[SATLUG] kvm networking

Bruce Dubbs bruce.dubbs at gmail.com
Mon Jan 23 17:04:31 CST 2012


I'm looking for help but this is pretty long.  Please trim any replies.

I am exploring kvm.  It is interesting technology, but I'm having a 
little problem figuring out how to set up networking.  I have been able 
to bring up a virtual system and install Fedora 16 on it.  I can then 
start that instance with:

qemu -hda vdisk.img -m 1G -net nic -net user

This provides network connectivity from the virtual system to the 
internet.

What I would like to do is get connectivity from the host to the client 
for an ssh connection.  The client has an ip address of 10.0.2.15/24 and 
a gateway of 10.0.2.2.

The host, on the other hand has no knowledge of any 10.x.x.x address.

Some documentation I've seen talks about using iptables/routing:

Host:
   sysctl -w net.ipv4.ip_forward=1
   route add -host <ip-of-client> dev <tap-device>

Client:
   route add -host <ip-of-host> dev <network-interface>
   route add default gw <ip-of-host>

I've tried this.  I have the following on the host:

#ls -l /dev/kv* /dev/net/*
crw-rw---- 1 root kvm  10, 232 Jan 23 13:37 /dev/kvm
crw-rw-rw- 1 root root 10, 200 Jan 23 13:37 /dev/net/tun

I have:

#cat /proc/sys/net/ipv4/ip_forward
1

#ls /proc/sys/net/ipv4/conf
all  default  eth0  lo  sit0  tap0  tunl0

#ifconfig tap0
tap0      Link encap:Ethernet  HWaddr 02:E2:D5:41:36:A3
           UP BROADCAST MULTICAST  MTU:1500  Metric:1
           RX packets:0 errors:0 dropped:0 overruns:0 frame:0
           TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
           collisions:0 txqueuelen:500
           RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

#route -n
Kernel IP routing table
Destination     Gateway      Genmask         Flags Metric Ref Use Iface
0.0.0.0         192.168.0.1  0.0.0.0         UG    0      0   0   eth0
10.0.2.15       0.0.0.0      255.255.255.255 UH    0      0   0   tap0
192.168.0.0     0.0.0.0      255.255.255.0   U     0      0   0   eth0

And the following on the client:

192.168.0.22    0.0.0.0      255.255.255.255 UH    0      0   0   tap0

However, there is is no direct connectivity between the host and client. 
  I suspect that it is due to the qemu options -net nic -net user, but I 
can't seem to figure out what to set.

Has anyone worked with this and figured it out?

   -- Bruce








More information about the SATLUG mailing list