目录
1.设置虚拟机网络适配器,选择自定义VMnet8(NAT模式)
一、NAT模式联网
1.设置虚拟机网络适配器,选择自定义VMnet8(NAT模式)
2.修改分配的网段
3.配置网关地址:192.168.8.254
网关地址可以使当前网段未被占用的任意一个
4.配置虚拟机网络配置
使用nmtui打开系统自带图像页面配置ip地址、网关
激活修改的网卡信息
设置完毕退出
[root@A /]# route –n #查看网关地址
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.8.254 0.0.0.0 UG 100 0 0 eth0
192.168.1.0 0.0.0.0 255.255.255.0 U 100 0 0 eth0
192.168.122.0 0.0.0.0 255.255.255.0 U 0 0 0 virbr0
[root@A /]# ping www.baidu.com #测试通信
PING www.a.shifen.com (61.135.169.125) 56(84) bytes of data.
64 bytes from 61.135.169.125 (61.135.169.125): icmp_seq=1 ttl=128 time=4.24 ms
64 bytes from 61.135.169.125 (61.135.169.125): icmp_seq=2 ttl=128 time=3.76 ms
64 bytes from 61.135.169.125 (61.135.169.125): icmp_seq=3 ttl=128 time=5.43 ms
二、桥接模式联网
修改虚拟机网卡适配器为桥接模式:
将网卡设置成自动获取IP:
[root@localhost ~]# nmcli connection modify eth0 ipv4.method auto connection.autoconnect yes
[root@localhost ~]# nmcli connection up eth0
连接已成功激活(D-Bus 活动路径: /org/freedesktop/NetworkManager/ActiveConnection/4)
[root@localhost ~]# ifconfig | head -2
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 172.40.93.124 netmask 255.255.255.0 broadcast 172.40.93.255
[root@localhost ~]# ping www.baidu.com
PING www.a.shifen.com (182.61.200.6) 56(84) bytes of data.
64 bytes from 182.61.200.6 (182.61.200.6): icmp_seq=1 ttl=53 time=4.41 ms
64 bytes from 182.61.200.6 (182.61.200.6): icmp_seq=2 ttl=53 time=4.15 ms
64 bytes from 182.61.200.6 (182.61.200.6): icmp_seq=3 ttl=53 time=4.32 ms
64 bytes from 182.61.200.6 (182.61.200.6): icmp_seq=4 ttl=53 time=4.48 ms