Set DNS Search Domains for a Network Service
Make short internal hostnames resolve by adding search domains to your Wi-Fi or Ethernet service.
Run sudo networksetup -setsearchdomains "Wi-Fi" "local" "company.internal"; use the single word "Empty" to clear the list.
01Command
Command
$ sudo networksetup -setsearchdomains "Wi-Fi" "local" "company.internal"02What it does
A search domain is appended automatically to single-label hostnames, so typing http://nas reaches nas.local or nas.company.internal without the suffix. Like other networksetup verbs this replaces the whole list for that one service, and -getsearchdomains prints what is currently set — handy when corporate VPN software has quietly rewritten it.
03Risk
!Warning: Setting search domains manually may stop DHCP-issued ones from being used; if internal names stop resolving, clear the list with "Empty" to fall back to the network's defaults.
04Undo
Undo
$ sudo networksetup -setsearchdomains "Wi-Fi" "Empty"05Sources
- networksetup - Configure Network SettingsEvidence: Documents -setsearchdomains for setting the DNS search domains of a network service (space-separated, 'Empty' to clear) and -getsearchdomains to view them.
- networksetup(8) man pageEvidence: The networksetup man page describes -setsearchdomains as specifying the domain names of the search domain for the named network service.
Last verified: 2026-09-19 · Category: Network