下载CentOS~7.9镜像
下载地址:https://llwp.linlink.xyz/%E8%BD%AF%E4%BB%B6%E7%B3%BB%E5%88%97/%E8%99%9A%E6%8B%9F%E6%9C%BA%E7%B3%BB%E5%88%97/%E7%B3%BB%E7%BB%9F%E9%95%9C%E5%83%8F/CentOS-7-x86_64-DVD-2009.iso
配置VMware网络
开始安装CentOS
选择Install CentOS 7
选择语言
分区(怎么都行)
直接安装
设置root密码
弱密码点两次
重启
配置NAT静态ip
查看网卡得知NAT的配置文件为ens33
1 2 3 4 5 6 7 8 9 10 11 12 13
| [root@localhost ~]# ip a 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 link/ether 00:0c:29:d5:f7:1b brd ff:ff:ff:ff:ff:ff inet 192.168.20.200/24 brd 192.168.20.255 scope global noprefixroute dynamic ens33 valid_lft 1489sec preferred_lft 1489sec inet6 fe80::f230:6540:5c24:735/64 scope link noprefixroute valid_lft forever preferred_lft forever
|
编辑ens33
1
| vi /etc/sysconfig/network-scripts/ifcfg-ens33
|
有的有双引号,有的没有,自己注意
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| TYPE="Ethernet" PROXY_METHOD="none" BROWSER_ONLY="no" BOOTPROTO="static" DEFROUTE="yes" IPV4_FAILURE_FATAL="no" IPV6INIT="yes" IPV6_AUTOCONF="yes" IPV6_DEFROUTE="yes" IPV6_FAILURE_FATAL="no" IPV6_ADDR_GEN_MODE="stable-privacy" NAME="ens33" UUID="d6084321-b13a-43b9-a474-26cb3ca78413" DEVICE="ens33" ONBOOT="yes" IPV6_PRIVACY="no" IPADDR="192.168.20.10" NETMASK="255.255.255.0" GATEWAY="192.168.20.2" DNS1="192.168.20.2"
|
关机
添加第二个网卡,放后面不容易出错(需要就操作不需要就跳过)
必须确定第一张网卡是NAT,第二张网卡是仅主机
配置仅主机模式静态ip
查看网卡得知仅主机模式的配置文件为ens36,有的是ens34或者其它
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| [root@localhost ~]# ip a 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 link/ether 00:0c:29:d5:f7:1b brd ff:ff:ff:ff:ff:ff inet 192.168.20.200/24 brd 192.168.20.255 scope global noprefixroute dynamic ens33 valid_lft 1730sec preferred_lft 1730sec inet6 fe80::f230:6540:5c24:735/64 scope link noprefixroute valid_lft forever preferred_lft forever 3: ens36: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 link/ether 00:0c:29:d5:f7:25 brd ff:ff:ff:ff:ff:ff inet 192.168.10.200/24 brd 192.168.10.255 scope global noprefixroute dynamic ens36 valid_lft 1729sec preferred_lft 1729sec inet6 fe80::1da4:c7ed:f085:ce2d/64 scope link noprefixroute valid_lft forever preferred_lft forever
|
查看是否有ens36文件,好像是没有,有就直接编辑它
1 2 3 4 5 6 7
| [root@localhost ~]# ll /etc/sysconfig/network-scripts/ total 232 -rw-r--r--. 1 root root 328 Sep 23 11:39 ifcfg-ens33 -rw-r--r--. 1 root root 254 May 22 2020 ifcfg-lo lrwxrwxrwx. 1 root root 24 Sep 23 11:38 ifdown -> ../../../usr/sbin/ifdown -rwxr-xr-x. 1 root root 654 May 22 2020 ifdown-bnep -rwxr-xr-x. 1 root root 6532 May 22 2020 ifdown-eth
|
如果没有ens36,如果是ens34,把下面ens36修改为ens34
1
| nmcli con add con-name ens36 type ethernet ifname ens36
|
继续查看有没有ens36文件,这下有了
1 2 3 4 5 6 7 8 9 10
| [root@localhost ~]# ll /etc/sysconfig/network-scripts/ total 236 -rw-r--r--. 1 root root 328 Sep 23 11:39 ifcfg-ens33 -rw-r--r--. 1 root root 280 Sep 23 12:03 ifcfg-ens36 -rw-r--r--. 1 root root 254 May 22 2020 ifcfg-lo lrwxrwxrwx. 1 root root 24 Sep 23 11:38 ifdown -> ../../../usr/sbin/ifdown -rwxr-xr-x. 1 root root 654 May 22 2020 ifdown-bnep -rwxr-xr-x. 1 root root 6532 May 22 2020 ifdown-eth -rwxr-xr-x. 1 root root 781 May 22 2020 ifdown-ippp -rwxr-xr-x. 1 root root 4540 May 22 2020 ifdown-ipv6
|
编辑ens36
1
| vi /etc/sysconfig/network-scripts/ifcfg-ens36
|
有的有双引号,有的没有,自己注意
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| TYPE=Ethernet PROXY_METHOD=none BROWSER_ONLY=no BOOTPROTO=static DEFROUTE=yes IPV4_FAILURE_FATAL=no IPV6INIT=yes IPV6_AUTOCONF=yes IPV6_DEFROUTE=yes IPV6_FAILURE_FATAL=no IPV6_ADDR_GEN_MODE=stable-privacy NAME=ens36 UUID=e58dad0e-108b-4039-9ad3-2bec0f5799c0 DEVICE=ens36 ONBOOT=yes IPADDR=192.168.10.10 NETMASK=255.255.255.0 GATEWAY=192.168.10.2 DNS1=192.168.10.2
|
重启网卡
1
| systemctl restart network
|
查看ip
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| [root@localhost ~]# ip a 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 link/ether 00:0c:29:d5:f7:1b brd ff:ff:ff:ff:ff:ff inet 192.168.20.10/24 brd 192.168.20.255 scope global noprefixroute ens33 valid_lft forever preferred_lft forever inet6 fe80::f230:6540:5c24:735/64 scope link noprefixroute valid_lft forever preferred_lft forever 3: ens36: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 link/ether 00:0c:29:d5:f7:25 brd ff:ff:ff:ff:ff:ff inet 192.168.10.10/24 brd 192.168.10.255 scope global noprefixroute ens36 valid_lft forever preferred_lft forever inet6 fe80::5cdf:75f:54b:12dd/64 scope link noprefixroute valid_lft forever preferred_lft forever
|
测试网络连通性
1 2 3 4 5 6 7 8 9 10 11
| [root@localhost ~]# ping baidu.com PING baidu.com (110.242.68.66) 56(84) bytes of data. 64 bytes from 110.242.68.66 (110.242.68.66): icmp_seq=1 ttl=128 time=45.5 ms 64 bytes from 110.242.68.66 (110.242.68.66): icmp_seq=2 ttl=128 time=45.6 ms 64 bytes from 110.242.68.66 (110.242.68.66): icmp_seq=3 ttl=128 time=45.5 ms 64 bytes from 110.242.68.66 (110.242.68.66): icmp_seq=4 ttl=128 time=45.7 ms 64 bytes from 110.242.68.66 (110.242.68.66): icmp_seq=5 ttl=128 time=45.4 ms ^C --- baidu.com ping statistics --- 5 packets transmitted, 5 received, 0% packet loss, time 4010ms rtt min/avg/max/mdev = 45.468/45.613/45.793/0.291 ms
|