BOOK THIS SPACE FOR AD
ARTICLE ADModern network connectivity is light years ahead of what it once was. Even though it's much more reliable than it was in the 1990s, issues still come up -- which is why I'm glad that Linux includes a bevy of commands I can use to start troubleshooting the problem.
Also: The first 5 Linux commands every new user should learn
Here are the five commands I turn to first.
1. ip
The ip command isn't just an easy way to discover your computer's IP address (ip a will do the trick), but it's also capable of troubleshooting connectivity. For example, I can check the status of all my network devices with the command:
The output of the above command displays the name of your network device, the MTU speed, the configuration options applied, and the IPv6 address of your connection. You can also start and stop network devices with ip link, like this:
You can also view the routes defined on your machine with:
From that command, you'll see the default route, the configurations applied, and the subnet of your network.
2. nslookup
The nslookup helps you to troubleshoot DNS name resolution. Let's say you're trying to reach a site and it's not coming up. Is it a local or remote issue?
Also: Vanilla OS Orchid improves on an already brilliant Linux distribution
To start troubleshooting, issue the command:
If you receive an answer (which will include the site's IP address), chances are pretty good the problem is local, and you can focus your troubleshooting efforts on your computer or your LAN. If you do not receive an answer, the problem is remote, and there's not much you can do (other than wait for the site to come back up).
You can also run a reverse DNS lookup by using the IP address, like this:
In this case, IP is the IP address. This command will display the host of the IP address (such as googleusercontent.com).
3. ss
The ss command replaced the deprecated netstat package and provides detailed information as to how your computer communicates to other devices, networks, or services. This command's main functionality is to dump socket statistics and display more TCP and state information than other tools.
If you issue the ss command without options, it will list all non-listening sockets with established connections. In other words, you'll see every device with an established connection to your computer. This can be very handy when trying to find out what machines and/or ports are communicating with your desktop or server.
Also: 5 Linux terminal apps that are better than your default
The output also includes the number of sent and received packets, so if you see a listing with an unusually high amount of sent or received packets, that could be a problem. You can also list only connections to a specific IP address. Let's say you suspect an IP address is sending and/or receiving too many packets to your machine. You can check that with:
Once again, IP is the IP address. You see a listing of the network ID, state, received packets, sent packets, local address port, peer address port, and process.
4. tracepath
The tracepath command displays the network connectivity path between local and remote hosts and identifies all routers used to make the connection. When you're unable to make a connection to a site, issue the command:
Here, SITE is the domain or IP address of the site in question.
The output of the command will list all hops between local and remote machines. If you see machines in that path posting a no reply, that could be where the problem lies.
The nice thing about tracepath is that it lists all IP addresses of the machines routing the packets from your local host to the remote. The maximum number of hops tracepath will attempt is 30. You can change that using the -m option, like this:
SITE is the site in question. You probably would never need to check 50 hops, but you can if needed.
5. ping
This is always the first command I use when networking problems arise. If my network seems down, I'll issue the command:
If the command works, then the issue is not DNS-related.
Also: How to replace Windows with Linux Mint on your PC
I use the ping command either when I suspect my local network is down or when a site is down. If I receive a response, I move on to other troubleshooting efforts.
These five Linux commands should help you troubleshoot any networking issues. To find out more bout these commands, make sure to read the man page for each (such as man ip, man nslookup, man ss, man tracepath, and man ping).