当我尝试ping我的CentOS 7虚拟机自己的界面时,ping命令失败

时间:2017-07-24 21:46:00

标签: centos ping centos7

我已经构建了一个CentOS 7.3 vmusing virtualbox。此vm具有以下接口:

[root@localhost ~]# ip addr show enp0s3
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 08:00:27:fa:df:f8 brd ff:ff:ff:ff:ff:ff
    inet 10.0.2.15/24 brd 10.0.2.255 scope global dynamic enp0s3
       valid_lft 86063sec preferred_lft 86063sec
    inet6 fe80::68e5:f976:c846:7881/64 scope link
       valid_lft forever preferred_lft forever

当我尝试ping这个时,我得到:

[root@localhost ~]# ping -c 3 10.0.2.15
PING 10.0.2.15 (10.0.2.15) 56(84) bytes of data.
64 bytes from 10.0.2.15: icmp_seq=1 ttl=64 time=0.027 ms
64 bytes from 10.0.2.15: icmp_seq=2 ttl=64 time=0.034 ms
64 bytes from 10.0.2.15: icmp_seq=3 ttl=64 time=0.034 ms

--- 10.0.2.15 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2002ms
rtt min/avg/max/mdev = 0.027/0.031/0.034/0.007 ms

但是,当我在ping命令中指定接口名称时,ping命令失败:

[root@localhost ~]# ping -c 3 -I enp0s3 10.0.2.15
PING 10.0.2.15 (10.0.2.15) from 10.0.2.15 enp0s3: 56(84) bytes of data.

--- 10.0.2.15 ping statistics ---
3 packets transmitted, 0 received, 100% packet loss, time 2001ms

我注意到的另一件事是这个问题似乎特定于CentOS 7.3。相同的命令在CentOS 7.2 vm上运行良好:

[root@localhost ~]# ip addr show enp0s3
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 08:00:27:12:a3:c1 brd ff:ff:ff:ff:ff:ff
    inet 10.0.2.15/24 brd 10.0.2.255 scope global dynamic enp0s3
       valid_lft 86226sec preferred_lft 86226sec
    inet6 fe80::a00:27ff:fe12:a3c1/64 scope link
       valid_lft forever preferred_lft forever


[root@localhost ~]# ping -c 3 10.0.2.15
PING 10.0.2.15 (10.0.2.15) 56(84) bytes of data.
64 bytes from 10.0.2.15: icmp_seq=1 ttl=64 time=0.021 ms
64 bytes from 10.0.2.15: icmp_seq=2 ttl=64 time=0.031 ms
64 bytes from 10.0.2.15: icmp_seq=3 ttl=64 time=0.032 ms

--- 10.0.2.15 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2000ms
rtt min/avg/max/mdev = 0.021/0.028/0.032/0.005 ms


[root@localhost ~]# ping -c 3 -I enp0s3 10.0.2.15
PING 10.0.2.15 (10.0.2.15) from 10.0.2.15 enp0s3: 56(84) bytes of data.
64 bytes from 10.0.2.15: icmp_seq=1 ttl=64 time=0.026 ms
64 bytes from 10.0.2.15: icmp_seq=2 ttl=64 time=0.031 ms
64 bytes from 10.0.2.15: icmp_seq=3 ttl=64 time=0.030 ms

--- 10.0.2.15 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 1999ms
rtt min/avg/max/mdev = 0.026/0.029/0.031/0.002 ms

有没有人知道为什么这在CentOS 7.2中有效,而不是CentOS 7.3?

0 个答案:

没有答案