11 Essential Linux Commands to Troubleshoot Network Issues
Network issues are some of the most frustrating problems I’ve encountered on a Linux system. One moment everything seems fine, and the next, you’re staring at a frozen terminal wondering what went wrong. In this guide, I’ll help clear up the confusion and walk you through troubleshooting your network.
Various Linux commands can troubleshoot different networking aspects, from basic connectivity to DNS resolution to firewall issues. Each tool offers insight into a different part of the system’s networking behavior.
So if you’re tired of guessing and ready to fix slow, broken, or even disconnected networks, you’re in the right place. Let me show you the essential commands that will take the mystery out of network troubleshooting.
If you need help with Linux, I’ve got something that can help you right away!
Download my free Linux commands cheat sheet – it’s a quick reference guide with all the essential commands you’ll need to get things done on your system. Click here to get it for free!
Identify Active Network Interfaces and IP Addresses
Before anything else, you need to ensure the system has a valid network interface and IP address. These two are the most important factors for any network connection, without them, you can’t go far.
To do this, I usually run the following command:ip a

This will show a list of network interfaces on your system and the IP addresses assigned to each. You’ll almost always see the lo interface (used for local loopback), and then another, often eth0/enp0s1 or wlan0 depending on whether it’s wired or wireless.
I can also determine whether an interface is available by looking at the UP and DOWN expressions next to its name. There are many other expressions recommended in the official documentation.
You might also like: Want to install Windows 11 on your Pi? Here's how
If you are more comfortable with older tools (or maybe you’re old enough!), there is an alternative called ifconfig that will provide you with the same information. There are also more ways to find your IP address, regardless of which Linux distribution or device you’re using.
Verify Network Connectivity Using Ping
Once you’re sure your interface is up, and you’ve got an IP, the next step is checking whether you can connect to anything. To do so, you must perform a ping request:ping <ip-address or domain>

Ping sends a series of ICMP packets to your target and reports whether they come back. If you get a response, great you have basic connectivity. But if not, it might mean something’s wrong with your connection, routing, or DNS.
Members get an ad-free version of every guide, plus exclusive project support.
Join the Community | Sign In
I recommend testing internal IPs (like your router’s or any other device in your network, usually expressed as 192.168.0.1) and external domains (like 8.8.8.8 or google.com). It’s not uncommon for the first ping to fail but the rest to succeed, so don’t be afraid.
Tip: Command lines can be a pain to memorize. I put the essential Linux commands on a printable cheat sheet so you don't have to keep googling them. You can grab the PDF here if you want to save some time.
Trace the Route to Find Where a Connection Fails
Still without a ping reply? Well, that’s bad. At this point, I would use a different tool, like traceroute. With traceroute, you can figure out where things are breaking down in the network. Like a ping, you can point it to an address or domain:traceroute <ip-address/domain>

Traceroute shows every “hop” your traffic takes to reach its destination. You’ll see each intermediary server. If something goes wrong, the process will usually stop responding at the point of failure.
As you can see, it took approximately 15 hops to reach this website. Of course, this number may vary depending on your source and destination locations.
Grab This Cheat Sheet!
I've compiled the must-know commands in a simple PDF for quick reference.
Download now
Note: This tool is usually not included by default in most distributions, so you’ll need to install it using APT or another package manager:sudo apt install traceroute
View the System’s Routing Table
So, even if your network interface appears to function properly and ping is working internally, you could still have trouble connecting to the internet or even locally with other devices.
At this point, I always examine the routing table closely to ensure that traffic is going where it should. A misconfigured gateway or missing default route is a surprisingly common cause of connectivity issues.
To see the current routing table, run:ip route

This command tells you how your system decides where to send outgoing traffic. It displays the default route (your system’s gateway to the internet), and the specific networks attached to each interface.
This information can help you identify incorrect configurations that do not align with your IP address. A wrong gateway, missing interface, or mismatched subnet could all explain connectivity problems.
Troubleshoot DNS Resolution Failures
So, you’ve verified that your interface is up and your route is in place, but you still can’t load websites by name? That might point to a DNS resolution issue. In simple terms, DNS is like your phone book of the internet, it turns website names (like raspberrytips.com) into IP addresses.
You can test DNS resolution using the dig command:dig <website>

If everything’s working, you’ll get an IP address under the ANSWER SECTION. If not, your system might be unable to reach a DNS server, and it may be necessary to check your DNS configuration into the hosts file (/etc/hosts).
View and Manage Current Network Configuration
If you have located the problem and determined it is in your network configuration, the first step is to view your current settings.
This may vary depending on your Linux distribution, but generally, you should be able to view a system file such as:
- /etc/network/interfaces – Used in older Debian-based systems (Debian, Ubuntu < 18.04).
- /etc/netplan/*.yaml – Used in modern Ubuntu versions (18.04+).
- /etc/sysconfig/network-scripts/ifcfg-* – Used in CentOS, RHEL, and AlmaLinux in older setups.
- /etc/NetworkManager/system-connections/*.nmconnection – Used in most modern desktop distros (including Fedora, Ubuntu Desktop, Manjaro, etc.).

You can open and modify these files using a text editor (I like to use nano or vim), but be cautious, especially over SSH. A single typo can break your network configuration. After making changes, restart your network service to apply them. Here’s how:
- Ubuntu (Netplan – Ubuntu 18.04+):
sudo netplan apply - Debian/Ubuntu (if using /etc/network/interfaces):
sudo systemctl restart networking - CentOS / RHEL / AlmaLinux (using network-scripts):
sudo systemctl restart network - CentOS / Fedora / Ubuntu (with NetworkManager):
sudo systemctl restart NetworkManager
If you’re looking to simplify or automate your network management, nmcli is a tool worth exploring. It makes handling connections much easier than using manual commands. It’s covered in detail in this guide on using nmcli, so be sure to check it out!
You might also like: Probably one of the best Raspberry Pi workstations (review)
Note: Don’t attempt this via SSH or any remote method unless you know exactly what you’re doing. You could lose remote access to any misconfiguration of the interface. I learned this the hard way several times.
Discover Open Ports and Listening Services
If you suspect something is running or listening on your machine that shouldn’t be, or you simply want to know which services are open to the network, you can check with:ss -tuln

This shows all currently open TCP and UDP ports, along with the addresses they’re bound to. Look for entries with 0.0.0.0 or your system’s IP in the Local Address column, those are ports open to external connections.
If you don’t see your expected service (like SSH on port 22 or HTTP on port 80), it might not be started, or its configuration could be wrong.
Although many tools are available for checking open ports, I prefer this one because it’s short and simple. However, it’s worth exploring other effective methods because your preferences may differ from mine. We’ve listed a few great alternatives in our article on checking open ports.
Check Port Availability from Another Device
Even if your service is listening, it doesn’t guarantee that others can access it, there could be a firewall or routing block in the way. To confirm port availability externally, I always like to use:telnet <target-ip> <port>

Grab This Cheat Sheet!
I've compiled the must-know commands in a simple PDF for quick reference.
Download now
If the port is open, it will return a success message.
If not, it will hang or return a connection refused error.
This helps identify firewall issues or services that aren’t running.
Review Firewall Rules That Might Be Blocking
Sometimes everything else checks out, but your system still won’t accept incoming traffic. In those cases, your firewall might be doing its job a little too well. If you’re unsure, the first thing I usually do is to check the current network status:sudo ufw status

But If you prefer a more detailed view (or aren’t using UFW), you can check iptables directly:sudo iptables -L -n -v

This will show you all current rules, allowing you to see if a port is being dropped, rejected, or allowed. Use this carefully, because firewall misconfigurations are a common cause of unexpected connectivity issues, and you can even block your access by any mistake.
Related: Step-by-Step Guide: Configuring a Firewall on Raspberry Pi
Monitor the Network Traffic in Real Time
Sometimes your internet works, but it’s extremely slow. That’s usually a sign of bandwidth congestion, maybe from a heavy download, a misbehaving service, or even malware.
To see what’s going on in real-time:sudo iftop

This tool displays a live feed of which IP addresses are sending or receiving data to and from your system. You’ll instantly spot any traffic spikes or unusual hosts. It usually helps me find hungry-network devices or stranger behavior.
Prefer videos over reading? The RaspberryTips Community members get exclusive video lessons every month. Join now and watch them all right away. Get instant access.
Capture and Analyze Packets in the Network
Lastly, for advanced users, packet sniffing can be a powerful way to troubleshoot obscure or low-level network problems. The go-to tool for this is tcpdump. With it, you can capture and analyze raw traffic:sudo tcpdump -i <interface> port <port-number>

This captures all traffic on port 80 (HTTP) from the main interface. You can replace the interface or port to match your case. Packet captures let you see exactly what data is being sent and received, which is great for tracking down protocol errors, timeouts, or unexpected behavior.
If you’re just getting started with network analysis, Wireshark is a great tool to begin with. It’s a more user-friendly alternative to tcpdump that makes it easier to visualize what’s happening on your network.
Note: tcpdump can produce thousands of lines in seconds. Always filter by interface, port, or protocol to avoid getting overwhelmed.
Finally, with these tools and commands at your disposal, you won’t have to guess your way through network issues now or in the future. These tools and commands will make diagnosing and fixing network problems feel more like a routine than an unresolved mystery.
Whenever you're ready, here are other ways I can help you:
Master Linux Commands: Overwhelmed with Linux commands? This book is your essential guide to mastering the terminal. It includes practical tips, real-world examples, and a bonus cheat sheet to keep by your side.
The RaspberryTips Community: Need help with Linux or want to chat with people who actually get it? Join the RaspberryTips Community and get access to private forums, exclusive lessons, and direct support.
You can also find all my recommendations for tools and hardware on this page.
You might also like: Yes, you can access your Pi from anywhere. Here's how.
