Hot answers tagged

61 votes
Accepted

What is the difference between ping localhost and ping 127.0.0.1?

The ping command shows the address it resolved the name to. In this case it resolved to the IPv6 localhost address, ::1. On the other hand, 127.0.0.1 is an IPv4 address, so it explicitly makes ping ...
user avatar
  • 119k
60 votes

Why does 'ping' not output a summary when redirecting output?

ping shows the summary when it is killed with SIGINT, e.g. as a result of CtrlC, or when it has transmitted the requested number of packets (the -c option). CtrlC causes SIGINT to be sent to all ...
user avatar
58 votes
Accepted

What Linux process is responsible for responding to pings?

The kernel network stack is handling ICMP messages, which are those sent by the ping command. If you do not get replies, besides network problems or filtering, and host based filtering/rate-limiting/...
user avatar
54 votes

traceroute gives only stars + how to fix

I found that traceroute -I gave me more complete results. -I, --icmp Use ICMP ECHO for probes
user avatar
  • 857
52 votes
Accepted

"/usr/bin/ping" is shown as yellow-on-red in the default Fedora bash color scheme -- what does it mean?

This indicates that ping has extra capabilities: $ getcap /usr/bin/ping /usr/bin/ping = cap_net_raw+ep or even (on Fedora up to 30): $ getcap /usr/bin/ping /usr/bin/ping = cap_net_admin,cap_net_raw+...
user avatar
49 votes
Accepted

Why is there output of ping after it has been terminated?

Ctrl+C makes the terminal send SIGINT to the foreground process group. A process that receives SIGINT can do anything, it can even ignore the signal. A common reaction to SIGINT is to exit gracefully, ...
user avatar
41 votes
Accepted

Check ping statistics without stopping

From the ping manpage (emphasis mine): When the specified number of packets have been sent (and received) or if the program is terminated with a SIGINT, a brief summary is displayed. Shorter ...
user avatar
37 votes
Accepted

What are the differences between iputils-ping and inetutils-ping?

iputils’s ping supports quite a few more features than inetutils’ ping, e.g. IPv6 (which inetutils implements in a separate binary, ping6), broadcast pings, quality of service bits... The linked ...
user avatar
33 votes

What is the difference between ping localhost and ping 127.0.0.1?

127.0.0.1: 127.0.0.1 is the default loopback of most system. A loopback address is an address used by the system to validate the network stack of the OS. The loopback address for IPv4 could take any ...
user avatar
  • 9,020
33 votes
Accepted

How can I ping multiple IP addresses at the same time?

If you look into the NMAP project you'll find that it includes additional tools on top of just nmap. One of these tools is nping, which includes the following ability: Nping has a very flexible and ...
user avatar
  • 348k
28 votes
Accepted

Why does 'ping' not output a summary when redirecting output?

Turns out that there is an option in tee to ignore interrupt signals which are sent when CTRL+C is pressed. From man tee: -i, --ignore-interrupts ignore interrupt signals When whole ...
user avatar
  • 1,586
27 votes
Accepted

ping to send 0 bytes

A ping cannot be 0 bytes on Linux, Windows or any other platform that claims to be able to send pings. At the very least the packet must contain an IP header and a non-malformed no-trick-playing ping ...
user avatar
  • 14.3k
23 votes

Check ping statistics without stopping

There is one more easy way to get the ping statistics durning it's execution: Just press Ctrl + | (vertical slash or it's also called pipe line) I do personally use it very often, try it: 64 bytes ...
user avatar
23 votes
Accepted

Why does ping need setuid permission?

In order for ping to work it needs to be able to create a raw network socket. This is typically a privileged action. On a modern Linux system this can be granted with "capabilities" eg on CentOS 7: ...
user avatar
22 votes
Accepted

How to Disable Ping Response (ICMP echo) in Linux all the time?

How would I be able to leave echo off even when I am rebooting my laptop? You can use one of the following three ways (as root): Edit /etc/sysctl.conf Add the following line to your /etc/sysctl....
user avatar
  • 58.7k
22 votes

How can I ping multiple IP addresses at the same time?

fping is in a Fedora package of the same name, and allows for many hosts, or a set of ip addressses. $ fping -a -A -c 1 hosta hostb 192.168.0.20 : xmt/rcv/%loss = 1/1/0%, min/avg/max = 0.64/0.64/0.64 ...
user avatar
  • 45.6k
20 votes
Accepted

Trying to write a shell script that keeps testing a server remotely, but it keeps falling in else statement when I logout

When GNU grep tries to write its result, it will fail with a non-zero exit status, because it has nowhere to write the output, because the SSH connection is gone. This means that the if statement is ...
user avatar
  • 276k
18 votes
Accepted

Why is the output on this ping outside the subshell?

The warning is sent to ping’s standard error, which isn’t captured. If you want to ignore it, redirect it to /dev/null explicitly: connected=$(ping -I $1 -qc 1 8.8.8.8 2>/dev/null \ && ...
user avatar
18 votes

Why can I access a server by a partial IP address?

That is an allowed form according to the inet_aton(3) function docs: DESCRIPTION inet_aton() converts the Internet host address cp from the IPv4 num‐ bers-and-dots notation into ...
user avatar
  • 31.6k
16 votes
Accepted

Bash ping script file for checking host availability

I would use this, a simple one-liner: while ! ping -c1 HOSTNAME &>/dev/null; do echo "Ping Fail - `date`"; done ; echo "Host Found - `date`" ; /root/scripts/test1.sh Replace HOSTNAME with the ...
user avatar
  • 5,127
14 votes

Can one ping a NIC by MAC

You cannot ping a normal NIC because NIC alone does not send any replies. Only a running computer is able send replies Normal network interface cards do not send any replies by themselves. They ...
user avatar
13 votes

recvmsg returns 'EAGAIN (Resource temporarily unavailable)'

When you read from a socket (or pipe or other asynchronous source), you can choose what happens if there's no data immediately available. Either you can have the read wait until some data arrives (...
user avatar
  • 15.6k
13 votes

network: destination host unreachable

try DHCP for the network interface sudo /etc/init.d/networking restart && sudo dhclient
user avatar
13 votes

What Linux process is responsible for responding to pings?

There is no userland process responsible for responding to pings. Ping is just a utility to send ICMP echo packets. These are received and process by the kernel's networking stack
user avatar
  • 1,149
13 votes

How can I ping multiple IP addresses at the same time?

I would suggest using GNU Parallel parallel -u ping ::: host1 host2 host3 output will be interleaved
user avatar
  • 455
13 votes
Accepted

Need Improvement on Script Which Continuously Tests Website

You don't need ; at the end of each line, this is not C. You don't need: cp /dev/null pingop.txt because the very next line in the script ping -i 1 -c 1 -W 1 google.com > pingop.txt will ...
user avatar
12 votes

Continuous ping loop in script

Do you mean something as simple as this: while :; do ping -c 1 -w 3 8.8.8.8; echo $? > /tmp/ping.status sleep 1 done That will write the exit status of ping to /tmp/ping.status once a ...
user avatar
  • 219k
11 votes
Accepted

Ping doesn't work, but I can browse through the internet

Outgoing ICMP (ping) is probably blocked by your firewall or gateway. That you are able to browse the Internet does not need ICMP (ping) to be working. You also might have a proxy configured which ...
user avatar
  • 12k
11 votes

ping to send 0 bytes

What's your layer 2 transmission medium? Ethernet? There's no way to have an ethernet frame shorter than 64 bytes, regardless of what it carries. So, even if you could send a ICMP ping with 0 ...
user avatar
  • 1,495

Only top scored, non community-wiki answers of a minimum length are eligible