Configuring hostnames and inspecting dynamic DNS resolution on macOS often confuses administrators accustomed to standard Linux configurations. On macOS, editing /etc/hosts or /etc/resolv.conf is often ineffective because Darwin manages system identities and network state through an internal dynamic repository called the SystemConfiguration (configd) daemon. The scutil (System Configuration Utility) command-line interface provides direct programmatic access to inspect and modify macOS computer names, DNS search domains, and network proxy stores.
Understanding the Three Distinct Names of macOS
Unlike Linux which uses a single static hostname, macOS maintains three separate identity parameters, each serving a unique networking role:
- ComputerName: The human-friendly label displayed in the macOS Finder, System Settings, AirDrop menus, and local Apple File Sharing (AFP/SMB) windows (e.g., “John’s MacBook Pro”).
- LocalHostName: The Bonjour / mDNS (multicast DNS) advertising identifier used by devices on the local subnet ending in
.local(e.g.,Johns-MacBook-Pro.local). It cannot contain spaces or punctuation. - HostName: The fully qualified domain name (FQDN) or standard POSIX hostname returned by shell utilities like
hostnameand terminal prompts over SSH.
Inspecting and Setting Hostnames with scutil
You can query any of the three naming domains directly using the --get flag:
scutil --get ComputerName
scutil --get LocalHostName
scutil --get HostName
Updating System Names via Terminal:
To assign standardized corporate or network naming conventions, update all three identifiers using --set with sudo:
sudo scutil --set ComputerName "MacBook-Air-M3"
sudo scutil --set LocalHostName "MacBook-Air-M3"
sudo scutil --set HostName "MacBook-Air-M3.corp.local"
After executing these commands, flush the local Directory Service cache to propagate changes across all system daemons:
sudo dscacheutil -flushcache
sudo killall -HUP mDNSResponder
Auditing Active DNS Configuration with scutil –dns
On modern macOS systems, viewing /etc/resolv.conf displays a legacy stub file warning that it does not reflect per-interface DNS configurations. To inspect the true, authoritative DNS resolvers actively in use across Wi-Fi, Ethernet, and active VPN tunnels, run:
scutil --dns
The command lists every scoped resolver:
- resolver #1: The primary system-wide resolver used for standard internet queries.
- Scoped resolvers: Interface-specific DNS routes (e.g., routing internal
.corpdomains exclusively through a corporate WireGuard or IPSec tunnel while sending general traffic through your home router).
Interactive Exploration of the Dynamic Configuration Store
Network engineers can enter scutil’s interactive shell by typing scutil without arguments. This opens an ncurses-like environment to inspect dynamic kernel keys:
scutil
> list State:/Network/Global/.*
> show State:/Network/Global/IPv4
> quit
This allows live inspection of default gateway IPs, primary network service interfaces, and active captive portal statuses without third-party network auditing software.