Essential Linux Network Commands for Troubleshooting and Management
This guide explains key Linux networking commands—including ip, ifconfig, netstat, ping, traceroute, DNS utilities, and DHCP tools—showing how to view interfaces, check connectivity, trace routes, query DNS records, and manage DHCP leases for effective network troubleshooting.
Interface Information
Use the interface information command when you need details about the network interfaces of the device you are logged into.
IP Command
Display all IP addresses: ip a Filter for IPv4 or IPv6 with the -4 or -6 options:
ip -4 a
ip -6 aAnother way to view network information is with ifconfig, which presents the data in a more readable format and includes basic transmission/reception statistics.
ifconfigNetwork Status Command
The netstat command helps discover which ports services are listening on. Use -t for TCP, -u for UDP, -l to show listening ports, and -n to display numeric IP addresses. netstat -tul To see the process ID of the service listening on a port, add -p (requires sudo).
sudo netstat -tulpNetwork Availability
Network availability commands quickly check whether a host is reachable or powered on.
Ping Command
The most famous network command, ping, verifies connectivity without routing through a router, making it reliable within the same network.
ping 192.168.1.10
ping thehostnamePing runs continuously until stopped; use -c to specify the number of packets. ping -c 3 192.168.1.10 Specify IPv4 or IPv6 with -4 or -6, and combine options as needed.
ping -4 -c 3 192.168.1.10Traceroute Command
tracerouteshows the path packets take to reach an external network, useful for diagnosing routing issues.
traceroute 8.8.8.8
traceroute google.comBy default it uses IPv4; you can force IPv4 or IPv6 with -4 or -6.
traceroute -4 google.com
traceroute -6 google.comDomain Name System
DNS commands are valuable for verifying hostname-to-IP mappings and inspecting DNS records.
Host Command
Lookup the IP address for a domain name: host google.com Specify a DNS server for the query:
host google.com 1.1.1.1Dig Command
For detailed DNS information, use dig. Basic usage mirrors host: dig google.com Specify a DNS server with @: dig @8.8.8.8 google.com Retrieve all DNS records with the any option, or query specific types such as MX:
dig google.com any
dig google.com mxPerform a reverse DNS lookup with -x:
dig -x 8.8.8.8Systemd-Resolve Command
Check the current DNS server configuration: systemd-resolve --status Flush the DNS resolver cache after changing settings:
sudo systemd-resolve --flush-cachesDHCP
DHCP commands are useful for manually releasing and renewing leases after network changes.
Dhclient Command
Release and renew the DHCP lease on a device (requires sudo):
sudo dhclient -r
sudo dhclientSigned-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.
Open Source Linux
Focused on sharing Linux/Unix content, covering fundamentals, system development, network programming, automation/operations, cloud computing, and related professional knowledge.
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.
