sodcalculator

10 Tech How-To

How to Ping Google in Linux (Terminal Guide)

Guide 10-47968 · Updated · Step by step

This guide shows you how to use the ping command in Linux to test your connection to Google’s public DNS server (8.8.8.8) or to google.com. You’ll learn the basic syntax, how to interpret the output, and how to stop the ping after a set number of packets. No special software is needed—the ping utility comes pre-installed on virtually all Linux distributions.

What You’ll Need

  • A Linux system with a terminal (any distribution, e.g., Ubuntu, Debian, Fedora, Arch).
  • An active internet connection.
  • Basic familiarity with opening a terminal window (Ctrl+Alt+T on most desktops).

Step-by-Step

  1. Open a terminal. Press Ctrl+Alt+T (or search for “Terminal” in your app menu). You’ll see a command prompt where you can type commands.
  2. Run a basic ping to Google. Type the following and press Enter:
    ping google.com

    This will send continuous ICMP echo requests to Google’s servers. You’ll see output like:

    64 bytes from 142.250.190.78: icmp_seq=1 ttl=115 time=14.3 ms

    The ping will keep running until you stop it with Ctrl+C.

  3. Stop the ping. Press Ctrl+C. The terminal will show a summary with statistics: packets transmitted, received, loss percentage, and min/avg/max times.
  4. Ping a specific number of times. To avoid manually stopping, use the -c (count) option. For example, to send exactly 4 pings:
    ping -c 4 google.com

    The command will exit automatically after 4 packets.

  5. Ping by IP address. Sometimes you want to test raw connectivity without DNS resolution. Use Google’s public DNS IP:
    ping -c 4 8.8.8.8

    This bypasses DNS and tests the network path directly.

  6. Adjust the interval (optional). By default, ping waits 1 second between packets. To send pings faster, use -i with a fractional value (requires root for values below 0.2):
    ping -i 0.5 -c 4 google.com

    This sends 4 pings every half second.

  7. Set a timeout for each reply (optional). Use -W to specify how many seconds to wait for a response before considering it lost:
    ping -W 2 -c 4 google.com

    This waits 2 seconds per packet.

Common Mistakes

  • Forgetting to stop the ping. Without -c, ping runs indefinitely. Always use -c or remember to press Ctrl+C.
  • Using the wrong interface. If you have multiple network interfaces (e.g., VPN, Ethernet, Wi-Fi), ping might use the wrong one. Specify the interface with -I (capital i): ping -I eth0 google.com.
  • Typing ping www.google.com with a trailing slash. Some users add a slash out of habit from web browsers. The command expects just the hostname or IP.
  • Assuming high ping = slow internet. Ping measures latency (delay), not bandwidth. High ping affects real-time applications like gaming or VoIP, but not necessarily download speeds.

Tips

  • Use ping -c 4 google.com as a quick connectivity test. Four packets are enough to see if there’s a stable connection.
  • To see the IP address of google.com without pinging, use dig google.com or nslookup google.com.
  • If you’re troubleshooting intermittent issues, run a longer ping (e.g., ping -c 100 google.com) and look for packet loss.
  • For a more detailed network analysis, use traceroute to see the path packets take to Google.
  • On some systems, ping uses IPv6 by default. If you see an IPv6 address (like 2607:f8b0::) and want to force IPv4, use ping -4 google.com.

Troubleshooting

If your ping fails, here’s what to check:

  • No response at all (100% packet loss): Check your internet connection. Try pinging your router’s IP (often 192.168.1.1) to see if local network works. If that fails, your network is down. If it works, the problem is likely your ISP or DNS.
  • “ping: google.com: Temporary failure in name resolution”: This means DNS is not working. Try pinging 8.8.8.8 directly. If that works, your DNS settings are wrong. Check /etc/resolv.conf or your network manager’s DNS settings.
  • “Destination Host Unreachable”: This usually means there’s no route to the destination. Check your default gateway with ip route. If the gateway is missing, your network configuration is incorrect.
  • High latency or packet loss: This could be due to network congestion, Wi-Fi interference, or ISP issues. Try pinging a closer server (e.g., your router) to isolate the problem. If local pings are fine, the issue is external.
  • Permission denied when using -i 0.1: On Linux, sending pings faster than 0.2 seconds requires root privileges. Use sudo or increase the interval.
  • Ping works but websites don’t load: This suggests DNS or browser issues, not connectivity. Try using a different DNS server (e.g., 8.8.8.8) or clear your browser cache.

Frequently Asked Questions

Why does ping keep running?

By default, ping sends packets indefinitely until you stop it with Ctrl+C. To limit the number of packets, use the -c option (e.g., ping -c 5 google.com).

What does “time=14.3 ms” mean?

This is the round-trip time (RTT) in milliseconds—how long it takes for a packet to travel from your computer to Google and back. Lower is better. Under 20 ms is excellent for most connections; over 100 ms may cause noticeable lag in real-time applications.

What is a good ping result?

For a typical broadband connection, a ping to Google of under 50 ms is good, under 20 ms is excellent. Satellite connections can be 500+ ms. The key is consistency—watch for packet loss.

Can I ping using a domain name instead of an IP?

Yes, ping google.com works. The system resolves the domain to an IP first. If DNS is broken, you’ll get a resolution error, so pinging by IP (8.8.8.8) is a useful diagnostic.

Why does ping show an IPv6 address?

If your system has IPv6 enabled, ping may use it by default. To force IPv4, use ping -4 google.com. To force IPv6, use ping -6 google.com.

Is pinging Google safe?

Yes, it’s a standard diagnostic tool. Google’s DNS servers are designed to respond to ping. However, avoid sending excessive pings (like with -f flood) as it could be considered abusive and may get your IP blocked.

Related

General steps for current mainstream versions; menus can differ by device and version. See the disclaimer or report an error.

More in this bed

The whole Tech How-To bed →