qemu-discuss
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-discuss] About how to connect from guest "10.0.2.15" to remote


From: qzhan15
Subject: Re: [Qemu-discuss] About how to connect from guest "10.0.2.15" to remote "192.168.1.xx"
Date: Tue, 14 Feb 2012 21:32:01 +0800

Thanks for you advice

I followed the instructions

I found my host can't ping to any remote server now
and my guest also can't ping to the host ( i just config the eth0 to 192.168.1.200)

the command i use start qemu changed to 
qemu-system-x86_64 -kernel arch/x86/boot/bzImage -boot d -append 'console=ttyS0, 115200' -nographic -net nic,macaddr=00:00:00:00:00:00 -net tap,ifname=tap0,script=no,downscript=no

below is ifconfig and route table dump on my host 
address@hidden:~$ ifconfig
br0       Link encap:Ethernet  HWaddr 02:32:6d:ca:db:a5  
          inet addr:192.168.1.155  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::40ec:69ff:fee8:3d00/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:104 errors:0 dropped:0 overruns:0 frame:0
          TX packets:263 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:9992 (9.9 KB)  TX bytes:30390 (30.3 KB)

eth0      Link encap:Ethernet  HWaddr 08:00:27:ed:c9:b3  
          inet addr:192.168.1.100  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:feed:c9b3/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:56919 errors:0 dropped:0 overruns:0 frame:0
          TX packets:42953 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:81679486 (81.6 MB)  TX bytes:3243769 (3.2 MB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:98 errors:0 dropped:0 overruns:0 frame:0
          TX packets:98 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:10026 (10.0 KB)  TX bytes:10026 (10.0 KB)

tap0      Link encap:Ethernet  HWaddr 02:32:6d:ca:db:a5  
          inet6 addr: fe80::32:6dff:feca:dba5/64 Scope:Link
          UP BROADCAST RUNNING PROMISC MULTICAST  MTU:1500  Metric:1
          RX packets:29 errors:0 dropped:0 overruns:0 frame:0
          TX packets:204 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 address@hidden:~$ route -n


Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.1.1     0.0.0.0         UG    0      0        0 eth0
192.168.1.0     0.0.0.0         255.255.255.0   U     0      0        0 eth0
192.168.1.0     0.0.0.0         255.255.255.0   U     0      0        0 br0:500 
          RX bytes:1882 (1.8 KB)  TX bytes:29466 (29.4 KB)
在 2012-2-14,下午6:04, mathslinux 写道:

You can add a bridge in you host os, and add your host's net interface and
guest's net device to this bridge.

Codes you should use:
brctl addbr br0 # Create a bridge named br0.

ifconfig br0 192.168.1.155 netmask 255.255.255.0 up # Activate br0, and set it's ipaddress.(Change with your real ipaddress)

tunctl -b -u root -t tap0 # Create a new tap device named tap0 for root.

brctl addif br0 tap0 # Make the tap0 a port of br0.

ifconfig tap0 up 0.0.0.0 promisc # set the tap0

# below make your real interface a port of br0.
brctl addif br0 eth0 # Change eth0 with your real interface name.
ifconfig eth0 0.0.0.0
ifconfig eth0 up

# Then start qemu:
qemu-kvm -net nic,macaddr=00:00:00:00:00:00 -net tap,ifname=tap0,script=no,downscript=no /var/lib/libvirt/images/XP.img -m 1024



2012/2/14 Qi Zhang <address@hidden>
Hi There:

       I'm trying to use QEMU to emulate a simple Linux Guest for
some specific task
       I have download/compile the Linux 3.2.5 kernel and busybox
1.19.4 and successfully make the guest system running after some
simple setup.
       Also the guest system can mount host NFS after I set the eth0
IP to 10.0.2.15.  (mount -t nfs 10.0.2.2:/xxx/xxx /tmp)

       Now the host system is also connect to a LAN (192.168.1.10),
and there is application running on the guest system, who want to talk
to another server on the LAN (192.168.1.8)
       but guest (10.0.2.15) can't ping to the remote server (192.168.1.8),
       I have manually add the default gateway as 10.0.2.2, that
still not work.
       Destination     Gateway         Genmask         Flags Metric
Ref    Use Iface
       0.0.0.0         10.0.2.2        0.0.0.0         UG    0      0
      0 eth0
       10.0.0.0        0.0.0.0         255.0.0.0       U     0      0
      0 eth0

       Can anybody help me to figure it out?
       Wish the solution is not about use the tap/bridge solution,
       I was lack of related network knowledge and the only thing I
know is use QEMU "user net" is something similar as "NAT" option in
virtual box,
       though when use NAT the host can't ping to guest, but the
guest can ping to everywhere and there is no bridge I think

       BTW:
       my host system is Ubuntu 11.10 and the command to start the QEMU is
       "qemu-system-x86_64 -kernel arch/x86/boot/bzImage -boot d
-append 'console=ttyS0, 115200' -nographic -net nic -net user"

Thanks a lot!
Zhang Qi




--
linuxer and emacser and pythoner living in beijing
blog: http://mathslinux.org
twitter: https://twitter.com/mathslinux
google+: https://plus.google.com/118129852578326338750



reply via email to

[Prev in Thread] Current Thread [Next in Thread]