Skip to main content
62 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 ...
ilkkachu's user avatar
  • 142k
61 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 ...
Stephen Kitt's user avatar
60 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/...
Patrick Mevzek's user avatar
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+...
Stephen Kitt's user avatar
52 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 ...
Stephen Kitt's user avatar
50 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, ...
Kamil Maciorowski's user avatar
34 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 ...
Kiwy's user avatar
  • 9,794
34 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 ...
slm's user avatar
  • 373k
29 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 ...
ks1322's user avatar
  • 1,656
27 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....
GAD3R's user avatar
  • 67.7k
24 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 ...
Dr. Alexander's user avatar
24 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: ...
Stephen Harris's user avatar
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 ...
meuh's user avatar
  • 52.3k
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 ...
Kusalananda's user avatar
  • 341k
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 \ && ...
Stephen Kitt's 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 ...
thrig's user avatar
  • 35.2k
18 votes
Accepted

No internet connection in chroot environment (customizing iso)

You have internet connection, as evidenced by the ping to 8.8.8.8. You just don't have DNS name resolution. See the file /etc/resolv.conf in your root file system and copy it to the chroot ...
RalfFriedl's user avatar
  • 9,091
17 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
Diaa Sami's user avatar
  • 505
15 votes

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

inetutils-ping is the portable GNU implementation, which is used on non-Linux Debian systems (such as Debian GNU/kFreeBSD). iputils-ping is Linux only, but does have more features. If you are using ...
sebasth's user avatar
  • 15.2k
14 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
Outurnate's user avatar
  • 1,219
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 ...
Arkadiusz Drabczyk's user avatar
12 votes

The difference between 'ping' and 'wget' in relation to hostname resolution

Answering to: What is the difference between 'ping' and 'wget' in relation to hostname resolution Ping expects either an IP address or a hostname as parameter. You are giving it a full URL which ...
jlliagre's user avatar
  • 61.8k
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 ...
terdon's user avatar
  • 245k
11 votes

Check ping statistics without stopping

Linux (Tested on Ubuntu 20.04) Send the SIGQUIT signal. Example output: 64 bytes from localhost (127.0.0.1): icmp_seq=138 ttl=64 time=0.021 ms 64 bytes from localhost (127.0.0.1): icmp_seq=139 ttl=...
Starson Hochschild's user avatar
11 votes

What Linux process is responsible for responding to pings?

The kernel itself (not any user process) is responsible to sending ICMP echo reply messages in response to ICMP echo request messages. So, if a host stops responding to pings, it is usually due to ...
Matija Nalis's user avatar
  • 3,176
10 votes
Accepted

Shell command/script to see if a host is alive?

Ping is great to get a quick response about whether the host is connected to the network, but it often won't tell you whether the host is alive or not, or whether it's still operating as expected. ...
Malvineous's user avatar
  • 7,073
10 votes

Check ping statistics without stopping

On Mac it's Ctrl+T. Ctrl+\ does the same as Ctrl+C, as it stops the ping after showing the stats.
Stefan Rogin's user avatar
10 votes

From 192.168.0.146 icmp_seq=1 Destination Host Unreachable

[edit] My other devices can ping my PC, but my PC can not ping any other device including the router to which my PC is attached directly. I would check for a conflicting IP address on another device. ...
sourcejedi's user avatar
  • 51.4k
10 votes
Accepted

ping: show only results

Another awk variation: ping -qc1 google.com 2>&1 | awk -F'/' 'END{ print (/^rtt/? "OK "$5" ms":"FAIL") }' -F'/' - treat slash / as field separator Example output: OK 47.090 ms
RomanPerekhrest's user avatar

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