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 220.127.116.11. 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 18.104.22.168 PING 22.214.171.124 (126.96.36.199) 56(84) bytes of data. --- 188.8.131.52 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 proxy.example.com PING proxy.example.com (IP_ADDRESS) 56(84) bytes of data. 64 bytes from proxy.example.com (IP_ADDRESS): icmp_seq=1 ttl=60 time=0.557 ms 64 bytes from proxy.example.com (IP_ADDRESS): icmp_seq=2 ttl=60 time=0.497 ms 64 bytes from proxy.example.com (IP_ADDRESS): icmp_seq=3 ttl=60 time=0.508 ms 64 bytes from proxy.example.com (IP_ADDRESS): icmp_seq=4 ttl=60 time=0.581 ms --- proxy.example.com 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=http://proxy.example.com:8080 $ export https_proxy=http://proxy.example.com:8080
3. Curl your favorite website
$ curl http://www.veronicasplantnursery.com/ Globomantics Simple Website <h1> This is a simple HTML website.</h1> <p> We use this to demonstrate how HTTP works.</p> <p> You'll be able to see this clear text in Wireshark, if you do your capture correctly.</p> <p> If you want a more complex website, try searching on <a href="http://www.youtube.com/watch?v=qb_hqexKkw8"> Google </a>. </p> ~~~
4. wget your favorite website
wget http://www.veronicasplantnursery.com/index.html --2016-03-14 08:43:25-- http://www.veronicasplantnursery.com/index.html Resolving proxy.example.com... IP_ADDRESS, ... Connecting to proxy.example.com|1P_ADDRESS|:8080... connected. Proxy request sent, awaiting response... 200 OK Length: 443 [text/html] Saving to: `index.html' 100%[==============================================================================>] 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 http://www.veronicasplantnursery.com