默认的kvm是nat模式,我需要用桥接模式。
1.去/etc/sysconfig/network-scripts目录下新增一个interface,ifcfg-br0文件,内容如下
[root@linuxsrv network-scripts]# cat ifcfg-br0
DEVICE=br0
TYPE=Bridge
BOOTRPOTO=static
IPADDR=192.168.101.41
NETMASK=255.255.255.0
GATEWAY=192.168.101.250
DNS1=192.168.102.1
ONBOOT=yes
2.我是用eth2,那么修改ifcfg-eth2,修改方法为去掉ip行,uuidh行,最后增加BRIDGE=br0
[root@linuxsrv network-scripts]# cat ifcfg-eth2
DEVICE="eth2"
BOOTPROTO=none
NM_CONTROLLED="yes"
ONBOOT=yes
TYPE="Ethernet"
#UUID="57b04eb5-0f04-489c-a961-7118e0d0294a"
HWADDR=00:1B:78:5D:35:A4
#IPADDR=192.168.101.41
PREFIX=24
#GATEWAY=192.168.101.250
#DNS1=192.168.102.1
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME="System eth2"
BRIDGE=br0
这样就将eth2桥接到br0。
3.重启网络
service network restart
后查看一下ifconfig
4. 查看当前桥接
[root@linuxsrv network-scripts]# brctl show
bridge name bridge id STP enabled interfaces
br0 8000.001b785d35a4 no eth2
virbr0 8000.525400ca78c1 yes virbr0-nic
5.将nic绑到新增的br0上
[root@linuxsrv network-scripts]# brctl delif virbr0 virbr0-nic
[root@linuxsrv network-scripts]# brctl addif br0 virbr0-nic
[root@linuxsrv network-scripts]# brctl show
bridge name bridge id STP enabled interfaces
br0 8000.001b785d35a4 no eth2
virbr0-nic
virbr0 8000.000000000000 yes
到此,操作完毕,然后就是在virt-manager里面给虚拟机选择新增的HostDevice virbr0-nic(Bridge 'br0')就可以了。
没有评论:
发表评论