Ping

為什麼 ping 工作時“ping -vrf”不起作用?

  • June 19, 2013
0:root@SERVER:/root # ping IPADDRESS
PING IPADDRESS (IPADDRESS): 56 data bytes
64 bytes from IPADDRESS: icmp_seq=0 ttl=254 time=0 ms
64 bytes from IPADDRESS: icmp_seq=1 ttl=254 time=0 ms
64 bytes from IPADDRESS: icmp_seq=2 ttl=254 time=0 ms
^C
--- IPADDRESS ping statistics ---
3 packets transmitted, 3 packets received, 0% packet loss
round-trip min/avg/max = 0/0/0 ms
0:root@SERVER:/root # ping -vrf IPADDRESS
PING IPADDRESS (IPADDRESS): 56 data bytes
ping: sendto: Network is unreachable
ping: wrote IPADDRESS 64 chars, ret=-1
.ping: sendto: Network is unreachable
ping: wrote IPADDRESS 64 chars, ret=-1
.ping: sendto: Network is unreachable
ping: wrote IPADDRESS 64 chars, ret=-1
.ping: sendto: Network is unreachable
ping: wrote IPADDRESS 64 chars, ret=-1
.ping: sendto: Network is unreachable
ping: wrote IPADDRESS 64 chars, ret=-1
.ping: sendto: Network is unreachable
ping: wrote IPADDRESS 64 chars, ret=-1
.ping: sendto: Network is unreachable

問題:如果我可以 ping IPADDRESS 那麼為什麼我不能“ping -vrf”IPADDRESS?

看起來是因為-r選項。來自男人:

  -r     Bypass the normal routing tables and send directly to a host 
         on an attached interface.  If the host is not on a directly-
         attached network, an error is returned.  This option can be 
         used to ping a local host through an interface that has no 
         route through it provided the option -I is also used.

您需要將主機直接連接到您的網路,否則它將像您的問題一樣失敗。

引用自:https://unix.stackexchange.com/questions/79938