Linux Troubleshooting 101-Networking
All computers have network problems from time to time. Usually everything works fine, but sometimes something goes wrong. The first step to determining what to fix is to determine where the issue lies. Below is outlined the first troubleshooting steps to determine where the problem lies.
Where is the Issue?
- On the computer?
- On the LAN – Local Area Network?
- On the Internet Connection, at the local router or at the ISP routers?
- With DNS – Dynamic Name Service?
There are simple commands that work for almost every UNIX/Linux-based computer, including Android, to troubleshoot these. We want to start from the computer and work our way out.
Even if you are not an expert, and I certainly am not, with these commands, we will be able to quickly narrow down where the issue is – or at least – where the issue is that is closest to the computer displaying the networking problem.
The Commands
For most of these commands, we need to use the IP address. This avoids being stopped by some other failure.
Determine The Computer’s IP Address
ip addr ... 3: enx000ec6cccbbaa: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 link/ether 00:0e:c6:cc:bb:aa brd ff:ff:ff:ff:ff:ff inet <strong>172.22.22.13/24</strong> brd 172.22.22.255 scope global enx000ec6cxxxxx valid_lft forever preferred_lft forever ...
The IP shown above is 172.22.22.13.
Determine The Router’s IP Address
$ route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 0.0.0.0 <strong>172.22.22.1</strong> 0.0.0.0 UG 0 0 0 enx000ec6caabbcc 172.22.22.0 0.0.0.0 255.255.255.0 U 0 0 0 enx000ec6caabbcc...
The gateway/router for this connection is 172.22.22.1. Your network will almost definitely have a different IP and router. Probably in the 192.168.×.x or 10.1.10.x IP ranges.
# Ping the router - you'll need to know the LAN router IP address ping 192.168.0.1 # ping a commonly known internet IP - 8.8.8.8 is an example ping 8.8.8.8 # see if DNS is working - try a few different, well-known, sites ping google.com ping www.abc.com
Depending on which command fails along the way, you have just determined a something is wrong – somewhere problem into a it is broken here problem.
Those are the first commands to check when you have any issue.
If you did the ping tests in order,
- Can’t ping the router using the router IP? Then the problem is before the router. That usually means a configuration or driver issue.
- Can’t ping a public internet IP? Then the problem is between the router and that internet server or a routing configuration issue.
- Can’t ping a few (always check more than 1) well-known website? The site is either down or you have a DNS issue. Try rebooting the router, then restarting the networking on your Linux computer. No need to reboot, unless you want.
Next Level
The following commands should help someone knowledgeable determine if the issue is a driver, routing, or configuration problem:
dmesg |grep eth[0-9]
sudo lshw -C network
ifconfig -a
more /etc/resolv.conf
route
Since 2016 or so, the systemd takeover has changed the typical names for network interfaces, i.e. NICs, so the driver used and the MAC address for the hardware create a unique device name on every system. Almost never will we see eth0 anymore, so that grep above likely will not find anything. Just put the interface name from the ip addr command a few sections above to filter the dmesg output.
These commands should show if the kernel found the network device, which driver is being used, if an IP has been assigned (static or DHCP), if DNS has been configured, and if a LAN and WAN route is setup properly. There is a little redundancy in the output. The first command does NOT show wifi adapters, because those will have different device names.
On my chromebook, the wifi device is:
$ dmesg |grep wlp1s0
[280380.755808] iwlwifi 0000:01:00.0 wlp1s0: renamed from wlan0
Non-Experts
If you aren’t familiar with networking, you can use another PC or telephone to contact someone to tell them the results of your troubleshooting. If you are an expert, I suppose you aren’t reading this anymore.
WiFi on Linux
I wish I had an answer, but wifi on Linux is beyond my skills. My experience with it is either it worked without any issues or it never worked.
There is a wifi network information script posted for each distro on most of their forums in the Network Issues sub-forum. In the Ubuntu forums, if there are wifi issues, the first thing that team will ask, is that you get and run the script.
Linux Support Forums
If you haven’t solved the issue by this point, it is time to ask for help. Each distribution has online forums where other users help each with issues. When you post, do not post everything, post only relevant data.
What is relevant:
- Wired ethernet or wifi? This is critical. Some commands are different for wifi.
- OS and Version – “Ubuntu” is not enough information. Use lsb_release -a
- State desktop or server install – which desktop environment is being used – Unity, Gnome3, KDE, others?
- At this point explain which of the first set up commands worked and which did not. Then post the output from the follow-up group of commands that is relevant.
- Google for an answer first. If you have googled and were unable to find an answer, let the readers know. It is really frustrating to me when people ask a very simple question on the forums that google would answer. I try to show the google query that I used to help. A few examples:
- ubuntu wifi howto
- ubuntu routing howto
- Copy/paste any error messages into google, add your distribution, remove any parts that are likely to be specific only to your system (like memory locations, kernel timestamps)
Your local LUG
Many metro areas have vibrant Linux Users Groups. Mine has over 4. Each runs an email list where we communicate and ask questions. Please, please, please, google for answers before posting. In your message, provide the same information AND the google query that didn’t work. Someone will be able to help you learn to google better or confirm your issue is un-googleable. How’s that for a word? We all have google-blindness from time to time.
Anyways, good luck and ask for help.
Post away and good luck.