Set a Static IP Address with networksetup -setmanual
Persistently configure a manual IPv4 address, netmask and gateway for a macOS network service.
Run `sudo networksetup -setmanual <service> <ip> <mask> <router>` to pin a static IP, and `networksetup -setdhcp <service>` to revert.
01Command
Command
$ sudo networksetup -setmanual Wi-Fi 192.168.1.50 255.255.255.0 192.168.1.1
# Verify:
networksetup -getinfo Wi-Fi02What it does
The macOS way is `networksetup -setmanual`, which writes the same values System Settings stores — unlike `ifconfig`, whose changes vanish on reboot or link renegotiation. Verify with `networksetup -getinfo Wi-Fi`, which prints the current configuration method (Manual or DHCP) and address. The command requires sudo because it alters system-wide network state.
03Risk
!Warning: If you are connected over SSH, double-check the router and mask before applying; an invalid gateway silently breaks routing until you revert.
04Undo
Undo
$ sudo networksetup -setdhcp Wi-Fi05Sources
- networksetup — macOS Command ReferenceEvidence: Documents -setmanual and -setdhcp syntax.
- ifconfig — macOS Command ReferenceEvidence: Notes that ifconfig changes are temporary while networksetup persists them.
Last verified: 2026-09-17 · Category: Network