LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Virtualization and Cloud (http://www.linuxquestions.org/questions/linux-virtualization-and-cloud-90/)
-   -   qemu-kvm howto setup virtual network to access Internet (http://www.linuxquestions.org/questions/linux-virtualization-and-cloud-90/qemu-kvm-howto-setup-virtual-network-to-access-internet-792981/)

garydale 03-03-2010 04:12 PM

qemu-kvm howto setup virtual network to access Internet
 
My network uses the 192.168.1.x range (pretty much hardcoded into my router) but when I start my Windows XP virtual machine, the qemu-kvm dhcp service gives it a 10.0.2.x address.

I'm running Debian/Squeeze and my /etc/network/interfaces file is:

auto br0
iface br0 inet dhcp
pre-up /usr/sbin/tunctl -u garydale -t tap0
pre-up ifconfig tap0 up
bridge_ports all tap0
post-down ifconfig tap0 down
post-down tunctl -d tap0

It gets me access to my server (Samba) so I can access network shares but my ability to get to the Internet is either iffy or nonexistent (not really sure which).

I can telnet to my server by name or IP address but I can't ping it or my router from the virtual machine.

Any ideas?

gezley 03-03-2010 08:22 PM

Quote:

Originally Posted by garydale (Post 3884570)
My network uses the 192.168.1.x range (pretty much hardcoded into my router) but when I start my Windows XP virtual machine, the qemu-kvm dhcp service gives it a 10.0.2.x address.

I'm running Debian/Squeeze and my /etc/network/interfaces file is:

auto br0
iface br0 inet dhcp
pre-up /usr/sbin/tunctl -u garydale -t tap0
pre-up ifconfig tap0 up
bridge_ports all tap0
post-down ifconfig tap0 down
post-down tunctl -d tap0

Have you added your physical (wired) interface to the bridge? If so you should be able to bypass DHCP and set XP manually to a 192.168.1.xxx address.

sidenote - in Slackware I set the IP address manually because I prefer to use rdesktop into an MS guest. It's faster and smoother than sdl - use "-nographic -daemonize" to start kvm without a virtual console, wait a couple of minutes till guest is fully up and then start your rdesktop script. Sorry for going off on a tangent - just explaining why I prefer not to use DHCP on the guest.

garydale 03-04-2010 12:01 PM

Quote:

Originally Posted by gezley (Post 3884848)
Have you added your physical (wired) interface to the bridge? If so you should be able to bypass DHCP and set XP manually to a 192.168.1.xxx address.

Sorry, yes the interfaces file I copied actually was incomplete. The full file is:

auto lo
iface lo inet loopback
address 127.0.0.1
netmask 255.0.0.0

mapping eth1
script grep
map eth1

iface eth0 inet manual

auto br0
iface br0 inet dhcp
pre-up /usr/sbin/tunctl -u garydale -t tap0
pre-up ifconfig tap0 up
bridge_ports all tap0
post-down ifconfig tap0 down
post-down tunctl -d tap0


The "mapping eth1" apparently allows hot-plugged NICs to be brought up when plugged in. I think the iface eth0... brings up the eth0 interface, which ifconfig shows is up but lacking an IPv4 address.

ifconfig shows:
br0 Link encap:Ethernet HWaddr 00:24:1d:14:d8:42
inet addr:192.168.1.17 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: 2002:63f3:ddfd:0:224:1dff:fe14:d842/64 Scope:Global
inet6 addr: fe80::224:1dff:fe14:d842/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:3858 errors:0 dropped:0 overruns:0 frame:0
TX packets:3749 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:1989136 (1.8 MiB) TX bytes:540901 (528.2 KiB)

eth0 Link encap:Ethernet HWaddr 00:24:1d:14:d8:42
inet6 addr: fe80::224:1dff:fe14:d842/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:3863 errors:0 dropped:0 overruns:0 frame:0
TX packets:3749 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:2045392 (1.9 MiB) TX bytes:540901 (528.2 KiB)
Interrupt:27 Base address:0x4000

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:2874 errors:0 dropped:0 overruns:0 frame:0
TX packets:2874 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:178308 (174.1 KiB) TX bytes:178308 (174.1 KiB)

tap0 Link encap:Ethernet HWaddr de:b0:87:ff:c2:87
inet6 addr: fe80::dcb0:87ff:feff:c287/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:357 overruns:0 carrier:0
collisions:0 txqueuelen:500
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)

garydale 03-04-2010 12:12 PM

Nevermind. It's started working (again?). I have no idea why but now I have access to the Internet to download program updates, etc..

garydale 03-06-2010 10:37 AM

Quote:

Originally Posted by garydale (Post 3885791)
Nevermind. It's started working (again?). I have no idea why but now I have access to the Internet to download program updates, etc..

And now it's stopped working. I didn't do anything in between - not even a reboot. I may have restart the virtual machine - that's the only thing I can think of. I'll do some more testing and report back.

However, if anyone has any ideas on the topic, please share them.

Thanks.

garydale 03-06-2010 12:16 PM

OK, it seems to be unrelated to rebooting my computer. I had Internet connectivity after my previous reboot and starting KVM, but not now. My last reboot of my physical machine and starting my virtual machine did not restore my Internet connection.

It also doesn't seem to a DNS issue. I can connect to my router via it's IP address but not to my Samba or CUPS servers via their IP address and port numbers.

I'm confused as to why I had Internet connectivity a couple of days ago but not now. I didn't change anything on my networking or virtual machine settings.


All times are GMT -5. The time now is 03:22 AM.