step
1. Install latest version bridge-utils in host, you can use 'yum insatll' or 'rpm'.
2. Update the script to enable bridge, include the bridge script and the
physical interface script:
# cat /etc/sysconfig/network-scripts/ifcfg-switch
DEVICE=switch
BOOTPROTO=dhcp
NM_CONTROLED=yes
PEERNTP=yes
ONBOOT=yes
TYPE=Bridge
DELAY=0
# cat /etc/sysconfig/network-scripts/ifcfg-em1
DEVICE=em1
ONBOOT=yes
BRIDGE=switch
HWADDR="1c:6f:65:06:b4:2e"
TYPE=Ethernet
3.Enable the configuration, and chech the result:
# ifup em1
# brctl show
# ping $external_host_ip -c 10
4.Configure network script for qemu.
# cat /etc/qemu-ifup
#!/bin/sh
switch=switch
/sbin/ifconfig $1 0.0.0.0 up
/usr/sbin/brctl addif ${switch} $1
5.Enable execution privilege to the script
# chmod +x qemu-ifup
6.Reboot host, and then check the network:
# ifconfig
# ping $external_host_ip -c 10
7.Launch a guest w/ network over bridge, and ping host w/ 10 counts.
-netdev tap,id=tap1,script=/etc/qemu-ifup \
-device virtio-net-pci,netdev=tap1,id=nic1,mac=1a:59:0a:4b:5a:94
Guest# ping $host_ip -c 10
Expected Result
1. After step 1confirm whether bridge-utils is installed
#rpm -q bridge-utils
bridge-utils-1.5-5.el7.x86_64
2. After step3, the bridge interface is set up successfully, mac address of
bridge interface and the physical inter face is same, and can get ip address
of bridge interface.
# brctl show
bridge name bridge id STP enabled interfaces
switch 0080.1c6f6506b42e no em1
and the ping successfully, bo pkg lost.
3. After step 6, bridge interface is up, and mac address of bridge interface
and the physical inter face is same, and can get ip address of bridge
interface, the ping successfully, bo pkg lost.
4. After step 7, guest can ip, and ping out successfully w/ no pkg lost.