LightAtom

Mac Network Commands: The Cheat Sheet

The network commands built into macOS, grouped by task, each with the one line you'll actually use. Tested on macOS 15 Sequoia.

ipconfig getifaddr en0

Your Mac's local IP on Wi-Fi.

beginner10 minNeeds: Terminal

When to use it

Keep this page open while troubleshooting. Every command here ships with macOS; nothing needs installing. Commands marked sudo need an administrator password.

Steps

  1. Addresses and interfaces

    ipconfig getifaddr en0 local IP · ifconfig en0 full interface details · networksetup -listallhardwareports which enX is which · ipconfig getpacket en0 DHCP lease, router and DNS · dig +short txt ch whoami.cloudflare @1.1.1.1 public IP.
  2. DNS

    dig +short apple.com look up a name · dig -x 8.8.8.8 +short reverse lookup · nslookup apple.com 1.1.1.1 ask a specific server · scutil --dns resolvers in use · dscacheutil -q host -a name apple.com resolve like apps do · sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder flush the cache.
  3. Connections and ports

    nettop -P live traffic per process · lsof -nP -i -sTCP:ESTABLISHED connections with remote addresses · sudo lsof -nP -iTCP:PORT -sTCP:LISTEN who listens on a port · netstat -an -p tcp all TCP sockets · nc -vz host port test a remote port.
  4. Reachability and routes

    ping -c 10 1.1.1.1 reachability and latency · traceroute -n host the route · netstat -rn -f inet routing table · route -n get default active gateway and interface · arp -a local devices.
  5. Wi-Fi

    Option-click the Wi-Fi icon for signal (RSSI) and channel · sudo wdutil info the same in Terminal · networksetup -listpreferredwirelessnetworks en0 saved networks · networksetup -getmacaddress Wi-Fi hardware MAC.
  6. Speed, firewall and settings

    networkQuality speed and responsiveness · /usr/libexec/ApplicationFirewall/socketfilterfw --getglobalstate firewall status · sudo pfctl -s info packet filter status · networksetup -setdnsservers Wi-Fi 1.1.1.1 set DNS · sudo ipconfig set en0 DHCP renew the lease.

Output explained

Each command has its own guide with real output explained; follow the related links. A few things that trip people up:

  • en0 is Wi-Fi on most Macs, but not all. Check with networksetup -listallhardwareports.
  • macOS ipconfig ≠ Windows ipconfig. The Mac version handles DHCP and interface queries; ifconfig shows addresses.
  • netstat on macOS doesn't show processes. Use lsof for that.
  • Network Utility is gone: Apple retired it starting with macOS Big Sur. ping, traceroute, whois, lsof and netstat cover everything it did.
  • Not built in: mtr, nmap, wget, telnet. Install them with Homebrew, or use traceroute, nc and curl.

Options and variations

FlagMeaningExample
nettop -PLive traffic per processnettop -P
nettop -m tcpOnly TCP socketsnettop -m tcp
nettop -L 1 -P -J bytes_in,bytes_outOne snapshot as CSVnettop -L 1 -P -J bytes_in,bytes_out
lsof -nP -iAll internet sockets of your processessudo lsof -nP -i
networksetup -helpEvery network setting from the command linenetworksetup -help | less

Common errors

ErrorCauseFix
command not foundThe tool isn't part of macOS (mtr, nmap, wget, telnet)brew install it, or use the built-in alternative.
Operation not permitted / no outputNeeds root to see other users' processesPrefix with sudo.

Do it in the app

LightAtom puts the most-used of these on one screen: live per-app connections with domains and bytes (nettop + lsof + DNS), every open port (Ports), and Traceroute on a map.

Download the cheat sheet (PDF)

Frequently asked questions

What network commands are built into macOS?

ping, traceroute, dig, nslookup, host, whois, curl, nc, lsof, netstat, nettop, arp, ifconfig, ipconfig, networksetup, scutil, route, tcpdump, pfctl, networkQuality and wdutil, among others.

What replaced Network Utility on Mac?

Terminal commands: ping, traceroute, whois, lsof, netstat and nc do what Network Utility's tabs did. Apple retired the app starting with macOS Big Sur.

What is the nettop command?

A built-in live view of network traffic per process and connection, like top for the network. nettop -P shows one row per process; press q to quit.

Do I need sudo for these commands?

Most work without it. You need sudo to see other users' and root processes (lsof), capture packets (tcpdump), flush DNS, and change firewall or pf settings.

LightAtom team

The people who build LightAtom, a network monitor for macOS.