Linux下使用指定網卡進行ping操作
1 # ping --help 2 ping: invalid option -- '-' 3 Usage: ping [-aAbBdDfhLnOqrRUvV64] [-c count] [-i interval] [-I interface] 4 [-m mark] [-M pmtudisc_option] [-l preload] [-p pattern] [-Q tos] 5 [-s packetsize] [-S sndbuf] [-t ttl] [-T timestamp_option] 6 [-w deadline] [-W timeout] [hop1 ...] destination 7 Usage: ping -6 [-aAbBdDfhLnOqrRUvV] [-c count] [-i interval] [-I interface] 8 [-l preload] [-m mark] [-M pmtudisc_option] 9 [-N nodeinfo_option] [-p pattern] [-Q tclass] [-s packetsize]10 [-S sndbuf] [-t ttl] [-T timestamp_option] [-w deadline]11 [-W timeout] destination
1 # man ping2 -I interface3 interface is either an address, or an interface name. If interface is an4 address, it sets source address to specified interface address. If interface in5 an interface name, it sets source interface to specified interface. For IPv6,6 when doing ping to a link-local scope address, link specification (by the7 '%'-notation in destination, or by this option) is required.
# . PING . (.) ( bytes from .: icmp_seq= ttl= = bytes from .: icmp_seq= ttl= =
1 # ping -I 192.168.187.10 172.16.0.112 PING 172.16.0.11 (172.16.0.11) from 192.168.187.10 : 56(84) bytes of data.3 From 192.168.187.10 icmp_seq=1 Destination Host Unreachable
1 # ping -I ens33 192.168.187.112 PING 192.168.187.11 (192.168.187.11) from 192.168.187.10 ens33: 56(84) bytes of data.3 64 bytes from 192.168.187.11: icmp_seq=1 ttl=64 time=18.1 ms4 64 bytes from 192.168.187.11: icmp_seq=2 ttl=64 time=4.11 ms
1 # ping -I 本機指定網卡名或網卡的IP地址 目標地址
*博客內容為網友個人發布,僅代表博主個人觀點,如有侵權請聯系工作人員刪除。