RHEL6.0 QEMU/KVM 建立新的虚拟机之配置Birdged Networking
Bridged networking (aka, physical device sharing)被用来为Virtual machine 指定一个专门的物理网卡设备。
首先, 由于NetworkManager不支持bridging,所以,需要disable NetworkManager servcie. 这样才可以使用network scripts(/etc/sysconfig/network-scripting/ 目录下)来管理网络。
chkconfig NetworkManager off
chkconfig network on
service NetworkManager stop
service network start
接下来 创建bridge
1 chdir 到network scripts directory
# cd /etc/sysconfig/network-scripts
2 修改network interface来创建一个bridge
编辑 /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE="eth0"
BOOTPROTO="dhcp"
HWADDR="00:1E:0B:EA:4C:C4"
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
NM_CONTROLLED="yes"
ONBOOT="yes"
BRIDGE=br0
# eth0成为bridge的一部分
3 创建bridge script
在/etc/sysconfig/network-scripts/下创建一个新的network script ifcfg-br0。 主要注意br0是新建bridge的名字。新的ifcfg-br0的内容如下:
DEVICE=br0
TYPE=Bridge
BOOTPROTO=dhcp
ONBOOT=yes
DELAY=0
4配置完成以后,需要重启networking 或者reboot
service network restart
5 配置iptables
Configure iptables to allow all traffic to be forwarded across the bridge.
# iptables -I FORWARD -m physdev --physdev-is-bridged -j ACCEPT
# service iptables save
# service iptables restart
或者 disable iptables on bridges: 在/etc/sysctl.conf 配置文件中,添加如下行:
net.bridge.bridge-nf-call-ip6tables = 0
net.bridge.bridge-nf-call-iptables = 0
net.bridge.bridge-nf-call-arptables = 0
通过sysctl 命令,然后重新加载kernel parameter
sysctl –p /etc/sysctl.conf
6 重新启动libvirt service
service libvirtd reload
7 验证bridge
brctl show
output:
bridge name bridge id STP enabled interfaces
virbr0 8000.000000000000 yes
br0 8000.000e0cb30550 no eth0