Linux Network Troubleshooting: A Complete Guide to Diagnosing and Fixing Connectivity Issues

"Stability is the goal of IT operations, but anomalies are the daily reality."
Photo by TC Photography / Unsplash

πŸš€

When a Linux system experiences network issues, it can be caused by hardware failures, misconfigurations, or service-related problems. To systematically identify and resolve network issues, follow this structured troubleshooting guide.

πŸ“Œ In this guide, you’ll learn:
βœ… How to check and diagnose common Linux network problems
βœ… Step-by-step solutions to fix network issues
βœ… Best practices to maintain a stable Linux network


πŸ›‘ 1. Check Network Hardware

Before troubleshooting software issues, verify that network hardware is functioning correctly.

πŸ”Ή Step 1: Verify Physical Connections

1️⃣ Check Network Cables – Ensure the Ethernet cable is properly plugged in and not damaged.
2️⃣ Verify Network Interfaces – If using a wired connection, check if the Ethernet port link lights are active.
3️⃣ Inspect Routers and Switches – If multiple devices are experiencing network issues, a router or switch failure could be the cause.

βœ… Solution: If a hardware component is faulty, replace or repair it before proceeding to software-based troubleshooting.


πŸ› οΈ 2. Verify Network Interface Configuration

If the hardware is working, check if the network interface is properly loaded and configured.

πŸ”Ή Step 1: Check if the Network Interface is Loaded

Use the ip a or ifconfig command to verify if the network interface is recognized:

ip a

πŸ“Œ Expected Output: The network interface (e.g., eth0, wlan0) should be listed.

βœ… If the interface is missing β†’ The driver may not be loaded. Use dmesg | grep eth to check for errors.


πŸ”Ή Step 2: Verify Interface Status

Check interface link status and speed using ethtool:

ethtool eth0

Look for:

  • Speed: Ensure it matches the expected value (e.g., 1000Mb/s for Gigabit Ethernet).
  • Link detected: If no, check the cable or port.

βœ… Solution: If Link detected: no, replace the cable or check for hardware issues.


πŸ”Ή Step 3: Check IP Address Configuration

Use the ip a command to check if the network interface has a valid IP address:

ip a show eth0

βœ… Solution: If no IP is assigned, use:

dhclient eth0  # Dynamic IP assignment

or manually configure a static IP:

ip addr add 192.168.1.100/24 dev eth0

πŸ”„ 3. Test Network Connectivity

After confirming that the network interface is correctly configured, test connectivity within the network.

πŸ”Ή Step 1: Ping a Local Machine

Use ping to test connectivity to another machine in the same network:

ping 192.168.1.1

βœ… Solution: If ping fails, verify that the local firewall or security settings are not blocking ICMP traffic.

πŸ”Ή Step 2: Ping the Default Gateway

ping 192.168.1.254

πŸ“Œ If gateway pings fail, check if the router is operational and properly configured.


πŸ“Œ 4. Verify Routing Table Configuration

A misconfigured routing table can cause connectivity issues even if the network interface is correctly set up.

πŸ”Ή Step 1: Check the Current Routing Table

ip route show

βœ… Example Output:

default via 192.168.1.1 dev eth0
192.168.1.0/24 dev eth0 proto kernel scope link src 192.168.1.100

πŸ”Ή Step 2: Fix Incorrect Routes

If the default route is missing, add it manually:

ip route add default via 192.168.1.1 dev eth0

πŸ“Œ Common Issue: If a system has multiple network interfaces (eth0, eth1), ensure the correct interface is used for external traffic.


🌐 5. Test DNS Resolution

If the system can reach the gateway but cannot browse the internet, DNS issues may be the cause.

πŸ”Ή Step 1: Test DNS Resolution

nslookup google.com

or

dig google.com

βœ… If DNS fails, try pinging an IP directly:

ping 8.8.8.8

πŸ“Œ If pinging an IP works but domains don’t resolve, DNS is misconfigured.

πŸ”Ή Step 2: Check DNS Configuration

Verify the /etc/resolv.conf file:

cat /etc/resolv.conf

βœ… Example Correct Configuration:

nameserver 8.8.8.8
nameserver 1.1.1.1

If DNS settings are incorrect, update the file and restart networking:

systemctl restart networking

βš™οΈ 6. Check Network Services

Some network issues stem from disabled or misconfigured services.

πŸ”Ή Step 1: Check if the Service is Running

For SSH:

systemctl status ssh

For Apache/Nginx:

systemctl status apache2

βœ… Solution: If the service is not active, restart it:

systemctl restart ssh

πŸ”Ή Step 2: Check Open Ports

Use netstat or ss to check if the service is listening:

netstat -tulnp | grep 22

πŸ“Œ If the port is closed, firewall rules or service misconfiguration may be blocking traffic.

βœ… Solution: Open the required port using:

ufw allow 22/tcp

πŸ›‘οΈ 7. Prevent Future Network Issues

Follow these best practices to avoid recurring network problems:

βœ… Document network configurations
Keep a record of /etc/network/interfaces (Debian) or /etc/sysconfig/network-scripts/ (RHEL).

βœ… Regularly monitor network interfaces
Check the status using:

ip -s link show eth0

βœ… Perform routine firewall checks
Ensure the firewall is not blocking expected traffic:

iptables -L -n

βœ… Monitor network logs for early detection
Check dmesg and /var/log/syslog for networking errors:

dmesg | grep eth

πŸ“Š 8. Summary

Issue Solution
No network connection Check hardware, cables, and ports
No IP address assigned Use dhclient or manually configure IP
Cannot connect to other machines Check routing table and firewall rules
Internet not working but local network is fine Check DNS settings (resolv.conf)
Services not accessible remotely Verify if service ports are open and firewall rules allow traffic

πŸ’¬ Join the Discussion!

Have you faced Linux network issues before?
What troubleshooting steps helped you fix them?

πŸ’¬ Share your experience in the comments below! πŸš€

πŸ‘‰ If you're troubleshooting Linux boot issues, check out: How to Fix Linux Boot Failure Due to Kernel File Loss

Read more