接上一篇
一:NAT模式
1. 虚拟机:查看NAT设置
- 记住如下信息:
image.png image.pngNAT子网IP
NAT子网掩码
NAT网关IP
2. windows:配置VMware Network Adapter VMnet8
image.pngIP地址:NAT子网地址最后一位不同即可
3. CentOS:配置网卡
- 3.1 切换到
root
用户
[m@localhost Desktop]$ su
Password:
[root@localhost Desktop]#
- 3.2 切换到网卡
[root@localhost Desktop]# cd /etc/sysconfig/network-scripts/
[root@localhost network-scripts]# ls
ifcfg-eno16777736 ifdown-ppp ifup-ib ifup-Team
ifcfg-lo ifdown-routes ifup-ippp ifup-TeamPort
ifdown ifdown-sit ifup-ipv6 ifup-tunnel
ifdown-bnep ifdown-Team ifup-isdn ifup-wireless
ifdown-eth ifdown-TeamPort ifup-plip init.ipv6-global
ifdown-ib ifdown-tunnel ifup-plusb network-functions
ifdown-ippp ifup ifup-post network-functions-ipv6
ifdown-ipv6 ifup-aliases ifup-ppp
ifdown-isdn ifup-bnep ifup-routes
ifdown-post ifup-eth ifup-sit
[root@localhost network-scripts]#
- 3.3 编辑网卡
[root@localhost network-scripts]# vi ifcfg-eno16777736
修改内容如下:别忘记去掉注释
TYPE=Ethernet
BOOTPROTO=none # 改为none
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_FAILURE_FATAL=no
NAME=eno16777736
UUID=8b6620fe-1b84-4e4a-82b3-c692b26f2973
DEVICE=eno16777736
ONBOOT=yes # 改yes
IPADDR=192.168.25.236 # NAT子网IP(最后一位不同即可)
GATEWAY=192.168.25.2 # NAT网关IP
DNS1=221.228.255.1 # 你的以太网的DNS
- 3.4 重启网络服务
[root@localhost network-scripts]# service network restart
- 3.5 测试
[root@localhost network-scripts]# ping www.baidu.com
PING www.a.shifen.com (180.97.33.107) 56(84) bytes of data.
64 bytes from 180.97.33.107: icmp_seq=1 ttl=128 time=5.57 ms
64 bytes from 180.97.33.107: icmp_seq=2 ttl=128 time=4.50 ms
64 bytes from 180.97.33.107: icmp_seq=3 ttl=128 time=5.12 ms
64 bytes from 180.97.33.107: icmp_seq=4 ttl=128 time=4.29 ms
64 bytes from 180.97.33.107: icmp_seq=5 ttl=128 time=4.73 ms
64 bytes from 180.97.33.107: icmp_seq=6 ttl=128 time=23.1 ms
二:桥接模式
1. windows:查看本地连接
- 记住如下信息:
image.png本地连接的IP地址
本地连接的子网掩码
本地连接的默认网关
本地连接的DNS服务器
2. windows:配置 VMware Network Adapter VMnet1
image.pngVMnet1的IP地址:本地连接的IP地址,最后一位不同即可
3. 虚拟机:改为桥接模式
image.png4. CentOS:配置网卡
- 4.1 切换到
root
用户
[m@localhost Desktop]$ su
Password:
[root@localhost Desktop]#
- 4.2 切换到网卡
[root@localhost Desktop]# cd /etc/sysconfig/network-scripts/
[root@localhost network-scripts]# ls
ifcfg-eno16777736 ifdown-ppp ifup-ib ifup-Team
ifcfg-lo ifdown-routes ifup-ippp ifup-TeamPort
ifdown ifdown-sit ifup-ipv6 ifup-tunnel
ifdown-bnep ifdown-Team ifup-isdn ifup-wireless
ifdown-eth ifdown-TeamPort ifup-plip init.ipv6-global
ifdown-ib ifdown-tunnel ifup-plusb network-functions
ifdown-ippp ifup ifup-post network-functions-ipv6
ifdown-ipv6 ifup-aliases ifup-ppp
ifdown-isdn ifup-bnep ifup-routes
ifdown-post ifup-eth ifup-sit
[root@localhost network-scripts]#
- 4.3 编辑网卡
[root@localhost network-scripts]# vi ifcfg-eno16777736
修改内容如下:别忘记去掉注释
TYPE="Ethernet"
BOOTPROTO="static" #改为static
DEFROUTE="yes"
PEERDNS="yes"
PEERROUTES="yes"
IPV4_FAILURE_FATAL="no"
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
IPV6_DEFROUTE="yes"
IPV6_PEERDNS="yes"
IPV6_PEERROUTES="yes"
IPV6_FAILURE_FATAL="no"
NAME="eno16777736"
UUID="377ec53d-cc17-4ee7-9deb-2e6daf0c9ff4"
DEVICE="eno16777736"
ONBOOT="yes" # 改为yes
IPADDR="10.88.99.175" # 添加VMnet1的IP地址(最后一位不同即可)
NETMASK="255.255.255.0" #添加本地连接的子网掩码
GATEWAY="10.88.99.12" #添加本地连接的默认网关
DNS1="221.228.255.12" #本地连接的DNS服务器
- 4.4 重启网络服务
[root@localhost network-scripts]# service network restart
- 4.5 测试
[root@localhost network-scripts]# ping www.baidu.com
网友评论