KVM work with bridge network problems

bridgekvm-virtualization

I try to configure bridge network for KVM(refer to http://www.linux-kvm.org/page/Networking), and it worked for Guest OS, but I have two problems with my Fedora host OS:

1、I can not access internet on host

2、The bridge configuration lost after reboot, I need to execute "service network restart" again to bring it up

I checked here(KVM network bridge with public static IP for both host and guests) for the first problem, it seems not working for me.

Any advice is appreciated!

ifconfig -a

eth0      Link encap:Ethernet  HWaddr 48:5B:39:ED:EB:5A  
          inet6 addr: fe80::4a5b:39ff:feed:eb5a/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:231340 errors:0 dropped:0 overruns:0 frame:0
          TX packets:413424 errors:0 dropped:0 overruns:0 carrier:1
          collisions:0 txqueuelen:1000 
          RX bytes:15335606 (14.6 MiB)  TX bytes:114755796 (109.4 MiB)
          Interrupt:44 

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:119307 errors:0 dropped:0 overruns:0 frame:0
          TX packets:119307 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:57151264 (54.5 MiB)  TX bytes:57151264 (54.5 MiB)

sit0      Link encap:IPv6-in-IPv4  
          NOARP  MTU:1480  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)

sw0       Link encap:Ethernet  HWaddr 48:5B:39:ED:EB:5A  
          inet addr:192.168.1.133  Bcast:255.255.255.255  Mask:255.255.255.0
          inet6 addr: fe80::4a5b:39ff:feed:eb5a/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:229584 errors:0 dropped:0 overruns:0 frame:0
          TX packets:401232 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:11047463 (10.5 MiB)  TX bytes:113891533 (108.6 MiB)

tap0      Link encap:Ethernet  HWaddr F2:86:1A:48:E2:55  
          inet6 addr: fe80::f086:1aff:fe48:e255/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:232 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2744 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:500 
          RX bytes:24842 (24.2 KiB)  TX bytes:243899 (238.1 KiB)

virbr0    Link encap:Ethernet  HWaddr 9A:7C:09:6B:85:65  
          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:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:46 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:0 (0.0 b)  TX bytes:5513 (5.3 KiB)

Best Answer

I am giving you my /etc/network/interfaces file where I configured a bridge to use with four VMs on Ubuntu server which also uses KVM (my default lan card is 3rd i.e. 0,1,2,3 so eth2 is used)

auto lo
iface lo inet loopback

# The primary network interface
auto eth2
iface eth2 inet manual

auto br0
iface br0 inet static
        address 192.168.1.17
        netmask 255.255.255.0
        network 192.168.1.0
        broadcast 192.168.100.255
        gateway 192.168.100.100
        # dns-* options are implemented by the resolvconf package, if installed
        dns-nameservers 192.168.103.2
        dns-search mydomain.com
        bridge_ports eth2
        bridge_fd 9
        bridge_hello 2
        bridge_maxage 12
        bridge_stp off

The above is a correct configuration.You might need to check /etc/network/interfaces manual page http://manpages.ubuntu.com/manpages/hardy/man5/interfaces.5.html to understand what the keyword manual in above does.

Post your network interfaces file where you defined bridge then we will be able to help.

I noticed your eth0 and sw0 are having same Mac address. Bridge works on Layer2 that might be source of your problem (some one correct me if I am wrong) and eth0 has IPv6 address where as sw0 has IPv4 address.This is not correct.