Master Linux Network Commands: IP, Netstat, Ping, Traceroute, DNS & DHCP
This guide explains essential Linux networking commands—including ip, ifconfig, netstat, ping, traceroute, host, dig, systemd-resolve, and dhclient—showing how to view interfaces, check connectivity, trace routes, query DNS records, and manage DHCP leases for effective troubleshooting.
Interface Information
When you need details about the network interfaces of the device you are logged into, use the interface information commands.
IP command
View all IP addresses: ip a Use -4 or -6 to filter IPv4 or IPv6 addresses.
ip -4 a
ip -6 aAn alternative is ifconfig, which is easier to read and also displays basic transmit/receive statistics.
ifconfigNetwork status command
netstathelps discover which ports services are listening on. Use -t for TCP, -u for UDP, -l for listening ports, and -n to show IP addresses instead of hostnames. netstat -tul To see the PID of the process owning a listening port, add -p (requires sudo).
sudo netstat -tulpNetwork Availability
Commands to quickly check whether a host is reachable on the network.
Ping command
Ping tests whether a device is reachable, unless blocked by a firewall. Use an IP address or hostname.
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 Use -4 or -6 to force IPv4 or IPv6, and combine with -c for a limited count. ping -4 -c 3 192.168.1.10 Firewalls may block ping; allowing it on internal networks aids troubleshooting, while blocking it from DMZ to external networks can improve security.
Traceroute command
Traceroute shows the path packets take to reach an Internet host; useful when multiple routers are involved.
traceroute 8.8.8.8
traceroute google.comSpecify IPv4 or IPv6 with -4 or -6; the default is IPv4.
traceroute -4 google.com
traceroute -6 google.comDomain Name System
DNS commands help resolve hostnames and inspect DNS records.
Host command
Lookup the IP address for a domain. host google.com Specify a DNS server to use.
host google.com 1.1.1.1Dig command
digprovides detailed DNS information. dig google.com Specify a DNS server with @. dig @8.8.8.8 google.com Query all records with any or specific types such as MX.
dig google.com any
dig google.com mxPerform a reverse lookup with -x.
dig -x 8.8.8.8systemd-resolve command
Check the current DNS server settings. systemd-resolve --status Flush the DNS cache.
sudo systemd-resolve --flush-cachesDHCP
DHCP commands are useful for releasing and renewing leases after router or switch changes.
dhclient command
Release and renew the DHCP lease with 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.
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.
