Bridged networking gives the ability to make the virtual machines appear as just any other machine on the LAN, and I find it very useful while managing virtual networks. From Fedora 15 on wards, systemd has become the default init system on Fedora. Here is some quick notes on configuring bridging using the systemctl utility to control services on the system:
Disable the NetworkManager service, and turn on the classic network service:
[root@tbox ~]# systemctl disable NetworkManager.service
[root@tbox ~]# systemctl enable network.service
Create a bridge interface file, and modify your em1 interface(Note that, since ‘Consistent Network Device Naming’ feature is introduced, netowkr interface names have changed to em[1234] (correspondig to physical locations) from ethX
#----------------------------------------------------------#
[root@tbox network-scripts]# cat ifcfg-em1
DEVICE=em1
BOOTPROTO=dhcp
TYPE=Ethernet
ONBOOT=yes
IPV6INIT=no
NM_CONTROLLED=no
USERCTL=no
PEERDNS=yes
PEERROUTES=yes
BRIDGE=br0
#----------------------------------------------------------#
[root@tbox network-scripts]# cat ifcfg-br0
DEVICE=br0
TYPE=Bridge
BOOTPROTO=dhcp
ONBOOT=yes
DELAY=0
[root@tbox network-scripts]#
#----------------------------------------------------------#
Restart the network service:
[root@tbox ~]# systemctl restart network.service
Ensure ‘network’ service is enabled(and NetworkManager is disabled) for the next boot:
#----------------------------------------------------------#
[root@tbox ~]# systemctl is-enabled network.service
network.service is not a native service, redirecting to /sbin/chkconfig.
Executing /sbin/chkconfig network --level=5
enabled
[root@tbox ~]#
#----------------------------------------------------------#
[root@tbox ~]# systemctl | grep -i network.service
network.service loaded active running LSB: Bring up/down networking
[root@tbox ~]#
#----------------------------------------------------------#
[root@tbox ~]# systemctl is-enabled NetworkManager.service
disabled
[root@tbox ~]#
#----------------------------------------------------------#
End result — Bridge(br0) inteface will have the IP address, and the em1 would lose it, as expected:
#----------------------------------------------------------#
[root@tbox ~]# ifconfig br0
br0 Link encap:Ethernet HWaddr 00:21:9B:73:E2:65
inet addr:ww.xx.yy.zz Bcast:ww.xx.yy.255 Mask:255.255.255.0
inet6 addr: 2620:52:0:41c9:221:9bff:fe73:e265/64 Scope:Global
inet6 addr: fe80::44c0:2bff:fe0d:b38c/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:26475163 errors:0 dropped:0 overruns:0 frame:0
TX packets:3031754 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:1836168879 (1.7 GiB) TX bytes:304657564 (290.5 MiB)
[root@tbox ~]#
#----------------------------------------------------------#
[root@tbox ~]# ifconfig em1
em1 Link encap:Ethernet HWaddr 00:21:9B:73:E2:65
inet6 addr: fe80::221:9bff:fe73:e265/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:28841542 errors:0 dropped:0 overruns:0 frame:0
TX packets:4659974 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:3999390382 (3.7 GiB) TX bytes:580866999 (553.9 MiB)
Interrupt:16
#----------------------------------------------------------#
(NOTE: I just masked out IP with ‘ww.xx.yy.zz’)
UPDATE: I totally forgot to discuss the recent additions like ‘iface-bridge/iface-unbridge’ to libvirt to simplify creating a bridge. If someone wants to try, this should be the sequence to create a bridge:
# virsh iface-begin
# virsh iface-bridge em1 br0
# virsh iface-commit