Linux – Diagnose internet connection issues using command line

centoscommand lineinternetlinuxwget

I'm having multiple issues trying to get CentOS to download anything. I can't get yum to work because there is a time out when trying to access a file. Anyways, is there a way to trace why a command won't get past a certain phase?

For example, if I run the following command:

 wget -O /dev/null http://speedtest.wdc01.softlayer.com/downloads/test10.zip

wget hangs on Connecting to addressFromAbove and finally times out a couple of minutes later.

How can I diagnose this issue?

Best Answer

There are a number of things to check. I would begin by checking these things:

  • command "ifconfig": ensure that you have an IP address and the correct net mask on the adapter you're connecting through. If you have multiple adapters on your server, make sure the right port is plugged in.
  • If you're using a static IP, try switching to DHCP if you can. If it works now, you've got some settings that are not being properly set when using the static IP.
  • command "ping default_gateway_ip": put the ip address of your gateway in to see if the server can communicate within your network
  • command "ping 8.8.8.8": test if traffic is flowing directly to a remote address.
  • command "ping www.google.com": test if you can resolve an address via DNS
  • command "route": make sure your default gateway is set, otherwise traffic won't properly route to external networks. (look for the UG flag)
  • command "service iptables stop": turn off you're firewall and test if it's mis-configured (don't forget to turn it back on)

If any of these fail, you should be able to do a web search to find a solution.

Related Question