Operations 9 min read

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.

Liangxu Linux
Liangxu Linux
Liangxu Linux
Master Linux Network Commands: IP, Netstat, Ping, Traceroute, DNS & DHCP

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 a

An alternative is ifconfig, which is easier to read and also displays basic transmit/receive statistics.

ifconfig

Network status command

netstat

helps 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 -tulp

Network 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 thehostname

Ping 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.com

Specify IPv4 or IPv6 with -4 or -6; the default is IPv4.

traceroute -4 google.com
traceroute -6 google.com

Domain 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.1

Dig command

dig

provides 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 mx

Perform a reverse lookup with -x.

dig -x 8.8.8.8

systemd-resolve command

Check the current DNS server settings. systemd-resolve --status Flush the DNS cache.

sudo systemd-resolve --flush-caches

DHCP

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 dhclient
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

linuxDNS
Liangxu Linux
Written by

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.)

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.