LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Virtualization and Cloud
User Name
Password
Linux - Virtualization and Cloud This forum is for the discussion of all topics relating to Linux Virtualization and Linux Cloud platforms. Xen, KVM, OpenVZ, VirtualBox, VMware, Linux-VServer and all other Linux Virtualization platforms are welcome. OpenStack, CloudStack, ownCloud, Cloud Foundry, Eucalyptus, Nimbus, OpenNebula and all other Linux Cloud platforms are welcome. Note that questions relating solely to non-Linux OS's should be asked in the General forum.

Notices

Reply
 
Search this Thread
Old 03-03-2010, 04:12 PM   #1
garydale
Member
 
Registered: Feb 2007
Posts: 122

Rep: Reputation: 22
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?
 
Old 03-03-2010, 08:22 PM   #2
gezley
Member
 
Registered: Sep 2009
Location: Ireland
Distribution: Slackware64, NetBSD
Posts: 495

Rep: Reputation: 207Reputation: 207Reputation: 207
Quote:
Originally Posted by garydale View Post
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.
 
Old 03-04-2010, 12:01 PM   #3
garydale
Member
 
Registered: Feb 2007
Posts: 122

Original Poster
Rep: Reputation: 22
Quote:
Originally Posted by gezley View Post
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)
 
Old 03-04-2010, 12:12 PM   #4
garydale
Member
 
Registered: Feb 2007
Posts: 122

Original Poster
Rep: Reputation: 22
Nevermind. It's started working (again?). I have no idea why but now I have access to the Internet to download program updates, etc..
 
Old 03-06-2010, 10:37 AM   #5
garydale
Member
 
Registered: Feb 2007
Posts: 122

Original Poster
Rep: Reputation: 22
Quote:
Originally Posted by garydale View Post
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.
 
Old 03-06-2010, 12:16 PM   #6
garydale
Member
 
Registered: Feb 2007
Posts: 122

Original Poster
Rep: Reputation: 22
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.
 
  


Reply

Tags
kvm, qemu, routing


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
On qemu-kvm, qemu-ifup script not found on Slackware 13 AndrewGaven Linux - Virtualization and Cloud 14 01-29-2010 03:36 AM
Loading kvm-intel module for qemu-kvm 0.11.0 alkos333 Slackware 6 11-13-2009 10:01 PM
manual network-setup for internet access john99 Incognito 3 07-24-2009 01:49 AM
Mount the QEmu virtual disk/Access CD Rom Iresh Ubuntu 2 07-18-2007 06:08 PM
I want to setup a dial up with access to the internal network and internet depam Linux - Software 2 05-02-2006 07:21 AM


All times are GMT -5. The time now is 09:37 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration