Core CLI tools to diagnose connectivity, DNS, routing, and paths across Windows, Linux, and macOS.
The following outlines some Essential Network Commands used between Windows, Linux, as well as macOS.
Network commands via the Command-Line Interface (CLI) allow you to effectively diagnose, troubleshoot, and manage network connections by offering detailed insights and real-time control over network environments.
Testing connectivity and measuring latency:
Windows:
ping example.com
ping -t example.com
ping -n 10 example.com
ping -l 1500 example.com
ping example.com
This sends four ICMP echo request packets to example.com
to test if the host is reachable and how long it takes for each response.
Use Case:
Quick connectivity test.
ping -t example.com
This sends continuous pings to example.com until manually stopped with ctrl + c
It's useful for monitoring real-time connectivity or detecting intermittent packet loss.
Use Case:
Ongoing monitoring for uptime and stability.
ping -n 10 example.com
Sends exactly 10 ping requests to example.com, instead of the default 4.
The -n switch allows you to specify the number of echo requests to send.
Use Case:
More thorough connectivity testing without going infinite.
ping -l 1500 example.com
Sends a ping to example.com with a custom packet size of 1500 bytes (instead of the default 32 bytes).
The -l option allows you to stress test the MTU and check for fragmentation.
Use Case:
MTU path discovery or testing network handling of large packets.
Linux:
ping example.com
ping -c 4 example.com
ping -i 0.5 example.com
ping -s 10 example.com
ping example.com
Sends continuous ICMP echo requests to example.com
Until manually stopped (usually with ctrl + c)
This is the default behavior on most Linux systems:
Use Case:
Live monitoring of reachability and response times.
ping -c 4 example.com
Sends exactly 4 ping requests to example.com and then stops automatically.
The -c flag stands for "count".
Use Case:
Simple, quick connectivity test — very similar to Windows default ping behavior.
ping -i 0.5 example.com
Sends pings to example.com at 0.5-second intervals between each request.
The -i flag sets the interval in seconds.
Use Case:
Faster-than-default pinging for fine-grained timing analysis or when observing short-lived connectivity changes.
ping -s 10 example.com
Sends pings with a custom ICMP payload size of 10 bytes, not counting the 8-byte ICMP header.
Total size sent = 18 bytes.
Use Case:
Useful for testing small packet delivery or for troubleshooting fragmentation or MTU-related issues.
Quickly retrieving network interface configurations and IP details
to address network connectivity and configuration issues promptly:
Windows:
ipconfig /all
ipconfig /release
ipconfig /renew
ipconfig /flushdns
ipconfig /all
Displays detailed network configuration for all network adapters on the system.
Including IP addresses, MAC addresses, DNS servers, DHCP lease info, and more.
Use Case:
Great for network troubleshooting, verifying DNS settings, checking DHCP status, or seeing physical (MAC) addresses.
ipconfig /flushdns
Clears the local DNS resolver cache, forcing the system to re-fetch DNS records the next time a domain is queried.
Use Case:
Used to fix DNS resolution issues, especially when a site has changed IP addresses or DNS has become stale or corrupted.
ipconfig /release
Releases the current IP address lease from the DHCP server for all adapters (or a specific one if specified).
Use Case:
Typically used to force-disconnect from a network or to troubleshoot DHCP assignment problems.
ipconfig /renew
Then requests a new IP address from the DHCP server for all adapters (or a specific one if specified).
Use Case:
Helps reconnect to a network, especially after a release or when troubleshooting automatic IP assignment issues.
Linux:
ifconfig
ip a
sudo dhclient -r
sudo dhclient
sudo systemctl restart NetworkManager
Displays the IP address, MAC address, and interface status for all active network interfaces. It's the legacy tool for interface configuration and inspection.
Use Case:
Quick way to check current IPs, interface names (like eth0, wlan0), or bring interfaces up/down (e.g., ifconfig eth0 down)
Displays all IP address information for each network interface, including IPv4/IPv6, loopback, and virtual interfaces. This command is part of the more modern iproute2 suite.
Use Case:
Preferred over ifconfig in modern systems for a more comprehensive and scriptable view of network config.
sudo dhclient -r
Sends a DHCP release request to the server and removes the current IP lease from the system.
Use Case:
Useful for disconnecting from the network or clearing stale DHCP settings before getting a new lease.
sudo dhclient
Requests a new IP address from the DHCP server for a network interface. If no interface is specified, it attempts on all interfaces.
Use Case:
Similar to ipconfig /renew — used when you need to reacquire an IP address or force DHCP negotiation.
sudo systemctl restart NetworkManager
Fully restarts the NetworkManager service, which manages network interfaces, DHCP leases, and DNS on many Linux distributions.
Use Case:
Used when facing network misbehavior or configuration changes that didn't apply.
It resets network connectivity without rebooting.
Scenarios for use:
Inspecting ARP tables to correlate IP addresses with MAC addresses:
arp -a
Benefits:
Resolving domain names to IP addresses for verifying DNS records:
Windows:
nslookup example.com
nslookup -type=mx example.com
nslookup -type=ns example.com
nslookup example.com
The nslookup command in Windows queries the nameserver for the IP address of the given host or vice versa in performing a reverse DNS lookup.
Launches an interactive DNS lookup tool that allows you to manually query DNS records.
Running it by itself drops you into a prompt where you can type in domains and get their associated IP addresses.
Use Case:
Useful for troubleshooting DNS resolution and verifying that a domain points to the correct IP address.
Reverse DNS (PTR) lookup example:
nslookup -type=mx example.com
This command queries the Mail Exchange (MX) record for example.com, showing which mail servers are responsible for handling email for the domain.
Use Case:
Helpful for email delivery diagnostics, checking mail server priorities, or verifying email infrastructure.
nslookup -type=ns example.com
Retrieves the Name Server (NS) records for example.com, identifying which DNS servers are authorized for the domain.
Use Case:
Used to validate domain delegation, ensure DNS servers are responding, or troubleshoot DNS propagation issues.
Linux:
host example.com
host -t MX example.com
host -t NS example.com
dig example.com
dig MX example.com
dig NS example.com
host example.com
The host command is a simple DNS lookup utility that returns DNS records for the given domain.
host example.com returns the A record, showing the IPv4 address of the domain.host -t mx example.com queries the MX records, listing mail servers responsible for handling email for the domain.host -t ns example.com displays the NS records, identifying the authoritative name servers for the domain.Use Case:
Ideal for quick DNS lookups when you want a fast, human-readable response without the detailed output of dig. Perfect for verifying basic DNS, mail routing, and domain delegation settings.
dig example.com
Performs a DNS query for example.com, returning A records (IPv4 addresses) by default, including a detailed breakdown of the query and response.
Use Case:
Preferred tool for troubleshooting DNS issues, seeing exact response times, and analyzing query behavior.
dig MX example.com
Queries the Mail Exchange (MX) records for example.com and shows priority & hostnames.
Use Case:
Used to inspect email routing setup, diagnose mail delivery problems, or verify MX changes after DNS edits.
dig NS example.com
Retrieves the Name Server (NS) records for example.com, showing the authoritative DNS servers responsible for handling domain resolution.
Use Case:
Helpful for checking domain delegation, identifying authoritative zones, and troubleshooting DNS propagation.
Troubleshooting scenarios:
Monitoring current connections and ports:
Windows:
netstat -a
netstat -an
netstat -b
The netstat command displays network connections, listening ports, and routing tables.
netstat -a shows all active TCP/UDP connections and listening ports, resolving hostnames and service names.netstat -an displays the same data but in numeric form, skipping DNS/service name resolution for faster, raw output.netstat -b shows which executable is associated with each connection or listening port (e.g., chrome.exe or svchost.exe).Use Case:
Great for identifying open ports, active connections, unauthorized programs, or malicious activity tied to running