Master Linux Network Troubleshooting: Essential Commands and Step‑by‑Step Guide
Learn how to configure and diagnose Linux network issues using essential commands such as ifconfig, ping, traceroute, netstat, ss, dig, nslookup, route, ethtool, and arp, with practical examples and a systematic troubleshooting workflow to quickly identify and resolve connectivity problems.
ifconfig – Network Interface Configuration and Inspection
The ifconfig command displays interface status, configures IP addresses and netmask, and enables or disables interfaces.
Show all interfaces: ifconfig -a Assign an IP address and netmask to an interface (e.g., eth0):
ifconfig eth0 192.168.1.110 netmask 255.255.255.0Enable or disable a specific interface:
ifup eth0 # enable
ifdown eth0 # disableChanges made with ifconfig are not persistent across reboots; edit the appropriate network configuration files for permanent settings.
ping – Test Network Connectivity
pingsends ICMP echo requests to verify that a host is reachable and measures round‑trip latency.
Ping the local loopback address: ping 127.0.0.1 Ping a remote host with a limited packet count (e.g., 5 packets):
ping -c 5 www.example.comtraceroute – Trace Packet Path
tracerouteshows each hop a packet takes to reach its destination, which helps locate routing problems.
traceroute 8.8.8.8netstat and ss – View Network Connections
Both commands list active sockets and listening ports. ss is generally faster.
Show all listening TCP and UDP ports:
netstat -tuln ss -tulnDisplay the routing table:
netstat -rdig and nslookup – DNS Queries
Use dig or nslookup to inspect DNS records.
dig www.google.com
nslookup google.comroute – Manipulate Routing Table
The route command displays or modifies the system’s routing information.
Show current routes: route Add a default gateway (replace with your gateway address):
route add default gw 192.168.1.1ethtool – Ethernet Interface Settings
ethtoolqueries or changes Ethernet driver parameters, useful for hardware‑level diagnostics.
ethtool eth0arp – Manage ARP Cache
arpdisplays or modifies the ARP table, helping resolve MAC address conflicts.
arp -ePractical Troubleshooting Workflow
When a website is unreachable, follow these steps to isolate the problem:
Check interface status: ifconfig Verify local loopback connectivity: ping 127.0.0.1 Test reachability of the default gateway (replace with your gateway address): ping <code>gateway_IP</code> Query DNS records for the target host:
dig www.example.com nslookup www.example.comInspect the routing table to ensure a valid route exists: netstat -r Combining these commands enables rapid identification of connectivity, DNS, or routing issues, allowing efficient resolution.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Liangxu Linux
Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
