实现虚拟机上网的理论:通过设定让真机变为一个路由器,然后虚拟机通过连接虚拟机来实现上网功能
一:设定虚拟机为路由器:
[root@localhost ~]# systemctl stop libvirtd.service 配置防火墙之前要关闭libvirtd服务器
[root@localhost ~]# systemctl restart firewalld 重起放防火墙
[root@localhost ~]# systemctl start libvirtd.service 开启libvirtd服务器
[root@localhost ~]# firewall-cmd --add-masquerade 将masquerade功能添加在防火墙中
success
[root@localhost ~]# firewall-cmd --list-all 查看防火墙状态
public (active)
target: default
icmp-block-inversion: no
interfaces: ens3
sources:
services: dhcpv6-client ssh
ports:
protocols:
masquerade: yes 添加成功的masquerade: yes功能(默认为no)
实现虚拟机联网的核心步骤:
IP masquerade 是Linux发展中的一种网络功能,如果一台Linux主机使用IP masquerade功能连接到网络,那么连接到它的其他主机(不论是在同一