当指定一个接口时,Curl正在工作,但ping不工作

在VirtualBox上运行Fedora 25,我连接了2个带有NATconfiguration的网卡。

我可以看到接口和路由都是由系统自动创build的:

$ ip route default via 10.0.2.2 dev enp0s3 proto static metric 100 default via 10.0.3.2 dev enp0s8 proto static metric 101 10.0.2.0/24 dev enp0s3 proto kernel scope link src 10.0.2.15 metric 100 10.0.3.0/24 dev enp0s8 proto kernel scope link src 10.0.3.15 metric 100 192.168.122.0/24 dev virbr0 proto kernel scope link src 192.168.122.1 linkdown 

现在我想通过两个界面进行curl请求:

 $ curl --interface enp0s3 www.perdu.com <html><head><title>Vous Etes Perdu ?</title></head><body><h1>Perdu sur l'Internet ?</h1><h2>Pas de panique, on va vous aider</h2><strong><pre> * <----- vous &ecirc;tes ici</pre></strong></body></html> $ curl --interface enp0s8 www.perdu.com <html><head><title>Vous Etes Perdu ?</title></head><body><h1>Perdu sur l'Internet ?</h1><h2>Pas de panique, on va vous aider</h2><strong><pre> * <----- vous &ecirc;tes ici</pre></strong></body></html> 

但是当我想通过这两个接口,只有一个工作:

 $ ping -Ienp0s3 8.8.8.8 PING 8.8.8.8 (8.8.8.8) from 10.0.2.15 enp0s3: 56(84) bytes of data. 64 bytes from 8.8.8.8: icmp_seq=1 ttl=56 time=4.87 ms 64 bytes from 8.8.8.8: icmp_seq=2 ttl=56 time=5.49 ms ^C --- 8.8.8.8 ping statistics --- 2 packets transmitted, 2 received, 0% packet loss, time 1000ms rtt min/avg/max/mdev = 4.874/5.182/5.490/0.308 ms $ ping -Ienp0s8 8.8.8.8 PING 8.8.8.8 (8.8.8.8) from 10.0.3.15 enp0s8: 56(84) bytes of data. ^C --- 8.8.8.8 ping statistics --- 3 packets transmitted, 0 received, 100% packet loss, time 2079ms 

我的问题是我怎样才能通过两个接口的ping工作?

谢谢

这可能与linux中的arpstream量有关。 尝试

 sysctl -w net.ipv4.conf.default.rp_filter = 2 

在VM中。 然后清除主机上的arpcaching,也可能需要等待几秒钟。 如果有帮助,添加

 net.ipv4.conf.default.rp_filter = 2 

/etc/sysctl.d/99-my.conf使其重新启动持久性。 重新启动后,不必将其应用于每个单一接口。