Linux Cheat Sheet for essential Network Commands
Whether troubleshooting connectivity issues, analyzing network traffic, verifying DNS resolution, or checking listening services, Linux provides a powerful set of built-in networking tools for day-to-day administration and debugging.
In this cheat sheet, we will look at some of the most essential Linux network commands commonly used for diagnostics, monitoring, and troubleshooting in enterprise and lab environments.
I will update this post on a regular basis.
Checking Listening Ports and Active Network Connections
The ss command is a modern and powerful replacement for legacy tools like netstat on Linux systems.
It can be used to quickly inspect listening TCP/UDP ports, active network connections, associated processes, and socket statistics, which is especially useful for troubleshooting network services such as SMTP, web servers, or SSH daemons.
For checking if Postfix is listening on TCP 25 e.g, the most useful ss command is:
# ss -tlnp | grep :25

Flags:
-t→ TCP sockets-l→ listening sockets only-n→ numeric ports/IPs-p→ show process using the socket
The following ss commands can be used to verify whether a DNS service is actively listening on UDP port 53 and to identify the associated process handling incoming DNS requests.
# ss -ulnp | grep :53

Flags:
-u→ UDP sockets-l→ listening sockets-n→ numeric output-p→ show associated process
Determine Public IP Address from Clients behind NAT by using DNS
The dig command can query Google’s public DNS service to determine the public IP address currently used for outbound internet connections.
This method is useful on Linux systems where external web services are unavailable or when troubleshooting NAT, firewalls, VPNs, and cloud networking configurations.
# dig TXT +short o-o.myaddr.l.google.com @ns1.google.com For Windows systems we can use: PS> (Invoke-RestMethod -Uri "https://api.ipify.org")
Links
ss — Linux manual page
https://man7.org/linux/man-pages/man8/ss.8.html
Latest posts
How to Migrate from vSphere Standard Switch (VSS) to vSphere Distributed Switch (VDS) – and Back Again
Follow me on LinkedIn
