How to check Internet access from a Linux terminal

To check if a Linux server can access the Internet, the first instinct might be to ping a well known server on the Internet such as Google’s DNS server If you can, that proves the server can go out into the Internet but if you cannot, it does not necessarily mean it cannot access the Internet.

$ ping
PING ( 56(84) bytes of data.

--- ping statistics ---
452 packets transmitted, 0 received, 100% packet loss, time 451025ms

For all good reasons, your network admin might be blocking icmp packets used by ping. What else can we do? If it was a desktop or the server has GUI which is rare, we would fire up a browser and open our favorite website. The good news is, we can use tools such curl, wget and text based browser such as lynx from the terminal. This is how we could go about verifying a Linux server have access to the Internet from the terminal.

1. Can the server talk your http proxy?
Mostly likely your server would need to access the Internet via a proxy. Check that the server can ping the proxy

PING (IP_ADDRESS) 56(84) bytes of data.
64 bytes from (IP_ADDRESS): icmp_seq=1 ttl=60 time=0.557 ms
64 bytes from (IP_ADDRESS): icmp_seq=2 ttl=60 time=0.497 ms
64 bytes from (IP_ADDRESS): icmp_seq=3 ttl=60 time=0.508 ms
64 bytes from (IP_ADDRESS): icmp_seq=4 ttl=60 time=0.581 ms

--- ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3002ms
rtt min/avg/max/mdev = 0.497/0.535/0.581/0.044 ms

2. Export proxy variables
Export http_proxy and https_proxy environment variables.

$ export http_proxy=
$ export https_proxy=

3. Curl your favorite website

$ curl

                Globomantics Simple Website

                        This is a simple HTML website.</h1>
                        We use this to demonstrate how HTTP works.</p>
                        You'll be able to see this clear text in Wireshark,
                        if you do your capture correctly.</p>
                        If you want a more complex website, try searching on
                        <a href="">


4. wget your favorite website

--2016-03-14 08:43:25--
Resolving IP_ADDRESS, ...
Connecting to|1P_ADDRESS|:8080... connected.
Proxy request sent, awaiting response... 200 OK
Length: 443 [text/html]
Saving to: `index.html'

100%[==============================================================================&gt;] 443         - -.-K/s   in 0s

2016-03-14 08:43:25 (38.4 MB/s) - `index.html' saved [443/443]

5. Lynx (or Links) your favorite website

$ links



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s