当我尝试ping我的CentOS 7 vm';用户自己的接口

当我尝试ping我的CentOS 7 vm';用户自己的接口,centos,ping,centos7,Centos,Ping,Centos7,我已经使用virtualbox构建了CentOS 7.3虚拟机。此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.

我已经使用virtualbox构建了CentOS 7.3虚拟机。此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命令中指定接口名称时,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虚拟机上也可以正常工作:

[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
[root@localhost~]#ip地址显示enp0s3
2:enp0s3:mtu 1500 qdisc pfifo_快速状态升级qlen 1000
链接/以太08:00:27:12:a3:c1 brd ff:ff:ff:ff:ff:ff
inet 10.0.2.15/24 brd 10.0.2.255范围全局动态enp0s3
有效\u lft 86226秒优先\u lft 86226秒
inet6 fe80::a00:27ff:fe12:a3c1/64范围链路
永远有效\u lft首选\u lft永远有效
[root@localhost~]#平-c3 10.0.2.15
PING 10.0.2.15(10.0.2.15)56(84)字节的数据。
10.0.2.15中的64字节:icmp_seq=1 ttl=64时间=0.021毫秒
10.0.2.15中的64字节:icmp_seq=2 ttl=64时间=0.031毫秒
10.0.2.15中的64字节:icmp_seq=3 ttl=64时间=0.032毫秒
---10.0.2.15平统计---
传输3个数据包,接收3个,0%数据包丢失,时间2000ms
rtt最小值/平均值/最大值/mdev=0.021/0.028/0.032/0.005 ms
[root@localhost~]#ping-c3-I enp0s3 10.0.2.15
从10.0.2.15 enp0s3 PING 10.0.2.15(10.0.2.15):56(84)字节的数据。
10.0.2.15中的64字节:icmp_seq=1 ttl=64时间=0.026毫秒
10.0.2.15中的64字节:icmp_seq=2 ttl=64时间=0.031毫秒
10.0.2.15中的64字节:icmp_seq=3 ttl=64时间=0.030毫秒
---10.0.2.15平统计---
传输3个数据包,接收3个,0%数据包丢失,时间1999ms
rtt最小值/平均值/最大值/mdev=0.026/0.029/0.031/0.002毫秒

有人知道为什么这在CentOS 7.2中有效,而在CentOS 7.3中无效吗?

在超级用户或Linux SE上可能会更幸运。一般来说,Linux讨厌你就像Stack Overflow讨厌问题一样。谢谢@DanWhaley,我来试试。
[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