器量大者,福泽必厚
全部博文(587)
分类: LINUX
2012-08-09 17:10:00
With bridged networking you can share actual network device with KVM machines. This is required for servers with multiple network cards and gives you good performance. You can choose to put multiple segments into one bridged network or to divide it into different networks interconnected by routers
.老外的一篇文章! 写的很详细!
Our Sample Setup:
The following describes the networking used by our setup:
The NetworkManager (GUI) tool can create problems with bridged based networking so disable it as follows, enter:
# chkconfig NetworkManager off
# chkconfig network on
# service NetworkManager stop
Edit /etc/sysconfig/network, enter:
# vi /etc/sysconfig/network
Update file as follows:
NETWORKING=yes
Save and close the file.
br0: Configure Bridging for eth0
Edit /etc/sysconfig/network-scripts/ifcfg-eth0, enter:
# vi /etc/sysconfig/network-scripts/ifcfg-eth0
Update it as follows:
Save and close the file.
Create /etc/sysconfig/network-scripts/ifcfg-br0, enter:
# vi /etc/sysconfig/network-scripts/ifcfg-br0
Update it as follows (note options are case sensitive i.e. Bridge and bridge are two different options)
Save and close the file.
Finally, create static routing file /etc/sysconfig/network-scripts/route-br0, enter :
# vi /etc/sysconfig/network-scripts/route-br0
Edit it as follows:
10.0.0.0/8 via 10.10.21.122 dev br0
Save and close the file. Delete old /etc/sysconfig/network-scripts/route-eth0 (if exists):
# rm /etc/sysconfig/network-scripts/route-eth0
Edit /etc/sysconfig/network-scripts/ifcfg-eth1, enter:
# vi /etc/sysconfig/network-scripts/ifcfg-eth1
Update it as follows:
Please note that test server is set to 100Mbps full duplex. Save and close the file.
Edit /etc/sysconfig/network-scripts/ifcfg-br1, enter:
# vi /etc/sysconfig/network-scripts/ifcfg-br1
Define public IP address including gateway as follows:
Save and close the file.
Restart Network Service
Type the following command:
# service network restart
Make sure everything is working fine:
# brctl show
Sample outputs:
Verify IPs and routing tables:
# ip addr show br0
# ip addr show br1
# ip route
# ping cyberciti.biz ##确认网络是否通!
# host google.com
另外一篇讲述KVM 网络的文章!
在Redhat Enterprise Linux 5 (RHEL5)上设置KVM虚拟机时有两种网络选项:
另外一部分介绍:
1.桥模式简介
关于桥的模式:
其实我们在虚拟机搭建的时候,我们最终关心的网卡是: eth0, br0, vnet0,vnet1… 其中,
我们的eth0是原来的物理网卡,br0是我们虚拟出来的桥设备,而vnetXXX就是桥接映射到虚拟机里面用到的网卡。
当配置完了之后,我们使用ifconfig,查看起来的话,eth0是没有ip地址的,而br0仿佛是虚拟出来的一个原来eth0的访问接口,
它具有ip地址,可以代替原来的eth0被访问,而vnetXX的地址可以在建立虚拟机之后在虚拟机里面配置
,桥接后可以被外部访问。
brctl addbr br0 # 创建一个桥接口
brctl addif br0 eth0 # 添加eth0到br0,
在安装KVM的时候,系统会自动安装virbr0这个设备的,这个设备在使用NAT模式才会用到,这里我们使用的桥接模式,其实是可以将它删除掉
brctl delbr virbr0 如果显示在用的话,就要先ifconfig virbr0 down将该网桥停掉,然后再删除!