ipconfig.co.uk

macOS: ifconfig, ipconfig, networksetup and scutil

macOS is a BSD underneath, so it has ifconfig. It also has a command called ipconfig that has nothing to do with the Windows one, a configuration tool called networksetup that mirrors System Settings, and scutil for the system configuration database. Knowing which one to reach for saves a lot of time.

Which tool for which job

TaskCommand
See my IPv4 addressipconfig getifaddr en0
See everything about an interfaceifconfig en0
See the address, mask, router and MAC in a readable formnetworksetup -getinfo "Wi-Fi"
See the default gatewayroute -n get default or netstat -rn | grep default
See DNS servers actually in usescutil --dns
See DNS servers configured for a servicenetworksetup -getdnsservers "Wi-Fi"
See the DHCP lease detailsipconfig getpacket en0
See the Wi-Fi network name and signalwdutil info (macOS 14+, needs sudo) or networksetup -getairportnetwork en0
Renew the DHCP leasesudo ipconfig set en0 DHCP
Set a static IPnetworksetup -setmanual "Wi-Fi" 192.168.1.50 255.255.255.0 192.168.1.1
Set DNS serversnetworksetup -setdnsservers "Wi-Fi" 1.1.1.1 1.0.0.1
Flush DNSsudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
Turn Wi-Fi off / onnetworksetup -setairportpower en0 off / on
See which interface is en0networksetup -listallhardwareports
Public IPcurl ipconfig.co.uk/ip

Interface names on a Mac

macOS numbers interfaces by driver, not by function, and the numbering depends on the hardware. Use networksetup -listallhardwareports to map names to ports:

macOS · Terminal
networksetup -listallhardwareports
Output
Hardware Port: Ethernet Adapter (en5)
Device: en5
Ethernet Address: 00:e0:4c:68:1a:2b

Hardware Port: Wi-Fi
Device: en0
Ethernet Address: f0:18:98:3a:2b:1c

Hardware Port: Thunderbolt 1
Device: en1
Ethernet Address: 36:8a:2f:11:22:01

Hardware Port: Thunderbolt Bridge
Device: bridge0
Ethernet Address: 36:8a:2f:11:22:01

VLAN Configurations
===================
NameWhat it is
en0Wi-Fi on every Mac with built-in Wi-Fi made since about 2010. On older Macs with built-in Ethernet, en0 was Ethernet and en1 Wi-Fi. On the Mac mini and Mac Studio en0 is Ethernet.
en1en9Thunderbolt ports (each gets a virtual interface for IP-over-Thunderbolt), USB Ethernet adapters, docks, iPhone USB tethering
lo0Loopback
bridge0Thunderbolt Bridge; groups the Thunderbolt interfaces
awdl0Apple Wireless Direct Link: AirDrop, AirPlay, Sidecar, Continuity
llw0Low-latency WLAN, paired with awdl0
ap1The Wi-Fi access point interface used for Internet Sharing and Personal Hotspot
utun0utun9Tunnels: VPN apps, iCloud Private Relay, Tailscale. Two or three exist even with no VPN installed.
gif0, stf0Generic and 6to4 tunnel placeholders; ignore
anpi0, anpi1Apple internal (debug/USB-C) interfaces on Apple silicon; ignore
vmenet0, bridge100Created by VMware Fusion, Parallels, Docker Desktop or UTM

The names in networksetup commands are network service names ("Wi-Fi", "Ethernet", "USB 10/100/1000 LAN", "Thunderbolt Bridge"), not device names. networksetup -listallnetworkservices lists them; an asterisk marks a disabled service.

The macOS ipconfig command

/usr/sbin/ipconfig controls the macOS IP configuration agent (configd's IPConfiguration plugin). It has no relationship to Windows ipconfig beyond the name. It is the most convenient tool for one-line answers in scripts.

Output
usage: ipconfig <command> <args>
where <command> is one of waitall, getifaddr, ifcount, getoption, getpacket, getv6packet,
       getra, getsummary, getdhcpduid, getdhcpiaid, set, setverbose
CommandWhat it does
ipconfig getifaddr en0Print the IPv4 address of en0, nothing else. Exit status 1 and no output if there is none.
ipconfig getsummary en0Everything IPConfiguration knows about en0: DHCP lease, router, DNS, IPv6 state, Wi-Fi SSID (macOS 12+)
ipconfig getpacket en0Decode the last DHCP ACK: server, lease time, all options. Empty if the interface is static.
ipconfig getv6packet en0The same for DHCPv6
ipconfig getra en0The last IPv6 router advertisement received (macOS 13+)
ipconfig getoption en0 routerOne DHCP option by name or number: router, domain_name_server, subnet_mask, lease_time, domain_name, server_identifier, or a number such as 42
ipconfig ifcountNumber of interfaces
ipconfig getdhcpduid / getdhcpiaid en0DHCPv6 identifiers
ipconfig waitallBlock until all interfaces have finished configuring; used by startup scripts
sudo ipconfig set en0 DHCPSwitch to DHCP, which also renews the lease
sudo ipconfig set en0 MANUAL 192.168.1.50 255.255.255.0Static address (temporary; the setting in System Settings still says DHCP)
sudo ipconfig set en0 BOOTPUse BOOTP
sudo ipconfig set en0 NONERemove IPv4 configuration
sudo ipconfig set en0 AUTOMATIC-V6 / MANUAL-V6 addr prefixlen / 6TO4 / LINKLOCAL-V6 / NONE-V6IPv6 modes
sudo ipconfig setverbose 1Verbose logging from IPConfiguration to the unified log
macOS · Terminal
ipconfig getifaddr en0
ipconfig getoption en0 router
ipconfig getoption en0 domain_name_server
ipconfig getoption en0 lease_time
Output
192.168.1.23
192.168.1.1
192.168.1.1
86400
macOS · Terminal
ipconfig getpacket en0
Output
op = BOOTREPLY
htype = 1
flags = 0
hlen = 6
hops = 0
xid = 0x6a1b3c4d
secs = 0
ciaddr = 192.168.1.23
yiaddr = 192.168.1.23
siaddr = 0.0.0.0
giaddr = 0.0.0.0
chaddr = f0:18:98:3a:2b:1c
sname =
file =
options:
Options count is 7
dhcp_message_type (uint8): ACK 0x5
server_identifier (ip): 192.168.1.1
lease_time (uint32): 0x15180
subnet_mask (ip): 255.255.255.0
router (ip_mult): {192.168.1.1}
domain_name_server (ip_mult): {192.168.1.1}
domain_name (string): home

The set … DHCP form is the command-line equivalent of the Renew DHCP Lease button in System Settings, and it is the fix for a Mac stuck on a 169.254 self-assigned address once the underlying problem is solved.

ifconfig on macOS

Covered in full on the ifconfig page. The macOS-specific points:

  • Netmasks print in hex (0xffffff00 = /24).
  • ifconfig -l lists names; ifconfig -u shows only interfaces that are up; ifconfig -v en0 is verbose; ifconfig -L adds IPv6 lifetimes.
  • Address changes made with ifconfig are overwritten as soon as the DHCP client or configd next runs, which can be seconds. Use networksetup or ipconfig set for anything you want to survive.
  • sudo ifconfig en0 down on Wi-Fi disconnects it; up reconnects.
  • To change the Wi-Fi MAC: sudo ifconfig en0 ether 02:xx:xx:xx:xx:xx while disassociated. macOS 15 and later can randomise it per network in System Settings, which is normally the better choice.

networksetup

networksetup is the command-line face of the Network pane in System Settings. Its changes are persistent and per network service and location. Most setter commands need sudo; getters do not.

Viewing

macOS · Terminal
networksetup -listallnetworkservices
networksetup -listallhardwareports
networksetup -listnetworkserviceorder
networksetup -getinfo "Wi-Fi"
networksetup -getdnsservers "Wi-Fi"
networksetup -getsearchdomains "Wi-Fi"
networksetup -getmacaddress en0
networksetup -getMTU en0
networksetup -getairportpower en0
networksetup -getairportnetwork en0
networksetup -getwebproxy "Wi-Fi"
networksetup -getcurrentlocation
networksetup -listlocations
Output
$ networksetup -getinfo "Wi-Fi"
DHCP Configuration
IP address: 192.168.1.23
Subnet mask: 255.255.255.0
Router: 192.168.1.1
Client ID:
IPv6: Automatic
IPv6 IP address: none
IPv6 Router: none
Wi-Fi ID: f0:18:98:3a:2b:1c

-getdnsservers prints There aren't any DNS Servers set on Wi-Fi. when DNS comes from DHCP; that is not an error. To see the servers actually in use, run scutil --dns. On macOS 14 and later -getairportnetwork may print You are not associated with an AirPort network for privacy reasons even when connected; use sudo wdutil info or ipconfig getsummary en0 | grep SSID instead.

Setting a static IP

macOS · Terminal
sudo networksetup -setmanual "Wi-Fi" 192.168.1.50 255.255.255.0 192.168.1.1
# back to DHCP
sudo networksetup -setdhcp "Wi-Fi"
# DHCP with a manual address (DHCP for router/DNS, fixed IP)
sudo networksetup -setmanualwithdhcprouter "Wi-Fi" 192.168.1.50
# DHCP with a client ID
sudo networksetup -setdhcp "Wi-Fi" myclientid

DNS and search domains

macOS · Terminal
sudo networksetup -setdnsservers "Wi-Fi" 1.1.1.1 1.0.0.1
sudo networksetup -setdnsservers "Wi-Fi" Empty        # back to DHCP-supplied
sudo networksetup -setsearchdomains "Wi-Fi" home.arpa
sudo networksetup -setsearchdomains "Wi-Fi" Empty

IPv6

macOS · Terminal
networksetup -getinfo "Wi-Fi" | grep IPv6
sudo networksetup -setv6automatic "Wi-Fi"
sudo networksetup -setv6linklocal "Wi-Fi"      # effectively disables global IPv6
sudo networksetup -setv6off "Wi-Fi"            # newer versions
sudo networksetup -setv6manual "Wi-Fi" 2001:db8::50 64 2001:db8::1

Wi-Fi

macOS · Terminal
networksetup -setairportpower en0 off
networksetup -setairportpower en0 on
networksetup -setairportnetwork en0 "MySSID" "password"
networksetup -listpreferredwirelessnetworks en0
sudo networksetup -removepreferredwirelessnetwork en0 "OldSSID"
sudo networksetup -addpreferredwirelessnetworkatindex en0 "MySSID" 0 WPA2 "password"

Other useful setters

macOS · Terminal
sudo networksetup -setMTU en0 1400
sudo networksetup -setnetworkserviceenabled "Thunderbolt Bridge" off
sudo networksetup -ordernetworkservices "Ethernet" "Wi-Fi" "Thunderbolt Bridge"
sudo networksetup -setwebproxy "Wi-Fi" proxy.example.com 8080
sudo networksetup -setwebproxystate "Wi-Fi" off
sudo networksetup -createlocation Office populate
sudo networksetup -switchtolocation Office
sudo networksetup -setcomputername "my-mac"

networksetup -help lists around 100 commands; networksetup -printcommands gives a compact list.

scutil

scutil reads the System Configuration dynamic store, which is the source of truth for what the system is actually using right now.

macOS · Terminal
scutil --dns          # resolver configuration, per interface and scoped
scutil --nwi          # network information: primary interface, reachability
scutil --proxy        # proxy settings
scutil --get HostName
scutil --get LocalHostName
scutil --get ComputerName
sudo scutil --set HostName my-mac.home.arpa
sudo scutil --set LocalHostName my-mac
sudo scutil --set ComputerName "My Mac"
Output
$ scutil --nwi
Network information

IPv4 network interface information
     en0 : flags      : 0x5 (IPv4,DNS)
           address    : 192.168.1.23
           reach      : 0x00000002 (Reachable)

   REACH : flags 0x00000002 (Reachable)

IPv6 network interface information
   No IPv6 states found

   REACH : flags 0x00000000 (Not Reachable)

Network interfaces: en0

scutil --dns is the only reliable way to see DNS on a Mac, because macOS has per-interface, per-domain and VPN-scoped resolvers that networksetup does not show. Look at resolver #1 for the servers used by default. There is no /etc/resolv.conf worth reading; the file exists for BSD compatibility and is often stale.

Interactive mode lets you walk the store: scutil then list, then show State:/Network/Global/IPv4 to see the primary interface and router, or show State:/Network/Service/<id>/DHCP for lease details.

Routing and ARP

macOS · Terminal
route -n get default          # default gateway and interface
netstat -rn                   # full routing table
netstat -rn -f inet           # IPv4 only
sudo route add -net 10.0.0.0/8 192.168.1.254
sudo route delete -net 10.0.0.0/8
sudo route flush              # dangerous: removes all routes
arp -a                        # ARP cache
arp -an                       # without name resolution
sudo arp -d -a                # clear the ARP cache
ndp -an                       # IPv6 neighbour cache
Output
$ route -n get default
   route to: default
destination: default
       mask: default
    gateway: 192.168.1.1
  interface: en0
      flags: <UP,GATEWAY,DONE,STATIC,PRCLO,GLOBAL>
 recvpipe  sendpipe  ssthresh  rtt,msec    rttvar  hopcount      mtu     expire
       0         0         0         0         0         0      1500         0

Note the BSD route syntax (route add -net, no gw keyword) differs from Linux net-tools.

DNS on macOS

macOS · Terminal
# flush the resolver cache
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
# look something up the way the system would (honours scoped resolvers, hosts file, mDNS)
dscacheutil -q host -a name example.com
# look something up directly with DNS
dig example.com
nslookup example.com
host example.com
# DNS-over-HTTPS/TLS status (macOS 11+)
scutil --dns | grep -i -A2 'flags'

The two-command flush is needed because dscacheutil clears the Directory Services cache while mDNSResponder holds the actual DNS cache; the HUP tells it to drop everything. Older versions used discoveryutil (10.10) or just killall -HUP mDNSResponder. All versions →

Wi-Fi diagnostics

macOS · Terminal
sudo wdutil info                        # macOS 14+: SSID, BSSID, RSSI, channel, security, IP
sudo wdutil diagnose                    # collect a full diagnostics bundle to /private/tmp
system_profiler SPAirPortDataType       # hardware and current network details
networksetup -getairportnetwork en0
ipconfig getsummary en0 | grep -E 'SSID|BSSID|Security'

The old airport binary in /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/ (airport -I, airport -s for scanning) was removed in macOS 14.4. wdutil and system_profiler replace it. Holding Option while clicking the Wi-Fi menu still shows the same information graphically and offers Open Wireless Diagnostics.

Other macOS commands

CommandPurpose
hostnameThe current hostname (may differ from ComputerName)
netstat -an | grep LISTENListening ports
lsof -i -P -n | grep LISTENListening ports with process names (the macOS equivalent of ss -tulpn)
lsof -i :443What is using a port
traceroute example.comPath to a host; traceroute6 for IPv6
ping -c 4 example.comReachability; ping6 for IPv6
nc -zv host 443Test a TCP port
sudo tcpdump -i en0 -n port 53Packet capture
sysctl net.inet.ip.forwardingIs IP forwarding on
sudo sysctl -w net.inet.ip.forwarding=1Enable forwarding (until reboot)
sudo pfctl -s rulesFirewall (pf) rules
/System/Library/PrivateFrameworks/SystemAdministration.framework/Resources/activateSettings -uApply settings changed by some scripts (rarely needed)
sudo launchctl kickstart -k system/com.apple.mDNSResponderRestart mDNSResponder
sudo ifconfig en0 down; sudo ifconfig en0 upBounce an interface

Full network reset on macOS

There is no single "network reset" button as in Windows. The closest equivalent, for a Mac whose networking is thoroughly confused:

  1. Turn Wi-Fi off, wait ten seconds, turn it on. Renew the DHCP lease: sudo ipconfig set en0 DHCP.
  2. Flush DNS: sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder.
  3. Forget and re-join the Wi-Fi network: sudo networksetup -removepreferredwirelessnetwork en0 "SSID", then join again.
  4. Remove the network service and re-add it: System Settings › Network › … › Delete Service, then Add Service.
  5. Move the preference files aside and reboot: sudo mkdir ~/Desktop/netprefs && sudo mv /Library/Preferences/SystemConfiguration/{NetworkInterfaces.plist,preferences.plist,com.apple.airport.preferences.plist,com.apple.network.eapolclient.configuration.plist} ~/Desktop/netprefs/. macOS recreates them at boot. This is the nuclear option and forgets every saved network and location.
  6. Reset the SMC or NVRAM on Intel Macs; on Apple silicon just restart.

Related pages

Last reviewed . Command syntax verified against Windows 11, Ubuntu 24.04, macOS 15 and FreeBSD 14 unless noted otherwise.

Spotted a mistake or a switch we have missed? Every page on this site is written to be checked against real output, so please test on your own machine and compare.