brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: network locations give your Mac a second set of network settings

Terminal
~/tips/tip-macos-network-locations

networksetup -listlocations

Saves separate sets of network settings and switches between them in one step.

Network locations are one of those Mac features that hide in a menu, and I think they deserve more attention. A location is a complete set of network settings: DNS, manual IPs, proxies, service order. Your Mac starts with one called Automatic, and you can add more and switch between them.

On macOS Ventura or later, open System Settings, click Network, and choose Locations > Edit Locations from the More pop-up menu below the list of services. Click the add button, type a name like Home or Test, and click Done. Every change you now make to Wi-Fi, Ethernet or other settings goes into the new location, and the old one stays exactly as you left it. Once you have more than one, the Apple menu gets a Location submenu for switching. The Terminal can do it too:

networksetup -listlocations
networksetup -getcurrentlocation
sudo networksetup -switchtolocation "Automatic"

The use I like best is the one Apple mentions itself: testing. Create a Test location, try a manual IP or a different DNS server there, and if it all goes wrong you switch back to Automatic and everything is as it was. That beats writing down every field before you start changing them. Apple also suggests it for a laptop that should prefer Ethernet at the office and Wi-Fi at home, since every location keeps its own service order.

The caveat: changes always land in the location that’s active, and it’s easy to forget which one that is. If settings seem to vanish, check networksetup -getcurrentlocation before anything else. For most people the single Automatic location is fine, as Apple says too, so I’d only add a second one when there’s a real reason.

Further reading: Use network locations on Mac (Apple), networksetup man page (SS64, macOS)

More Terminal tips ioreg -rn AppleSmartBattery | grep CycleCount Terminal can save your windows and tabs as a window group Export a Terminal profile to a .terminal file and import it on another Mac mc hidutil property --set '{"UserKeyMapping":[{"HIDKeyboardModifierMappingSrc":0x700000039,"HIDKeyboardModifierMappingDst":0x700000029}]}' All Terminal tips (116) All topics

Link