宿主机网卡配置:
NAT模式安装KVM时候,已经默认配置好了。如果没有:
找回NAT:
#virsh net-define /usr/share/libvirt/networks/default.xml //目标:/etc/libvirt/storage/default.xml
#virsh net-autostart defalut //目标:/etc/libvirt/storage/autostart/default.xml
#virsh net-start default
[root@ywzx-01 ~]# virsh net-list
[root@ywzx-01 ~]#
BRIDGE模式,BRIDGE重点:
禁用NetworkManager工具,启用自带的network服务
chkconfig NetworkManager off
chkconfig network on
service NetworkManager stop
测试时,注意关闭宿主机与虚拟机的防火墙等,待测试完后再配置。
宿主机网卡:
[root@ywzx-01 ~]# cat /etc/sysconfig/network-scripts/ifcfg-br0
DEVICE=br0
TYPE=Bridge
#UUID=498400a2-bc2d-4680-963d-d0a585cdde5b
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=static
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
#NAME="System eth4"
#HWADDR=70:E2:84:0F:08:18
IPADDR=192.168.0.239
NETMASK=255.255.254.0
NETWORK=192.168.0.0
PREFIX=23
GATEWAY=192.168.1.1
DNS1=61.139.2.69
LAST_CONNECT=1438859818
[root@ywzx-01 ~]#
[root@ywzx-01 ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth4
DEVICE=eth4
TYPE=Ethernet
#UUID=498400a2-bc2d-4680-963d-d0a585cdde5b
ONBOOT=yes
#NM_CONTROLLED=yes
#BOOTPROTO=static
#DEFROUTE=yes
#IPV4_FAILURE_FATAL=yes
#IPV6INIT=no
#NAME="System eth4"
HWADDR=70:E2:84:0F:08:18
#IPADDR=192.168.0.239
#NETMASK=255.255.254.0
#PREFIX=23
#GATEWAY=192.168.1.1
#DNS1=61.139.2.69
#LAST_CONNECT=1438859818
BRIDGE="br0"
[root@ywzx-01 ~]#
重启network服务之后
service network restart
出现“Master connection not found or invalid”网络错误
关闭NetworkManager,重起网络
service NetworkManager stop
service network restart
[root@ywzx-01 ~]# brctl show
bridge name bridge id STP enabled interfaces
br0 8000.70e2840f0818 no eth4
vnet0
virbr0 8000.52540097dc51 yes virbr0-nic
bridge br0 已经搭建完成,eth4与虚拟机启动时候产生的vnet0已经在br0中
[root@ywzx-01 ~]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.122.0 0.0.0.0 255.255.255.0 U 0 0 0 virbr0
192.168.0.0 0.0.0.0 255.255.254.0 U 0 0 0 br0
169.254.0.0 0.0.0.0 255.255.0.0 U 1009 0 0 br0
0.0.0.0 192.168.1.1 0.0.0.0 UG 0 0 0 br0
[root@ywzx-01 ~]#
虚拟机网卡配置:
IPADDR=192.168.0.237
NETMASK=255.255.254.0
NETWORK=192.168.0.0
GATEWAY=192.168.1.1
DNS1=61.139.2.69
虚拟机VMware下RedHat Linux上网设置(bridged NAT方式)图文详解:http://www.linuxdiyf.com/linux/8736.html
VirtualBox在Ubuntu下配置桥接bridge的一些现象:http://www.linuxdiyf.com/linux/7197.html
Linux Bridge的镜像端口实现:http://www.linuxdiyf.com/linux/4270.html
Linux虚拟机采用NAT方式时如何能在虚拟机中访问互联网:http://www.linuxdiyf.com/linux/12354.html