Routing
捲曲正在工作,但在指定介面時 ping 不起作用
在 virtualBox 中的 Fedora 25 上執行,我連接了 2 個具有 NAT 配置的網卡。
我可以看到介面和路由都是系統自動創建的:
$ 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 ê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 êtes ici</pre></strong></body></html>
但是當我想通過這兩個介面 ping 通時,只有一個在工作:
$ 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中的*arp通量有關。*嘗試
sysctl -w net.ipv4.conf.default.rp_filter = 2
在虛擬機中。然後清空你主機上的arp記憶體,也可能是你要等幾秒。如果有幫助,請添加
net.ipv4.conf.default.rp_filter = 2
使其
/etc/sysctl.d/99-my.conf
重新啟動持久。重新啟動後,不必將其應用於每個單獨的介面。