C.W.K.
Stream
Lesson 12 of 13 · published

networksetup (macOS)

~12 min · networksetup, macos, static-ip, dns, mtu

Level 0Pinger
0 XP0/101 lessons0/12 achievements
0/150 XP to next level150 XP to go0% complete

System Settings, from the terminal

networksetup is macOS's command-line interface to the System Settings → Network panel. Anything you can do via the UI — set a static IP, change DNS, switch to DHCP, set the MTU for jumbo frames — you can script. Indispensable for fleet automation, dotfiles bootstrap, and any scenario where you want repeatable network config.

Code

Inspect·bash
# All hardware ports (Ethernet, Wi-Fi, Thunderbolt, USB-C)
networksetup -listallhardwareports

# Detailed info for a specific port
networksetup -getinfo "Ethernet"
networksetup -getinfo "Wi-Fi"

# Current DNS for a service
networksetup -getdnsservers "Wi-Fi"

# Current MTU
networksetup -getMTU "Ethernet"
Configure·bash
# Set a static IP / mask / gateway
sudo networksetup -setmanual "Ethernet" 192.168.1.100 255.255.255.0 192.168.1.1

# Switch back to DHCP
sudo networksetup -setdhcp "Ethernet"

# Set DNS servers
sudo networksetup -setdnsservers "Wi-Fi" 1.1.1.1 8.8.8.8

# Clear custom DNS (revert to DHCP-provided)
sudo networksetup -setdnsservers "Wi-Fi" "Empty"

# Set MTU for jumbo frames on 10GbE (Track 7)
sudo networksetup -setMTU "Ethernet" 9000

External links

Exercise

Run networksetup -listallhardwareports and identify each interface. Pick Wi-Fi: networksetup -getdnsservers "Wi-Fi". Then networksetup -getMTU "Wi-Fi". These commands are read-only — no changes. The point is fluency: you should be able to inspect any network setting from the terminal without clicking through System Settings.

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.

No comments yet — be the first.