Pieter's Page

Dive deep in Software, Cloud, Security, and DevOps

Check Internet Connection

The confirm that you have an internet connection you can run the following commands to test and confirm in the terminal.

Standard Ping

Ping sends a small packet of data to server and waits for a response.

The most reliable target is Google’s DNS servers:

ping 8.8.8.8

Alternatively you can ping against Cloudflare’s DNS servers:

ping 1.1.1.1

Successful requests will output the following:

PING 8.8.8.8 (8.8.8.8): 56 data bytes
64 bytes from 8.8.8.8: icmp_seq=0 ttl=117 time=8.113 ms
64 bytes from 8.8.8.8: icmp_seq=1 ttl=117 time=7.226 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=117 time=11.837 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=117 time=13.184 ms
^C
— 8.8.8.8 ping statistics —
4 packets transmitted, 4 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 7.226/10.090/13.184/2.487 ms

Failed requests will output Request timed out or Destination host unreacable.

Testing DNS

Sometime you will have a connection to the internet at IP level, but your DNS is broken (Cannot load websites by their name).

Test this with the ping command to a domain name, and not the IP address:

ping google.com

If ping 8.8.8.8 works, but but ping google.com fails your internet is working but your DNS setting are misconfigured.

Testing Web Traffic

You can try fetching the headers of a website. This is more “real-world” as it test the HTTP Protocol

curl -I https://www.google.com

Successful requests will return HTTP/1.1 200 OK, or similar:

HTTP/2 200
content-type: text/html; charset=ISO-8859-1

Failed requests will hang or say Could not resolve host.

In Closing

If all the above command successfully work, then you have an internet connection that is working. If you are then still experiencing any issues, then it could be something more specific to your firewall or the application that you are using.