Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm completely new to KVM and the whole idea of virtualisation, but have been reading about it for a couple of days and playing with it for the last few hours.

Creating, installing, cloning etc... all seems great. But the guests that I make end up with "network unreachable" when I try to ping 8.8.8.8

I'm using CentOS 6.5 for both host and guests.

ifconfig on the guest:

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:0 errors:0 dropped:0 overruns:0 frame:0
      TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:0 
      RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

I appreciate that this is probably where the problem lies - there should be an eth0 device I assume? Why isn't there?

install code:

virt-install \
--virt-type kvm \
--name sebweb2 \
--ram 16384 \
--cdrom /var/ISOs/CentOS-6.5-x86_64-minimal.iso \
--disk /var/lib/libvirt/images/sebweb2.img,format=qcow2 \
--network bridge=br0 \
--nographics \
--os-type linux \
--os-variant rhel6 \
--vcpus 12

Host's ifconfig:

br0   Link encap:Ethernet  HWaddr 16:AC:2D:A6:98:40
      inet addr:xxx.yyy.zzz.217  Bcast:xxx.yyy.zzz.255  Mask:255.255.255.0
      UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
      RX packets:92172 errors:0 dropped:0 overruns:0 frame:0
      TX packets:58463 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:0
      RX bytes:5428257 (5.1 MiB)  TX bytes:71953860 (68.6 MiB)

eth0  Link encap:Ethernet  HWaddr 16:AC:2D:A6:98:40
      UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
      RX packets:117592 errors:0 dropped:0 overruns:0 frame:0
      TX packets:79097 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:1000
      RX bytes:8766798 (8.3 MiB)  TX bytes:73073312 (69.6 MiB)
      Memory:fbc00000-fbd00000

lo    Link encap:Local Loopback
      inet addr:127.0.0.1  Mask:255.0.0.0
      UP LOOPBACK RUNNING  MTU:16436  Metric:1
      RX packets:92 errors:0 dropped:0 overruns:0 frame:0
      TX packets:92 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:0
      RX bytes:8172 (7.9 KiB)  TX bytes:8172 (7.9 KiB)

virbr0 Link encap:Ethernet  HWaddr 51:54:00:39:CA:A7
      inet addr:192.168.122.1  Bcast:192.168.122.255  Mask:255.255.255.0
      UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
      RX packets:2 errors:0 dropped:0 overruns:0 frame:0
      TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:0
      RX bytes:128 (128.0 b)  TX bytes:0 (0.0 b)

vnet0 Link encap:Ethernet  HWaddr 54:FE:00:F1:31:95
      UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
      RX packets:0 errors:0 dropped:0 overruns:0 frame:0
      TX packets:256 errors:0 dropped:0 overruns:1 carrier:0
      collisions:0 txqueuelen:500
      RX bytes:0 (0.0 b)  TX bytes:20835 (20.3 KiB)

vnet1 Link encap:Ethernet  HWaddr 54:FE:00:CD:CD:C4
      UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
      RX packets:11 errors:0 dropped:0 overruns:0 frame:0
      TX packets:1307 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:500
      RX bytes:2722 (2.6 KiB)  TX bytes:110215 (107.6 KiB)

Any other relevant information I should supply?

Thanks!

share|improve this question

closed as off-topic by mdpc, Nathan C, MadHatter, RolandoMySQLDBA, Andrew B May 9 at 16:45

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions must be relevant to professional system administration. Server Fault is dedicated to professional system and network administrators. End user and enthusiast questions are off-topic (contact your system administrator or hire a professional to help you out). Please see the Help Center for more information." – mdpc, Nathan C, MadHatter, RolandoMySQLDBA, Andrew B
If this question can be reworded to fit the rules in the help center, please edit the question.

    
what does 'ifconfig -a' show? –  user1174838 May 8 at 1:39
    
ifconfig -a gives: eth0 Link encap:Ethernet HWaddr 51:54:00:29:86:47 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:1000 RX bytes:0 (0.0 b) TX bytes:0 (0.0 b) –  Codemonkey May 8 at 12:10
    
Based on the ifconfig -a output, I'd say check /etc/sysocnfig/network-scripts/ifcfg-eth0 on the guest and hard set the IP address info (IP, mask, gateway, etc), then restart the network service. That should get you going. –  user1174838 May 8 at 22:45
    
I've done that, and it accepts the IP I've put in (192.168.122.100) but I still can't ping 8.8.8.8. I now get "destination host unreachable" which is an improvement on "network unreachable". Do I need to do something with iptables on the host to allow these packets through? –  Codemonkey May 8 at 23:41
    
Can your KVM host ping 8.8.8.8? Also, what does ifconfig on the guest show now? –  user1174838 May 8 at 23:54

2 Answers 2

If "ifconfig -a" on the guest does not show an eth0, then run "virt-manager" on the host to get a nice GUI for editing the virtual machine's parameters instead of doing it on the command line. Through that GUI you can add a network interface if you need one.

Once you have an eth0 on the guest, then you will need to specify the parameters of the interface in the file /etc/sysconfig/network-scripts/ifcfg-eth0 . Be sure to specify a default gateway with the "GATEWAY" keyword. Here is a sample ifcfg script for manual specification of parameters (as opposed to using DHCP). You will of course need to supply the correct values of IPADDR, NETWORK, NETMASK, and GATEWAY for your network.

DEVICE=eth0
TYPE=Ethernet
ONBOOT=yes
NM_CONTROLLED=no
BOOTPROTO=static
IPADDR=192.168.1.110
NETWORK=192.168.1.0
NETMASK=255.255.255.0
GATEWAY=192.168.1.1

To put the changes to ifcfg-eth0 into effect, run "service network restart".

share|improve this answer
    
+1 for disabling network manager –  user1174838 May 8 at 4:51
    
Amen! It has burned me far too many times not to :-) –  kronuus May 8 at 6:30
    
I don't know what NetworkManager is, but I have already disabled it after reading similar comments in a guide somewhere. As an aside, why do I have a bridge on the host machine, is that needed or shuold I get rid of that? –  Codemonkey May 8 at 11:18
    
@Codemonkey: NetworkManager simplifies many things with todays mobile desktops where you switch from wired connection to WLAN X or tethered mobile connection or something else, but makes configuring VLANs, bridges and other server oriented stuff either hell or impossible. –  Janne Pikkarainen May 8 at 12:42

do "brctl show" on host

to verify that your vm is connected to bridge br0 and since your br0 is having public ip (i assume since you commented it) assign public ip to your guest vm with proper gateway.

or

remove your virtual interface from br0,and add it to virbr0.

on host

brctl delif br0 vifname 

brctl addif virbr0 vifname 

enable dhcp on your guest by setting BOOTPROTO=dhcp.

You will get an ip address in 192.168.122.0 and you should be able to access outside,provided you have correct NAT rules created by libvirt.

share|improve this answer
    
1) "brctl show" on the guest shows no bridge. 2) the delif/addif commands both return with "interface vifname does not exist" –  Codemonkey May 8 at 12:26
    
You want to do the brctl show on the KVM host, not the guest. The host does bridging to allow multiple guests (and the host itself) to all use the host's NIC at the same time. It basically turns the NIC into a switch (but not really 'cos switchs use ASICs and do their work in hardware whereas bridges work in software like what you're doing on your KVM host) –  user1174838 May 8 at 22:51

Not the answer you're looking for? Browse other questions tagged or ask your own question.