Ping
Ping allows you to see if a computer is reachable via the network and to measure the network latency. You stop it with CTRL_C.
Example:
# ping 192.168.0.1 PING 192.168.0.1 (192.168.0.1) 56(84) bytes of data. 64 bytes from 192.168.0.1: icmp_seq=1 ttl=64 time=1.19 ms 64 bytes from 192.168.0.1: icmp_seq=2 ttl=64 time=0.417 ms 64 bytes from 192.168.0.1: icmp_seq=3 ttl=64 time=0.382 ms
In this example we have a latency of below 1 milisecond and 192.168.0.1 is up
Broadcast ping
A broadcast ping can be described as a request "Anybody who hears this, please respond back". The problem is that you can configure computers to ignore these requests.
To tell your computer to answer on broadcast pings, open a console and issue:
echo "0" >/proc/sys/net/ipv4/icmp_echo_ignore_broadcasts
To verify if your computer is set to answer on broadcast pings, issue:
sysctl net.ipv4.icmp_echo_ignore_broadcasts
In this case, the response
net.ipv4.icmp_echo_ignore_broadcasts = 0
means it is set to answer broadcast pings.
To perform a broadcast ping,
- Find out the broadcast address of the network where you want to broadcast
ifconfig eth1 eth1 Link encap:Ethernet HWaddr 00:1C:F0:BB:06:C8 inet addr:192.168.0.5 Bcast:192.168.0.255 Mask:255.255.255.0 inet6 addr: fe80::21c:f0ff:febb:6c8/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:315742 errors:0 dropped:0 overruns:0 frame:0 TX packets:297176 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:195071533 (186.0 Mb) TX bytes:41401952 (39.4 Mb) Interrupt:21 Base address:0x4000
- ping the broadcast IP
# ping -b 192.168.0.255 WARNING: pinging broadcast address PING 192.168.0.255 (192.168.0.255) 56(84) bytes of data. 64 bytes from 192.168.0.5: icmp_seq=1 ttl=64 time=0.039 ms
Broadcast ping does not work?
try nmap like this:
nmap 192.168.0.0/24
Ping does not work
If you change a host's IP in /etc/hosts and this change is not reflected instantly by ping, restart the name service cache daemon:
/etc/init.d/nscd restart
and check /etc/nsswitch.conf