Set DNS Servers per Network Service with networksetup

Use networksetup -setdnsservers to set, inspect, or reset DNS servers for any macOS network service.

macOSconfigurationnetworksetupDNSLow risk
Run `networksetup -setdnsservers <service> <ip>...` to set DNS, or pass the literal word `Empty` to return to DHCP-provided DNS.

01Command

Command
$ networksetup -setdnsservers Wi-Fi 1.1.1.1 8.8.8.8
# Revert to DHCP-provided DNS:
networksetup -setdnsservers Wi-Fi "Empty"

02What it does

Unlike a global /etc/resolv.conf edit, macOS stores DNS per network service (Wi-Fi, Ethernet, etc.). `networksetup -setdnsservers` writes those System Settings entries directly and takes effect immediately — no reboot needed. Call `networksetup -listallnetworkservices` first to get the exact service name, and note the setting is per-user-location, so VPN or location changes can surface different values.

03Risk

RiskLow risk
!Warning: Passing the word `Empty` literally clears the list; forgetting it (leaving no addresses) prints usage instead of clearing anything.

04Undo

Undo
$ networksetup -setdnsservers Wi-Fi "Empty"

05Sources

Last verified: 2026-09-17 · Category: Network