KVM网络

KVM网络:

NAT模式:
KVM默认的网络方式,如果想要应用这种模式,防火墙需要打开,因为需要用到iptables规则

//打开防火墙添加规则,打开5900端口

[root@localhost ~]# firewall-cmd  --add-port=5900/tcp  --permanent 
success
[root@localhost ~]# firewall-cmd  --reload
success
[root@localhost ~]# firewall-cmd   --list-all

//添加路由转发:

[root@localhost ~]# echo  net.ipv4.ip_forward = 1  >>  /etc/sysctl.conf 
[root@localhost ~]# sysctl  -p
net.ipv4.ip_forward = 1

总结:
nat模式支持主机与虚拟机的互访,也支持虚拟机访问互联网,但不支持外网访问虚拟机域

桥接网络:
1)创建虚拟桥接网卡br0

[root@localhost ~]# systemctl  stop  NetworkManager
[root@localhost ~]# virsh  iface-bridge  ens33  br0  //提示失败不用理会
使用附加设备 br0 生成桥接 ens33 失败
已启动桥接接口 br0

//查看配置文件会看到,ens33桥接到了br0

[root@localhost network-scripts]# cat ifcfg-ens33
DEVICE=ens33
ONBOOT=yes
BRIDGE="br0"
[root@localhost network-scripts]# brctl  show
bridge name	bridge id		STP enabled	interfaces
br0		8000.000c2901f11f	yes		ens33
virbr0		8000.525400dc381b	yes		virbr0-nic

2)修改kvm虚拟机域的xml配置文件:

<interface type='bridge'>
<mac address='52:54:00:f8:a1:c9'/>
<source bridge='br0'/>

3)开启虚拟机,配置IP,验证是否能够联通外网:

[root@localhost ~]# vi  /etc/sysconfig/network-scripts/ifcfg-eth

//IP和br0的IP要在同一网段

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章