The linuxarping command learns how to use the arping command to send ARPREQUEST packets to neighboring hosts. The 1arping command can be used to test the connectivity between hosts in the Lan and the connection to the Internet, sh-pingwwwgooglecomPINGwwwg linux arping command learns how to use the arping command to send arp request packets to neighboring hosts. 1. the arping command can be used to test the connectivity between hosts in the LAN. it cannot be used to test whether the host can communicate with the internet. sh-# ping www. google. comPING www.google.com (74.125.239.147) 56 (84) bytes of data.64 bytes from nuq05s02-in-f19.1e100.net (bytes): icmp_req = 1 ttl = 53 time = 267 ms64 bytes from nuq05s02-in-f19.1e100.net (74.125.239.147 ): icmp_req = 2 ttl = 53 time = 269 ms64 bytes from nuq05s02-in-f19.1e100.net (74.125.239.147): icmp_req = 3 ttl = 53 time = 289 ms ^ C --- www .Google.com ping statistics --- 4 packets transmitted, 3 bytes ed, 25% packet loss, time 3011 msrtt min/avg/max/mdev = 267.321/275.337/289.108/9.790 MS sh-# arping-I eth0 www.google.com-w 5 ARPING 74.125.239.147 from 192.168.0.153 eth0Sent 6 probes (6 broadcast (s )) received 0 response (s) sh-# arping-I eth0 192.168.0.151-w 5 ARPING 192.168.0.151 from 192.168.0.153 eth0Unicast reply from 192.168.0.151 [78: 52: 1A: 4D: D0: A5] 56.882 msUnicast reply from 192.168.0.151 [78: 52: 1A: 4D: D0: A5] 280.078 msUnicast reply from 192.168.0.151 [78: 52: 1A: 4D: D0: A5] 92.872 msUnicast reply from 192.168.0.151 [78: 52: 1A: 4D: D0: A5] 116.720 msUnicast reply from 192.168.0.151 [78: 52: 1A: 4D: D0: A5] 129.921 msUnicast reply from 192.168.0.151 [78: 52: 1A: 4D: D0: A5] 48.195 msSent 6 probes (1 broadcast (s )) received 6 response (s) 2. arping To test whether a specific IP address in the Lan is occupied. We know that IP address conflicts in the LAN may cause various strange network problems, so the arping command is very useful when you manually set the IP address. You can use the arping command to test the IP address before setting the IP address. Use the return code of the arping command to confirm the execution result: if the returned result is 1, the IP address already exists in the LAN. if the returned result is 0, this indicates that no one in the Lan uses this IP address for the moment, so we can use it. Sh-# arping-I eth0-D 192.168.0.151-w 5 ARPING 192.168.0.151 from 0.0.0.0 eth0Unicast reply from 192.168.0.151 [78: 52: 1A: 4D: D0: a5] 141.406 msSent 1 probes (1 broadcast (s) Received 1 response (s) sh-# echo $? 1sh-# arping-I eth0-D 192.168.0.152-w 5 ARPING 192.168.0.152 from 0.0.0.0 eth0Sent 6 probes (6 broadcast (s) Received 0 response (s) sh-# echo $? 0sh-# Question: If your C application needs to check whether the IP address is available to determine how the user interface is displayed, how can this problem be solved? This requires the use of the library function system function provided by linux. # Include If (0 = system ("arping-I eth0-D 192.168.10.123-w 5") {printf ("\ nip not exist, can use this ip \ n ");} else {printf ("\ nip exist, can not use this ip \ n ");}
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service