How to Check Your Mac’s Network Settings in Terminal (2026 Guide)

Ben Stockton
·
13 min read

Switching to Mac is reader-supported. We may earn a commission when you buy through links on our site. Learn more.

Your Mac says it’s connected to Wi-Fi, but pages won’t load. Or a router setup screen wants your IP address, and you’d rather not click through System Settings > Network looking for it. Terminal can answer both in a single line, and nearly everything below only reads information without changing it.

I came to the Mac from Windows, where ipconfig /all was muscle memory. macOS has its own set of tools, and a few of them behave differently from their Windows namesakes. Once you know which command answers which question, Terminal is the quickest way to see what your network is doing. You can experiment without much risk.

Terminal window on macOS showing the output of networksetup -listallhardwareports followed by ipconfig getifaddr en0, with the Wi-Fi hardware port and its en0 device name highlighted

Before you start

  • Open Terminal: Press Cmd + Space, type Terminal, and press Return. You can also open it from Finder > Applications > Utilities > Terminal.
  • Check your macOS version: These steps are written for macOS Ventura (macOS 13) and later, which use System Settings. macOS Monterey and earlier use System Preferences, and some network and firewall options are in different places.
  • Know what needs admin rights: Most commands here only read information. Commands that start with sudo ask for your administrator password. I’ll warn you before any command that changes a setting.
  • Watch what you share: Output can include your MAC address, IP addresses, and Wi-Fi network names. Blank those out before you paste anything into a forum or a support chat.

Step 1: Find your network interface name

Many commands below need an interface name such as en0. On most MacBooks, en0 is Wi-Fi, but don’t assume that. Desktop Macs, a USB-C Ethernet adapter, or a Thunderbolt dock with its own network port can all change the numbering.

Run this first:

networksetup -listallhardwareports

You’ll get a list of Hardware Port names (Wi-Fi, Ethernet, Thunderbolt Bridge, and so on), each with a Device name like en0 or en1. Note the device that matches the connection you care about, then use it wherever you see en0 below.

Using networksetup

networksetup is Apple’s own tool for macOS network services, and it’s the best place to start. It works with service names you’ll recognize from System Settings > Network, such as “Wi-Fi” and “Ethernet,” rather than raw interface names.

Type networksetup -help to see every available option. These are the ones I use most:

networksetup -getcomputername
networksetup -listallnetworkservices
networksetup -getinfo Wi-Fi
networksetup -getdnsservers Wi-Fi
networksetup -getcurrentlocation
networksetup -listlocations
  • -getcomputername shows the name your Mac uses on the network.
  • -listallnetworkservices lists every configured service. Disabled ones have an asterisk.
  • -getinfo Wi-Fi shows the IP address, subnet mask, router, and Wi-Fi hardware address for that service.
  • -getdnsservers Wi-Fi shows DNS servers you’ve set manually. If it reports none, your Mac is using whatever the router hands out.
  • -getcurrentlocation and -listlocations show your network locations, which still exist even though System Settings gives them far less room than the old System Preferences pane did.

To see the Wi-Fi network you’re joined to, use your Wi-Fi device name:

networksetup -getairportnetwork en0

Checking proxy settings is useful when one app connects and another doesn’t:

networksetup -getwebproxy Wi-Fi
networksetup -getsecurewebproxy Wi-Fi
networksetup -getsocksfirewallproxy Wi-Fi

Service names have to match the output of -listallnetworkservices exactly. On some Macs, Ethernet appears as USB 10/100/1000 LAN or something similar, so wrap names with spaces in quotes.

Terminal window on macOS showing networksetup -listallnetworkservices output followed by networksetup -getinfo Wi-Fi, with the IP address and Router lines highlighted

networksetup can also change DNS servers, proxies, locations, and service order. I’d skip that unless you’re scripting a setup across several Macs. A typo can knock you offline, and System Settings > Network shows you what you’re changing before you commit.

Using ipconfig

If you’re coming from Windows, macOS’s ipconfig will feel cramped. It doesn’t dump everything like ipconfig /all. It’s good at answering one specific question at a time.

Get the IPv4 address on an interface:

ipconfig getifaddr en0

Get the DNS server your router assigned through DHCP:

ipconfig getoption en0 domain_name_server

If getifaddr returns nothing, that interface either isn’t connected or isn’t the one you’re using. Go back to Step 1 and check the device name.

Terminal window on macOS showing ipconfig getifaddr en0 returning a 192.168.x.x address, followed by ipconfig getoption en0 domain_name_server returning a DNS server address

Using ifconfig

ifconfig gives you the lower-level detail. Run it on its own and you’ll see every interface on your Mac, including IP addresses, MAC addresses, and whether each one is active.

ifconfig
ifconfig en0

The full output is long. To list only IPv4 addresses:

ifconfig | grep "inet "

You’ll almost always see 127.0.0.1 in that list. That’s the loopback address, your Mac talking to itself, and it has nothing to do with your actual network.

For IPv6 addresses on a specific interface:

ifconfig en0 | grep inet6

The ether line in ifconfig en0 shows the MAC address for that interface. If Private Wi-Fi Address is on for a network, the MAC address shown there can differ from your Mac’s hardware address, so don’t panic if it doesn’t match the sticker or the router’s records.

Terminal window on macOS showing ifconfig en0 output with the ether (MAC address), inet (IPv4), and inet6 lines highlighted and the status: active line visible

Which address is which?

Seeing several addresses is normal. This table sorts them out:

Address typeWhat it looks likeWhere it comes fromHow to find it
Local (private) IPv4192.168.x.x, 10.x.x.x, or 172.16.x.x to 172.31.x.xYour routeripconfig getifaddr en0
Public IPVariesYour ISP or VPN providercurl -4 ifconfig.me
IPv6Long colon-separated hexRouter or ISP, often alongside IPv4ifconfig en0 | grep inet6
Loopback127.0.0.1Your Mac itselfIgnore it for troubleshooting
MAC addressaa:bb:cc:dd:ee:ffNetwork hardware, possibly randomized per Wi-Fi networkifconfig en0 (the ether line)

You may also spot extra interfaces from VPN apps, virtual machines, or containers. Those are fine too.

Find your public IP address

Your Mac only knows its local address. Your router uses NAT to share one public address across your whole home, so the only way to see that public address is to ask a server on the internet:

curl -4 ifconfig.me

For IPv6:

curl -6 ifconfig.me

If that service is down, curl -4 icanhazip.com and curl -4 api.ipify.org do the same job.

Two things to keep in mind. These services see your IP address when you ask, since that’s how they answer. And if a VPN or proxy is active, you’ll get the VPN’s address, which is usually the whole point of the VPN.

Check your router and routing

Your default gateway is usually your router. To find it:

route -n get default

Look for the gateway: line. For IPv6, use route -n get -inet6 default. The full routing table is available with netstat -rn.

When Wi-Fi, Ethernet, and a VPN are all active at once, this command shows which one macOS is actually using:

scutil --nwi

It lists interfaces in priority order, and it’s my first stop when traffic goes somewhere unexpected.

Inspect DNS settings

On macOS, /etc/resolv.conf doesn’t give you the full picture. macOS can use different DNS servers for different domains, like a work VPN that resolves internal names while everything else goes through your home router. To see every resolver macOS knows about:

scutil --dns

To test a lookup:

dig example.com
dig +short example.com
dig @1.1.1.1 example.com
host example.com

dig +short trims the output to the answer. dig @1.1.1.1 asks a specific DNS server directly, which is a quick way to tell whether your router’s DNS is the problem.

If a site recently moved and your Mac keeps resolving the old address, flush the DNS cache:

sudo dscacheutil -flushcache
sudo killall -HUP mDNSResponder

This clears cached answers. It won’t fix wrong DNS settings, a misbehaving router, a VPN conflict, or a site that’s actually down, so don’t run it on repeat hoping for a different result.

Using ping

ping doesn’t show network settings, but it tells you whether your Mac can reach another device. On macOS, ping runs until you stop it with Ctrl + C, so I add -c 4 to send four packets and quit:

ping -c 4 example.com

To ping your router without looking up its address first:

ping -c 4 "$(route -n get default | awk '/gateway:/{print $2}')"
Terminal window on macOS showing ping -c 4 example.com with four reply lines, the round-trip times, and the summary line reading 0.0% packet loss highlighted

Pair it with traceroute example.com to see each hop along the way, and curl -I https://example.com to test an actual web connection. Read the results like this:

  • Router ping fails: The problem is local, likely Wi-Fi, an Ethernet cable, DHCP, or the router itself.
  • Router ping works, but pinging a website fails: Suspect DNS or filtering.
  • DNS works, but curl fails: Look at proxies, the firewall, certificates, or the app itself.
  • Only ping fails: That alone proves nothing. Plenty of servers block ping while serving web pages fine.

Apple’s platform deployment guide points to the same set of tools (ifconfig, ping, traceroute, scutil, and networksetup) for testing connections, so you’re in good company.

Using netstat

netstat shows active connections and network statistics. The macOS version shares a name with the Windows and Linux tools, but some flags differ, so check man netstat before you trust a command copied from a Linux guide.

netstat -an
netstat -I en0
netstat -rn
netstat -s
netstat -i
  • -an lists all connections and listening sockets with numeric addresses.
  • -I en0 shows traffic counts for one interface.
  • -rn prints the routing table.
  • -s and -i show protocol and interface statistics. Climbing error counts here can point to a flaky cable or adapter.
Terminal window on macOS showing netstat -an output with ESTABLISHED and LISTEN connection states visible in the state column

Using lsof

netstat shows connections. lsof shows which app owns them. That’s the macOS answer to netstat -b on Windows.

List everything listening for incoming connections:

sudo lsof -nP -iTCP -sTCP:LISTEN
sudo lsof -nP -iUDP

Find which app is holding a specific port:

sudo lsof -nP -i :80

The -n and -P flags skip name lookups, which makes the output appear much faster. Without sudo, you’ll only see your own processes, which explains the “where did half my apps go?” moment. Run man lsof for the full option list.

Terminal window on macOS showing sudo lsof -nP -iTCP -sTCP:LISTEN output with the COMMAND, PID, and NAME columns visible and a process listening on a local port highlighted

If a Linux guide tells you to run ss or ip, those aren’t included with macOS. Use lsof, netstat, ifconfig, and networksetup instead.

Using arp

arp -a lists IP and MAC addresses for devices your Mac has recently communicated with on your local network:

arp -a

This is a cache, so it only shows devices your Mac has heard from lately. A smart plug that’s been idle may not appear. Ping a device’s IP address and run arp -a again, and it’ll usually show up.

Terminal window on macOS showing arp -a output listing several local devices with 192.168.x.x IP addresses, MAC addresses, and the en0 interface

Check your firewall

In current macOS, Apple documents the firewall at System Settings > Network > Firewall, where you can turn it on and click Options to manage per-app rules (Apple: Change Firewall settings on Mac). Apple’s security documentation also describes firewall settings under Privacy & Security, so the exact location can vary by macOS version or by whether your Mac is managed by an employer.

From Terminal, you can check the same settings without opening anything:

/usr/libexec/ApplicationFirewall/socketfilterfw --getglobalstate
/usr/libexec/ApplicationFirewall/socketfilterfw --listapps
/usr/libexec/ApplicationFirewall/socketfilterfw --getstealthmode
/usr/libexec/ApplicationFirewall/socketfilterfw --getallowsigned

These cover the macOS application firewall, which handles incoming connections. It supports blocking incoming connections, allowing signed software automatically, per-app rules, and stealth mode, which stops your Mac from responding to some probing (Apple Platform Security: Firewall). It doesn’t block outgoing traffic, and it can’t see rules on your router, VPN app, or any security software your company installed.

Get a rough location from your IP

Terminal can’t find your physical location from your local IP address. An external lookup gives you an estimate:

curl https://ipinfo.io/json
curl https://ipinfo.io/country

Treat the result as approximate. It might show your ISP’s registered city, your VPN server, or a mobile carrier’s gateway in another state. For precise location, macOS uses Location Services, which you can review at System Settings > Privacy & Security > Location Services.

More tools worth knowing

  • Hardware details: system_profiler SPNetworkDataType and system_profiler SPAirPortDataType produce long reports on your network hardware and Wi-Fi. They’re useful to paste into a support ticket (after scrubbing identifying details).
  • Wireless Diagnostics: For stubborn Wi-Fi problems, hold Option and click the Wi-Fi icon in the menu bar, then choose the diagnostics option. It’s also at Finder > Applications > Utilities > Wireless Diagnostics. The menu wording varies by macOS version, but it can collect logs that ping never will.
  • System Settings: For a quick look at your connection status, System Settings > Network is often clearer than Terminal (Apple: Network settings on Mac). Terminal wins when you need repeatable checks, remote help, or scripts.
  • Homebrew extras: Tools like mtr, nmap, and iproute2mac are available through Homebrew. They’re optional and change your system, and their results won’t always match Apple’s tools. Only scan networks you own or manage, since port scanning someone else’s network can break rules or laws.

Troubleshooting common gotchas

en0 shows no address

Your active connection is on a different interface. Run networksetup -listallhardwareports, find the right device name, and use that instead.

Terminal says “permission denied”

Add sudo in front of the command and enter your admin password. If a command still fails, macOS privacy protections may be blocking it. Don’t hand Full Disk Access to Terminal just to see if that fixes it. Grant permissions only when you know why a command needs them.

My public IP doesn’t match my local IP

That’s how it’s supposed to work. Your router gives your Mac a private address and shows a single public address to the internet. A VPN, proxy, or iPhone hotspot changes the public address again.

scutil --dns shows several DNS servers

macOS keeps separate resolvers for your regular network, VPNs, and specific domains. Which one answers depends on the domain you’re looking up and the active interface.

Output looks different after a macOS update

Apple tweaks output formats and interface names between releases without removing the tools. If you’ve written scripts that parse this output, test them after each major update.

Putting it to work

So far so good: with these commands, you can see exactly how your Mac is connected and spot what needs changing. Sometimes that’s practical, like checking which MAC address a guest Wi-Fi network’s filtering sees. Other times, it’s diagnosis. If your router ping keeps failing on a single access point, the problem may be your setup, and a mesh Wi-Fi router can help in a large home.

These tools are especially useful if your Mac drops its WiFi connection regularly, since you can tell whether the link, DNS, or the router is failing. If your Mac is sluggish in general, maintenance apps like OnyX for Mac can help you get back up and running.

For everyday checks, I still open System Settings first. But when the settings pane says everything’s fine and nothing loads, Terminal is the better choice. It’s worth trying before you call your ISP or restart the router.