How to Troubleshoot Network Connectivity on Linux (Step-by-Step)

Introduction

If you’ve ever sat in front of a Linux terminal thinking,

“Why can’t this server reach the internet?”

—you’re not alone.

Every system administrator, especially when starting out, eventually faces the mysterious “no internet” moment.
Maybe it’s a wrong gateway, a missing DNS, or a firewall rule you forgot existed.

In this guide, I’ll walk you through a simple, logical way to troubleshoot network connectivity issues on Linux, step by step — exactly how I do it in the field.
No guesswork. No panic. Just a solid method that works.

Step 1: Check the Network Interface

Before jumping into commands, take 30 seconds to check the physical layer —
Is the cable plugged in, link light on, or the virtual NIC attached (if you’re on a VM)?
It sounds simple, but it’s one of the most common root causes of “network not working.”

Then, check your interface:

ip a

You should see something like:

2: eno1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 ...
    inet 192.168.10.25/24 brd 192.168.10.255 scope global dynamic eno1Code language: HTML, XML (xml)

Look for:

  • The word UP in the interface status
  • A valid IP address (not 0.0.0.0)

If the interface is missing or down:

sudo systemctl restart networking

or double-check /etc/network/interfaces.

If you’re using DHCP, confirm the lease:

sudo journalctl -u systemd-networkd | grep DHCP

Step 2: Verify Your Default Gateway

Next, confirm your default route — it’s your way out to the internet.

ip route show

Expected output:

default via 192.168.10.1 dev eno1
192.168.10.0/24 dev eno1 proto kernel scope link src 192.168.10.25Code language: JavaScript (javascript)

Make sure:

  • You have a default via entry
  • The gateway IP (192.168.10.1 in this case) is reachable

Try pinging it:

ping -c 3 192.168.10.1Code language: CSS (css)

If that fails, you might have a wrong gateway, VLAN tagging issue, or misconfigured bridge.

Step 3: Test External Connectivity (Without DNS)

If your gateway works, test an external IP directly to see if your routing and NAT are fine:

ping -c 3 8.8.8.8Code language: CSS (css)

Works → Great, your network layer is fine.
❌ Fails → Check firewall, NAT, or ISP connection.

Step 4: Test DNS Resolution

If IP pings work but domain names don’t, it’s a DNS problem.

ping -c 3 google.comCode language: CSS (css)

If that fails, check your DNS configuration:

cat /etc/resolv.conf

Example:

nameserver 1.1.1.1
nameserver 8.8.8.8Code language: CSS (css)

Try testing DNS directly:

dig google.comCode language: CSS (css)

or

nslookup google.comCode language: CSS (css)

If it only works with IPs, your /etc/resolv.conf might be misconfigured or overwritten by NetworkManager.

Step 5: Check Firewall Rules

Sometimes the network is fine — but the firewall says no.

For UFW:

sudo ufw status verbose

For iptables:

sudo iptables -L -n -v

If you see DROP or REJECT on outbound traffic, that’s your culprit.

Temporarily allow outgoing traffic for testing:

sudo ufw allow out on eno1

Step 6: Trace the Route

Use traceroute or mtr to see exactly where packets stop.

sudo apt install traceroute mtr -y
traceroute 8.8.8.8Code language: CSS (css)

or

mtr -rw google.comCode language: CSS (css)

If it stops at your gateway → local issue.
If it stops further → ISP or routing issue upstream.

Step 7: Restart Network ServicesWhen everything looks fine but still doesn’t work — restart the network stack.

sudo systemctl restart networking

If you’re using NetworkManager:

sudo systemctl restart NetworkManager

In virtualized environments (KVM, Proxmox, etc.):

sudo systemctl restart libvirtd

Key Takeaways

  • Always start from the basics — physical layer, interface, route, then DNS.
  • Ping by IP first, then by hostname.
  • Check routes before blaming DNS or firewall.
  • Use mtr to see where packets actually stop.

Network troubleshooting isn’t about memorizing commands — it’s about thinking logically under pressure.

Final Thoughts

Troubleshooting networks might feel overwhelming at first, but once you follow a clear process, it becomes second nature.

Remember: even experienced sysadmins still start with ping.
The difference is — they know exactly what to check next.

Quick Command Summary

PurposeCommand
Show interfacesip a
Show routesip route show
Test gatewayping -c 3 <gateway>
Test external IPping -c 3 8.8.8.8
Test DNSping google.com / dig google.com
Show firewall rulessudo ufw status / iptables -L -n -v
Trace routetraceroute 8.8.8.8 / mtr -rw google.com

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top