Skip to content

Both.org

News, Opinion, Tutorials, and Community for Linux Users and SysAdmins

Primary Menu
  • About Us
  • Computers 101
    • Hardware 101
    • Operating Systems 101
  • End of 10 Events
    • Wake Forest, NC, — 2025-09-20
  • Linux
    • Why I use Linux
    • The real reason we use Linux
  • My Linux Books
    • systemd for Linux SysAdmins
    • Using and Administering Linux – Zero to SysAdmin: 2nd Edition
    • The Linux Philosophy for SysAdmins
    • Linux for Small Business Owners
    • Errata
      • Errata for The Linux Philosophy for SysAdmins
      • Errata for Using and Administering Linux — 1st Edition
      • Errata for Using and Administering Linux — 2nd Edition
  • Open Source Resources
    • What is Open Source?
    • What is Linux?
    • What is Open Source Software?
    • The Open Source Way
  • Write for us
    • Submission and Style guide
    • Advertising statement
  • Downloads
  • Home
  • Diagnose connectivity issues with the Linux ping command
  • Linux
  • Networking

Diagnose connectivity issues with the Linux ping command

Networking is what makes the Internet, the cloud, file shares, media streaming, remote administration, printing, and much more possible. When something goes wrong, it can sometimes be challenging to diagnose. One of the most fundamental diagnostic tools for networked connectivity is the ping command.
Don Watkins February 20, 2024 5 minutes read
connections_wires_sysadmin_cable

Networked computers are so common these days that most of us take it for granted that a computer on one side of a room can contact one on the other side of the room, much less the other side of the world. When it works as designed, networking is what makes the Internet, the cloud, file shares, media streaming, remote administration, printing, and much more possible. When something goes wrong, it can sometimes be challenging to diagnose. One of the most fundamental diagnostic tools for networked connectivity is the ping command.

The basic ping

You can ping it when you can’t reach a computer on your local network or a server on the Internet. A ping sends an Internet Control Message Protocol (ICMP) packet to a destination IP address. ICMP is, by design, a rudimentary format used mostly for diagnostics: It’s essentially a call-and-response signal.

But there’s an order to troubleshoot, and it starts as close to home as possible. When in doubt, first ping your own computer to ensure you’re running a networking stack. The computer you’re operating is also called your localhost, and it has a special IP address assigned for speaking to itself: 12.0.0.1.

The ping command understands the localhost hostname, its IP address, and a shortcut of just 0.

You can control how many signals you send with the -c (as in count) option.

$ ping 0 -c1
PING 0 (127.0.0.1) 56(84) bytes of data.
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.069 ms

--- 0 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.069/0.069/0.069/0.000 ms

After you’ve established that your local networking stack is up and running, you can ping your router. The address of a router usually starts with 192,168, or 10. The exact IP address depends on your router’s configuration.

When you don’t specify how many pings to send, you can stop ping from running with Ctrl+C.

$ ping 192.168.0.1 
PING 192.168.0.1 (192.168.0.1) 56(84) bytes of data.
From 192.168.0.100: icmp_seq=2 Redirect Host(New nexthop: 192.168.0.1)
From 192.168.0.100: icmp_seq=3 Redirect Host(New nexthop: 192.168.0.1)
From 192.168.0.100: icmp_seq=4 Redirect Host(New nexthop: 192.168.0.1)
From 192.168.0.100: icmp_seq=5 Redirect Host(New nexthop: 192.168.0.1)
^C

If you can reach your router, that means your wired or wireless connection is working. 

What about other hosts on my network? You can ping all kinds of devices. Not all are guaranteed to respond (some devices drop ICMP packets), but many do. For instance, I can ping my printer:

$ ping 192.168.0.4 

Pinging beyond your network

Beyond establishing that your network is working as expected, you can ping out into the broader world beyond your router. Again, not all servers are permitted to receive ICMP, much less respond to. However, some do, and a vital server to the working of the Internet is a nameserver.

Google’s DNS server is relatively easy to remember, and it does respond to pings:

$ ping -c 2 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=116 time=53.3 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=116 time=53.5 ms

--- 8.8.8.8 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1000ms
rtt min/avg/max/mdev = 53.304/53.424/53.544/0.120 ms

When a site has disappeared, you might be able to probe the worldwide DNS network to find out what its host server’s address is, and then ping that server. This at least tells you whether the host is down or whether it’s just a web server issue.

For example, say you’re trying unsuccessfully to reach example.com. First, find the IP address using the host command:

$ host example.com
example.com has address 93.184.216.34
example.com has IPv6 address 2606:2800:220:1:248:1893:25c8:1946
example.com mail is handled by 0 

And then ping the website’s host by IP:

$ ping 93.184.216.34 -c 1

Ping and IPv6

Ping works over IPv4 as well as IPv6. Using only one of them explicitly can be enforced by specifying -4 or -6. 

Packet size

You can change the size of the ICMP packets you’re sending with the -s option. The default packet size is 56, which translates into 64 ICMP data bytes when combined with the 8-byte header. This command sends 43 bytes:

$ ping -s 35 -c 5 8.8.8.8

You can print a timestamp before each ping report in your terminal with the -D option. This provides the UNIX epoch time, plus microseconds:

$ ping -D 8.8.8.8 
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
[1634013430.297468] 64 bytes from 8.8.8.8: icmp_seq=1 ttl=116 time=53.3 ms
[1634013431.298738] 64 bytes from 8.8.8.8: icmp_seq=2 ttl=116 time=53.1 ms

Ping time

You can change the time interval between pings using the -i option. This changes the ping interval to two seconds:

$ ping -i 2 

You can also stop pinging after some value of time (in seconds) with the -w option:

$ ping -w 6

Variants

There are many implementations of ping. The iputils package provides a ping command, Busybox has a ping command, and there’s one from BSD and others. There’s even a GUI for ping: Gping is available for Linux, macOS, and Windows. You can find more information gping on Github. 

Learn to ping

The ping command is simple, but it can be eyes and ears out on your network’s vast expanse. Next time you have connectivity issues, let ping be the first tool you turn to.

Tags: ping ping command

Post navigation

Previous: systemd — #8: Analyzing systemd calendar and timespans
Next: Generate QR codes with this open source tool

Related Stories

connections_wires_sysadmin_cable
  • Linux
  • Networking
  • Router

How to Make your Linux Box Into a Router

David Both April 29, 2026
f44-01-day-cropped
  • Fedora
  • Linux
  • Upgrades

Fedora 44 Released

David Both April 28, 2026
command_line_prompt
  • Command Line
  • Linux
  • Programming

Writing a replacement seq command

Jim Hall April 27, 2026

Random Quote

I do not fear computers. I fear the lack of them.

— Isaac Asimov

Why I’ve Never Used Windows

On February 12 I gave a presentation at the Triangle Linux Users Group (TriLUG) about why I use Linux and why I’ve never used Windows.

Here’s the link to the video: https://www.youtube.com/live/uCK_haOXPFM 

Why there’s no such thing as AI

Last October at All Things Open (ATO) I was interviewed by Jason Hibbits of We Love Open Source. It’s posted in the article “Why today’s AI isn’t intelligent (yet)“.

Technically We Write — Our Partner Site

Our partner site, Technically We Write, has published a number of articles from several contributors to Both.org. Check them out.

Technically We Write is a community of technical writers, technical editors, copyeditors, web content writers, and all other roles in technical communication.

Subscribe to Both.org

To comment on articles, you must have an account.

Send your desired user ID, first and last name, and an email address for login (this must be the same email address used to register) to subscribe@both.org with “Subscribe” as the subject line.

You’ll receive a confirmation of your subscription with your initial password as soon as we are able to process it.

Administration

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org

License and AI Statements

Both.org aims to publish everything under a Creative Commons Attribution ShareAlike license. Some items may be published under a different license. You are responsible to verify permissions before reusing content from this website.

The opinions expressed are those of the individual authors, not Both.org.

You may not use this content to train AI.

 

Advertising Statement

Both.org does not sell advertising on this website.


Advertising may keep most websites running—but at Both.org, we’re committed to keeping our corner of the web ad-free. Both.org does not sell advertising on the website. Nor do we offer sponsored articles at this time. We’ll update this page if our position on sponsorships changes.

We want to be open about how the website is funded. Both.org is supported entirely by David Both and a few other dedicated individuals.

 

 

Copyright © All rights reserved. | MoreNews by AF themes.