ipconfig getifaddr en0Your Mac's local IP on Wi-Fi.
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
Addresses and interfaces
ipconfig getifaddr en0local IP ·ifconfig en0full interface details ·networksetup -listallhardwareportswhich enX is which ·ipconfig getpacket en0DHCP lease, router and DNS ·dig +short txt ch whoami.cloudflare @1.1.1.1public IP.DNS
dig +short apple.comlook up a name ·dig -x 8.8.8.8 +shortreverse lookup ·nslookup apple.com 1.1.1.1ask a specific server ·scutil --dnsresolvers in use ·dscacheutil -q host -a name apple.comresolve like apps do ·sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponderflush the cache.Connections and ports
nettop -Plive traffic per process ·lsof -nP -i -sTCP:ESTABLISHEDconnections with remote addresses ·sudo lsof -nP -iTCP:PORT -sTCP:LISTENwho listens on a port ·netstat -an -p tcpall TCP sockets ·nc -vz host porttest a remote port.Reachability and routes
ping -c 10 1.1.1.1reachability and latency ·traceroute -n hostthe route ·netstat -rn -f inetrouting table ·route -n get defaultactive gateway and interface ·arp -alocal devices.Wi-Fi
Option-click the Wi-Fi icon for signal (RSSI) and channel ·sudo wdutil infothe same in Terminal ·networksetup -listpreferredwirelessnetworks en0saved networks ·networksetup -getmacaddress Wi-Fihardware MAC.Speed, firewall and settings
networkQualityspeed and responsiveness ·/usr/libexec/ApplicationFirewall/socketfilterfw --getglobalstatefirewall status ·sudo pfctl -s infopacket filter status ·networksetup -setdnsservers Wi-Fi 1.1.1.1set DNS ·sudo ipconfig set en0 DHCPrenew 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
| Flag | Meaning | Example |
|---|---|---|
| nettop -P | Live traffic per process | nettop -P |
| nettop -m tcp | Only TCP sockets | nettop -m tcp |
| nettop -L 1 -P -J bytes_in,bytes_out | One snapshot as CSV | nettop -L 1 -P -J bytes_in,bytes_out |
| lsof -nP -i | All internet sockets of your processes | sudo lsof -nP -i |
| networksetup -help | Every network setting from the command line | networksetup -help | less |
Common errors
| Error | Cause | Fix |
|---|---|---|
| command not found | The tool isn't part of macOS (mtr, nmap, wget, telnet) | brew install it, or use the built-in alternative. |
| Operation not permitted / no output | Needs root to see other users' processes | Prefix 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.