1、分別使用vmware將兩台linux虛擬機還原至安裝的初始狀態(前提是已經創建快照,實驗目的是配置網卡信息,確保兩台主機可以通信,因此需要兩台虛擬機)
2、為了更加清晰的分辨兩台主機,先分別配置主機名稱,並查看系統版本
[root@linuxprobe Desktop]# vim /etc/hostname ## 修改虛擬機1主機名稱 host1 [root@linuxprobe Desktop]# hostname ## 查看 host1 [root@linuxprobe Desktop]# hostnamectl ## 查看系統信息 Static hostname: host1 Icon name: computer Chassis: n/a Machine ID: 3475295383774df4b83491fd573fbbc2 Boot ID: 71ab80ee01054f5b84d6cd935259a977 Virtualization: vmware Operating System: Red Hat Enterprise Linux Server 7.0 (Maipo) CPE OS Name: cpe:/o:redhat:enterprise_linux:7.0:GA:server Kernel: Linux 3.10.0-123.el7.x86_64 Architecture: x86_64 [root@linuxprobe Desktop]# reboot ## 重啟,是主機名稱生效
[root@linuxprobe Desktop]# vim /etc/hostname ## 修改虛擬機2主機名稱 host2 [root@linuxprobe Desktop]# hostname ## 查看 host2 [root@linuxprobe Desktop]# hostnamectl ## 查看系統版本信息,也是RHEL7 Static hostname: linuxprobe.com Icon name: computer Chassis: n/a Machine ID: 94333412b1ab4fb8b024d9b7038e4caa Boot ID: 3998b9eeab3f45ffa78549f214f057ae Virtualization: vmware Operating System: Red Hat Enterprise Linux Server 7.0 (Maipo) CPE OS Name: cpe:/o:redhat:enterprise_linux:7.0:GA:server Kernel: Linux 3.10.0-123.el7.x86_64 Architecture: x86_64 [root@linuxprobe Desktop]# reboot ## 重啟使主機名稱生效
2、分別查看兩台虛擬機的網卡信息
[root@host1 Desktop]# ifconfig ## 查看虛擬機1網卡信息,有網卡名稱,MAC地址,但是沒有IP信息 eno16777728: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 ether 00:0c:29:e4:f7:b9 txqueuelen 1000 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10<host> loop txqueuelen 0 (Local Loopback) RX packets 658 bytes 51740 (50.5 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 658 bytes 51740 (50.5 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
[root@host2 Desktop]# ifconfig ## 查看虛擬機2的網卡信息,有網卡名稱,MAC地址,但是沒有IP eno16777728: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 ether 00:0c:29:aa:2b:29 txqueuelen 1000 (Ethernet) RX packets 1 bytes 243 (243.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10<host> loop txqueuelen 0 (Local Loopback) RX packets 530 bytes 41628 (40.6 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 530 bytes 41628 (40.6 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
3、分別修改兩台虛擬機的網卡配置文件
[root@host1 Desktop]# cd /etc/sysconfig/network-scripts/ ## 進入虛擬機1網卡配置文件目錄 [root@host1 network-scripts]# ls ifcfg-eno16777728 ifdown-ippp ifdown-routes ifup ifup-ipv6 ifup-ppp ifup-tunnel ifcfg-lo ifdown-ipv6 ifdown-sit ifup-aliases ifup-isdn ifup-routes ifup-wireless ifdown ifdown-isdn ifdown-Team ifup-bnep ifup-plip ifup-sit init.ipv6-global ifdown-bnep ifdown-post ifdown-TeamPort ifup-eth ifup-plusb ifup-Team network-functions ifdown-eth ifdown-ppp ifdown-tunnel ifup-ippp ifup-post ifup-TeamPort network-functions-ipv6 [root@host1 network-scripts]# vim ifcfg-eno16777728 ## 編輯配置文件 TYPE=Ethernet BOOTPROTO=static NAME=eno16777728 ONBOOT=yes IPADDR=192.168.10.10 NETMASK=255.255.255.0 GATEWAY=192.168.10.1 DNS1=192.168.10.1
## 參數解釋
##TYPE:網絡類型
##BOOTPROTO:地址分配模式
##NAME:網卡名臣
##ONBOOT:是否開機自動重啟網卡
##IPADDR:IP地州
##NETMADK:子網掩碼
##GATEWAY:網關地址
##DNS1:DNS地址
[root@host1 network-scripts]# ifconfig ## 查看網卡重啟前網卡信息 eno16777728: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 ether 00:0c:29:e4:f7:b9 txqueuelen 1000 (Ethernet) RX packets 5 bytes 762 (762.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10<host> loop txqueuelen 0 (Local Loopback) RX packets 786 bytes 61852 (60.4 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 786 bytes 61852 (60.4 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 [root@host1 network-scripts]# systemctl restart network ## 重啟網卡 [root@host1 network-scripts]# ifconfig ## 查看網卡重啟后網卡信息,多出了IP信息 eno16777728: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.10.10 netmask 255.255.255.0 broadcast 192.168.10.255 inet6 fe80::20c:29ff:fee4:f7b9 prefixlen 64 scopeid 0x20<link> ether 00:0c:29:e4:f7:b9 txqueuelen 1000 (Ethernet) RX packets 5 bytes 762 (762.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 26 bytes 3600 (3.5 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10<host> loop txqueuelen 0 (Local Loopback) RX packets 793 bytes 62618 (61.1 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 793 bytes 62618 (61.1 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 [root@host1 network-scripts]# ping -c 3 192.168.10.10 ## 本地主機測試網絡聯通性,聯通 PING 192.168.10.10 (192.168.10.10) 56(84) bytes of data. 64 bytes from 192.168.10.10: icmp_seq=1 ttl=64 time=0.056 ms 64 bytes from 192.168.10.10: icmp_seq=2 ttl=64 time=0.040 ms 64 bytes from 192.168.10.10: icmp_seq=3 ttl=64 time=0.042 ms --- 192.168.10.10 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2000ms rtt min/avg/max/mdev = 0.040/0.046/0.056/0.007 ms
[root@host2 Desktop]# cd /etc/sysconfig/network-scripts/ ## 進入虛擬機2網卡配置文件所在目錄 [root@host2 network-scripts]# ls ifcfg-eno16777728 ifdown-bnep ifdown-ipv6 ifdown-ppp ifdown-Team ifup ifup-eth ifup-isdn ifup-post ifup-sit ifup-tunnel network-functions ifcfg-lo ifdown-eth ifdown-isdn ifdown-routes ifdown-TeamPort ifup-aliases ifup-ippp ifup-plip ifup-ppp ifup-Team ifup-wireless network-functions-ipv6 ifdown ifdown-ippp ifdown-post ifdown-sit ifdown-tunnel ifup-bnep ifup-ipv6 ifup-plusb ifup-routes ifup-TeamPort init.ipv6-global [root@host2 network-scripts]# vim ifcfg-eno16777728 ## 編輯配置文件 TYPE=Ethernet BOOTPROTO=static NAME=eno16777728 ONBOOT=yes IPADDR=192.168.10.20 NETMASK=255.255.255.0 GATEWAY=192.168.10.1 DNS1=192.168.10.1 [root@host2 network-scripts]# ifconfig ## 查看重啟網卡前網卡信息 eno16777728: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 ether 00:0c:29:aa:2b:29 txqueuelen 1000 (Ethernet) RX packets 104 bytes 6885 (6.7 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10<host> loop txqueuelen 0 (Local Loopback) RX packets 914 bytes 71964 (70.2 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 914 bytes 71964 (70.2 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 [root@host2 network-scripts]# systemctl restart network ## 重啟網卡 [root@host2 network-scripts]# ifconfig ## 查看網卡重啟后網卡信息,多出了IP信息 eno16777728: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.10.20 netmask 255.255.255.0 broadcast 192.168.10.255 inet6 fe80::20c:29ff:feaa:2b29 prefixlen 64 scopeid 0x20<link> ether 00:0c:29:aa:2b:29 txqueuelen 1000 (Ethernet) RX packets 104 bytes 6885 (6.7 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 26 bytes 3736 (3.6 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10<host> loop txqueuelen 0 (Local Loopback) RX packets 921 bytes 72730 (71.0 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 921 bytes 72730 (71.0 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 [root@host2 network-scripts]# ping 192.168.10.20 ## 本地主機測試聯通性,聯通 PING 192.168.10.20 (192.168.10.20) 56(84) bytes of data. 64 bytes from 192.168.10.20: icmp_seq=1 ttl=64 time=0.031 ms 64 bytes from 192.168.10.20: icmp_seq=2 ttl=64 time=0.056 ms 64 bytes from 192.168.10.20: icmp_seq=3 ttl=64 time=0.041 ms 64 bytes from 192.168.10.20: icmp_seq=4 ttl=64 time=0.042 ms ^C --- 192.168.10.20 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3000ms rtt min/avg/max/mdev = 0.031/0.042/0.056/0.011 ms
4、測試虛擬機1和虛擬機2是否聯通
[root@host1 network-scripts]# ifconfig | head -n 3 ## 查看虛擬機1 IP eno16777728: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.10.10 netmask 255.255.255.0 broadcast 192.168.10.255 inet6 fe80::20c:29ff:fee4:f7b9 prefixlen 64 scopeid 0x20<link> [root@host1 network-scripts]# ping -c 5 192.168.10.20 ## 測試虛擬機1和虛擬機2的聯通性,聯通 PING 192.168.10.20 (192.168.10.20) 56(84) bytes of data. 64 bytes from 192.168.10.20: icmp_seq=1 ttl=64 time=0.423 ms 64 bytes from 192.168.10.20: icmp_seq=2 ttl=64 time=0.187 ms 64 bytes from 192.168.10.20: icmp_seq=3 ttl=64 time=0.209 ms 64 bytes from 192.168.10.20: icmp_seq=4 ttl=64 time=0.220 ms 64 bytes from 192.168.10.20: icmp_seq=5 ttl=64 time=0.199 ms --- 192.168.10.20 ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4001ms rtt min/avg/max/mdev = 0.187/0.247/0.423/0.090 ms [root@host2 network-scripts]# ifconfig | head -n 3 ## 查看虛擬機2IP eno16777728: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.10.20 netmask 255.255.255.0 broadcast 192.168.10.255 inet6 fe80::20c:29ff:feaa:2b29 prefixlen 64 scopeid 0x20<link> [root@host2 network-scripts]# ping -c 5 192.168.10.10 ## 測試聯通性,聯通 PING 192.168.10.10 (192.168.10.10) 56(84) bytes of data. 64 bytes from 192.168.10.10: icmp_seq=1 ttl=64 time=0.272 ms 64 bytes from 192.168.10.10: icmp_seq=2 ttl=64 time=0.246 ms 64 bytes from 192.168.10.10: icmp_seq=3 ttl=64 time=0.219 ms 64 bytes from 192.168.10.10: icmp_seq=4 ttl=64 time=0.230 ms 64 bytes from 192.168.10.10: icmp_seq=5 ttl=64 time=0.255 ms --- 192.168.10.10 ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4002ms rtt min/avg/max/mdev = 0.219/0.244/0.272/0.023 ms
5、修改虛擬機1網卡IP,測試和虛擬機2的聯通性
[root@host1 network-scripts]# ls ifcfg-eno16777728 ifdown-ippp ifdown-routes ifup ifup-ipv6 ifup-ppp ifup-tunnel ifcfg-lo ifdown-ipv6 ifdown-sit ifup-aliases ifup-isdn ifup-routes ifup-wireless ifdown ifdown-isdn ifdown-Team ifup-bnep ifup-plip ifup-sit init.ipv6-global ifdown-bnep ifdown-post ifdown-TeamPort ifup-eth ifup-plusb ifup-Team network-functions ifdown-eth ifdown-ppp ifdown-tunnel ifup-ippp ifup-post ifup-TeamPort network-functions-ipv6 [root@host1 network-scripts]# vim ifcfg-eno16777728 ## 修改配置文件 TYPE=Ethernet BOOTPROTO=static NAME=eno16777728 ONBOOT=yes IPADDR=192.168.3.10 NETMASK=255.255.255.0 GATEWAY=192.168.3.1 DNS1=192.168.3.1 [root@host1 network-scripts]# ifconfig ## 查看重啟網卡前網卡信息 eno16777728: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.10.10 netmask 255.255.255.0 broadcast 192.168.10.255 inet6 fe80::20c:29ff:fee4:f7b9 prefixlen 64 scopeid 0x20<link> ether 00:0c:29:e4:f7:b9 txqueuelen 1000 (Ethernet) RX packets 140 bytes 12075 (11.7 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 231 bytes 16610 (16.2 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10<host> loop txqueuelen 0 (Local Loopback) RX packets 931 bytes 75480 (73.7 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 931 bytes 75480 (73.7 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 [root@host1 network-scripts]# systemctl restart network ## 重啟網卡 [root@host1 network-scripts]# ifconfig ## 查看重啟網卡后網卡信息,IP信息發生變化 eno16777728: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.3.10 netmask 255.255.255.0 broadcast 192.168.3.255 inet6 fe80::20c:29ff:fee4:f7b9 prefixlen 64 scopeid 0x20<link> ether 00:0c:29:e4:f7:b9 txqueuelen 1000 (Ethernet) RX packets 140 bytes 12075 (11.7 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 257 bytes 20056 (19.5 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10<host> loop txqueuelen 0 (Local Loopback) RX packets 942 bytes 76666 (74.8 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 942 bytes 76666 (74.8 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 [root@host1 network-scripts]# ping -c 3 192.168.3.10 ## 測試本地聯通性,聯通 PING 192.168.3.10 (192.168.3.10) 56(84) bytes of data. 64 bytes from 192.168.3.10: icmp_seq=1 ttl=64 time=0.031 ms 64 bytes from 192.168.3.10: icmp_seq=2 ttl=64 time=0.041 ms 64 bytes from 192.168.3.10: icmp_seq=3 ttl=64 time=0.043 ms --- 192.168.3.10 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 1999ms rtt min/avg/max/mdev = 0.031/0.038/0.043/0.007 ms [root@host1 network-scripts]# ping -c 3 192.168.10.20 ## 測試和虛擬機2的連通性,不聯通 PING 192.168.10.20 (192.168.10.20) 56(84) bytes of data. From 192.168.3.10 icmp_seq=1 Destination Host Unreachable From 192.168.3.10 icmp_seq=2 Destination Host Unreachable From 192.168.3.10 icmp_seq=3 Destination Host Unreachable --- 192.168.10.20 ping statistics ---
3 packets transmitted, 0 received, +3 errors, 100% packet loss, time 1999ms pipe 3
6、修改虛擬機2網卡IP,測試和虛擬機1的連通性
[root@host2 network-scripts]# ls ifcfg-eno16777728 ifdown-bnep ifdown-ipv6 ifdown-ppp ifdown-Team ifup ifup-eth ifup-isdn ifup-post ifup-sit ifup-tunnel network-functions ifcfg-lo ifdown-eth ifdown-isdn ifdown-routes ifdown-TeamPort ifup-aliases ifup-ippp ifup-plip ifup-ppp ifup-Team ifup-wireless network-functions-ipv6 ifdown ifdown-ippp ifdown-post ifdown-sit ifdown-tunnel ifup-bnep ifup-ipv6 ifup-plusb ifup-routes ifup-TeamPort init.ipv6-global [root@host2 network-scripts]# vim ifcfg-eno16777728 ## 編輯虛擬機2的網卡配置文件 TYPE=Ethernet BOOTPROTO=static NAME=eno16777728 ONBOOT=yes IPADDR=192.168.3.20 NETMASK=255.255.255.0 GATEWAY=192.168.3.1 DNS1=192.168.3.1 [root@host2 network-scripts]# ifconfig ## 查看重啟網卡前網卡信息 eno16777728: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.10.20 netmask 255.255.255.0 broadcast 192.168.10.255 inet6 fe80::20c:29ff:feaa:2b29 prefixlen 64 scopeid 0x20<link> ether 00:0c:29:aa:2b:29 txqueuelen 1000 (Ethernet) RX packets 331 bytes 23607 (23.0 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 135 bytes 10795 (10.5 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10<host> loop txqueuelen 0 (Local Loopback) RX packets 997 bytes 79808 (77.9 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 997 bytes 79808 (77.9 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 [root@host2 network-scripts]# systemctl restart network ## 重啟網卡 [root@host2 network-scripts]# ifconfig ## 查看重啟網卡后網卡信息,IP信息發生變化 eno16777728: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.3.20 netmask 255.255.255.0 broadcast 192.168.3.255 inet6 fe80::20c:29ff:feaa:2b29 prefixlen 64 scopeid 0x20<link> ether 00:0c:29:aa:2b:29 txqueuelen 1000 (Ethernet) RX packets 331 bytes 23607 (23.0 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 159 bytes 13947 (13.6 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10<host> loop txqueuelen 0 (Local Loopback) RX packets 1005 bytes 80680 (78.7 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 1005 bytes 80680 (78.7 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 [root@host2 network-scripts]# ping -c 3 192.168.3.20 ## 測試本地主機聯通性,聯通 PING 192.168.3.20 (192.168.3.20) 56(84) bytes of data. 64 bytes from 192.168.3.20: icmp_seq=1 ttl=64 time=0.032 ms 64 bytes from 192.168.3.20: icmp_seq=2 ttl=64 time=0.041 ms 64 bytes from 192.168.3.20: icmp_seq=3 ttl=64 time=0.045 ms --- 192.168.3.20 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2000ms rtt min/avg/max/mdev = 0.032/0.039/0.045/0.007 ms [root@host2 network-scripts]# ping -c 3 192.168.3.10 ## 此時,測試和虛擬機1的聯通性,聯通 PING 192.168.3.10 (192.168.3.10) 56(84) bytes of data. 64 bytes from 192.168.3.10: icmp_seq=1 ttl=64 time=0.385 ms 64 bytes from 192.168.3.10: icmp_seq=2 ttl=64 time=0.247 ms 64 bytes from 192.168.3.10: icmp_seq=3 ttl=64 time=0.188 ms --- 192.168.3.10 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2001ms rtt min/avg/max/mdev = 0.188/0.273/0.385/0.083 ms
此時,再用虛擬機1測試和虛擬機2的聯通性:
[root@host1 network-scripts]# ifconfig | head -n 3 ## 查看虛擬機1的IP eno16777728: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.3.10 netmask 255.255.255.0 broadcast 192.168.3.255 inet6 fe80::20c:29ff:fee4:f7b9 prefixlen 64 scopeid 0x20<link> [root@host1 network-scripts]# ping -c 3 192.168.3.20 ## 測試和虛擬機2的聯通性,聯通 PING 192.168.3.20 (192.168.3.20) 56(84) bytes of data. 64 bytes from 192.168.3.20: icmp_seq=1 ttl=64 time=0.230 ms 64 bytes from 192.168.3.20: icmp_seq=2 ttl=64 time=0.244 ms 64 bytes from 192.168.3.20: icmp_seq=3 ttl=64 time=0.214 ms --- 192.168.3.20 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2001ms rtt min/avg/max/mdev = 0.214/0.229/0.244/0.017 ms
說明:192.169.10.10和192.168.10.20可以聯通;192.168.3.10和192.168.3.20可以聯通;交叉時不連通。
7、測試和外網的聯通性
以上的測試中兩台虛擬機均為僅主機模式:
[root@host1 network-scripts]# ping -c 3 www.baidu.com ## 測試虛擬機1和外網的聯通性,不聯通 ping: unknown host www.baidu.com [root@host2 network-scripts]# ping -c 3 www.baidu.com ## 測試虛擬機2和外網的聯通性,不聯通 ping: unknown host www.baidu.com