macOS ipconfig vs ifconfig: Terminal Commands, DHCP Renew

Updated

ipconfig terminal mac

macOS has its own ipconfig in Terminal, but it is not the Windows command. It is a front end to the Mac’s IP configuration agent, so Windows switches such as /all and /renew only print a usage message. Three commands cover most needs: ipconfig getifaddr en0 prints your IPv4 address, ifconfig en0 shows the interface itself, and sudo ipconfig set en0 DHCP renews the DHCP lease. Replace en0 with your interface name; the last section shows how to find it. Your public address, the one websites see, is a different number; how to find your IP address on a Mac covers both.

I ran the read-only commands below on macOS 26.6 Tahoe. The System Settings steps match Apple’s guides for macOS 27 Golden Gate, macOS 26 Tahoe and macOS 15 Sequoia.

Why ipconfig /all does not work on a Mac

Windows ipconfig takes switches. The Mac ipconfig takes subcommands, and anything else gets the usage line back:

$ ipconfig /all
usage: ipconfig <command> <args>
where <command> is one of waitall, getifaddr, ifcount, getoption, getiflist,
getsummary, getpacket, getv6packet, getra, getdhcpduid, getdhcpiaid, set, setverbose

Per Apple’s man page, ipconfig “communicates with the IPConfiguration agent”, the part of macOS that runs the DHCP client and manages addresses on Ethernet and Wi-Fi, and it “should only be used in a test and debug context”. ifconfig is the older BSD tool for the interface itself: its addresses, MAC address and settings.

The Mac version of /flushdns is sudo killall -HUP mDNSResponder, the command in Apple’s DNS cache article. /renew and /release are in the renew section below.

ipconfig /all equivalent on a Mac

There is no single command, and ifconfig -a is not it: it does not show DNS servers, the DHCP server or lease times. I use these:

Windows shows On a Mac Notes
IPv4 address ipconfig getifaddr en0 Prints only the address, or nothing if the interface has none.
Subnet mask ipconfig getoption en0 subnet_mask ifconfig en0 shows it in hex, such as 0xffffff00.
Default gateway ipconfig getoption en0 router route -n get default works however the address was set.
DNS servers scutil --dns networksetup -getdnsservers Wi-Fi says there are none on my Mac, even though DHCP supplies two.
DHCP server ipconfig getoption en0 server_identifier
Lease obtained and expires ipconfig getsummary en0 | grep Lease Prints LeaseStartTime and LeaseExpirationTime.
Physical address ifconfig en0 | grep ether macOS 15 and later use a private Wi-Fi address by default, so networksetup -getmacaddress en0 can show a different, hardware address.
Address, mask, router and MAC at once networksetup -getinfo "Wi-Fi" Takes the service name, not en0. networksetup -listallnetworkservices lists the names.

Read the DHCP lease with ipconfig getpacket

ipconfig getpacket en0 prints the whole DHCP reply the Mac accepted. I read yiaddr (your address), server_identifier, lease_time, subnet_mask, router and domain_name_server. lease_time is in seconds, printed in hex: 0x1c20 is 7200, or two hours. ipconfig getoption en0 lease_time prints it in decimal. On an interface with no DHCP lease, getoption prints nothing and getpacket fails with a message like ipconfig_get_packet(en4) failed: not found.

Renew a DHCP lease on a Mac (ipconfig /renew equivalent)

This is the Mac version of ipconfig /renew:

sudo ipconfig set en0 DHCP

Per the man page, set removes the interface’s current IPv4 service and starts a new one, here DHCP, which fetches the address, mask, router and DNS servers again. Without sudo it fails with “permission denied“. The new service is temporary and lasts until the next network configuration change, so set is for renewing and debugging, not permanent settings. ipconfig getsummary en0 | grep Lease then shows the new lease times.

For the /release half, sudo ipconfig set en0 NONE removes every IPv4 service from the interface. The man page does not say it sends a DHCP release to the server, so read it as “drop the address”. Do not run it over SSH or Screen Sharing on that interface: the session ends with the address.

No Terminal needed:

  1. Choose Apple menu > System Settings, then click Network in the sidebar.
  2. Click your Wi-Fi or Ethernet service, then click Details.
  3. Click TCP/IP (scroll down if you do not see it), then click Renew DHCP Lease.

Apple’s TCP/IP guide says the button appears only when the service uses DHCP. If a renew leaves you with an address starting 169.254, DHCP failed to get an address and macOS gave the interface a link-local one. See MacBook Wi-Fi has no IP address. If the address is fine but the connection keeps dropping, see MacBook Wi-Fi keeps disconnecting.

ifconfig commands in Mac Terminal

ifconfig                   # same as ifconfig -a: every interface
ifconfig en0               # one interface
ifconfig -l -u             # names of the interfaces that are up
ifconfig -f inet:cidr en0  # mask as a prefix, like 192.168.1.20/24, not hex

In the output, inet is the IPv4 address, inet6 the IPv6 addresses and ether the MAC address. The mask is in hex unless you pass -f inet:cidr or -f inet:dotted.

Only the super-user can change an interface with ifconfig, and ipconfig(8) says the IPConfiguration agent manages Wi-Fi and Ethernet addresses, so for a change that has to stick use System Settings or networksetup: sudo networksetup -setmanual "Wi-Fi" 192.168.1.50 255.255.255.0 192.168.1.1 sets a static address and sudo networksetup -setdhcp "Wi-Fi" goes back to DHCP. Avoid sudo ifconfig en0 down as a stand-in for a release: it only marks the interface down, and over SSH it cuts you off with no way to type up.

Linux guides that use ip addr, ip route or ip neigh fail on a Mac with “command not found”. The Mac counterparts are ifconfig, netstat -rn -f inet and arp -an, and more are in macOS terminal commands.

What en0, en1 and utun mean on a Mac

networksetup -listallhardwareports pairs each interface name with its hardware port. On my MacBook Pro it lists Wi-Fi as en0, the Thunderbolt ports as en1 to en3 and Thunderbolt Bridge as bridge0. Do not assume en0 is Wi-Fi on yours. route -n get default shows the interface: your traffic uses.

  • en0, en1 and so on: Wi-Fi, Ethernet and Thunderbolt ports.
  • lo0: the software loopback interface, 127.0.0.1.
  • utun0, utun1 and so on: virtual tunnel interfaces (“user tunnel” in Apple’s kernel source) for software such as VPN clients. Mine shows utun0 to utun3 with no VPN connected.

ipconfig only knows the interfaces its agent manages. For any other name, getpacket fails with ipconfig_get_packet(en1) failed: interface doesn't exist. ipconfig getiflist lists the names it accepts; ifconfig -l lists every interface.

Photo of author
Sudhir P. founded HeatWare.com in 1999 and has built and operated it full-stack ever since; it is now used by more than 88,000 people. He writes here about the PostgreSQL, MySQL, Linux and DevOps work that keeps it running. Articles are rewritten only after the commands in them have actually been run, and the verification scripts are published alongside them so anyone can check the claims. Reach him at blog@heatware.net.