打开一台Linux虚拟机VM1,并添加2块网卡,一个使用VMware1网卡,一个使用VMware2网卡
配置VMware1网卡的IP地址为192.168.136.254/24; VMware2网卡的IP地址为192.168.137.254/24
[root@nb ~]# ifconfig ens33 192.168.136.254 netmask 255.255.255.0
[root@nb ~]# ifconfig ens37 192.168.137.254 netmask 255.255.255.0
打开Linux的路由转发功能
[root@nb ~]# vim /etc/sysctl.conf
[root@nb ~]# sysctl -p
打开第二台Linux VM2,网卡选择VMware1网络,然后设置其IP地址为192.168.136.100/24,网关为192.168.136.254
[root@nb ~]# nmcli connection add con-name vm1 ipv4.addresses "192.168.136.100/24" ipv4.gateway 192.168.136.254 type ethernet ifname ens37 ipv4.method manual
Connection 'vm1' (0b69a93d-4a55-4bdf-ab1e-284892b8974e) successfully added.
[root@wei ~]# cat /etc/sysconfig/network-scripts/ifcfg-vm1
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=none
IPADDR=192.168.136.100
PREFIX=24
GATEWAY=192.168.136.254
打开第三台LinuxVM3,网卡选择VMware2网络,然后设置其IP地址为192.168.137.100/24,网关为192.168.137.254
[root@test-server network-scripts]# nmcli connection add con-name test2 ifname ens37 type ethernet
[root@test-server network-scripts]# vim ifcfg-test2
BOOTPROTO=none
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=test2
UUID=380b35a5-df46-4de6-88c6-b6e68c92fd2a
DEVICE=ens37
ONBOOT=yes
IPADDR0="192.168.137.100"
PREFIX0="24"
GATEWAY0="192.168.137.254"
在VM2主机上使用root用户SSH访问VM3,并能够在VM3上创建目录/caiwubu
[root@localhost network-scripts]# ssh [email protected]
The authenticity of host '192.168.137.100 (192.168.137.100)' can't be established.
ECDSA key fingerprint is SHA256:2Hycwb7odM3yB9FZPipnqSHKHetRPiOrIit7fS8YScs.
ECDSA key fingerprint is MD5:21:9c:e2:96:2c:ee:fd:54:a7:34:28:af:0c:29:8d:1e.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.137.100' (ECDSA) to the list of known hosts.
[email protected]'s password:
Last login: Mon Oct 26 15:07:44 2020 from 192.168.181.1
[root@test-server ~]# mkdir /caiwubu
使用SCP命令将VM2的网卡配置文件,复制到VM3的/caiwubu目录下
[root@localhost network-scripts]# scp ./ifcfg-test1 [email protected]:/caiwubu