

Switch the active location to a location called Work, but also show the GUID of that location so we can make scripties with it laters: scselect Work Switch the active location to a location called Work: networksetup -switchlocation Work Obtain the active location the system is using: networksetup -getcurrentlocationĬreate a network location called Work and populate it with information from the active network connection: networksetup -createlocation Work populateĭelete a network location called Work: networksetup -deletelocation Work Show a list of locations on the computer: networksetup -listlocations

Get information about how en0 got its DHCP on: ipconfig getpacket en1 View the dns server for en0: ipconfig getoption en0 domain_name_server View the subnet mask of en0: ipconfig getoption en0 subnet_mask Same thing, but setting and echoing a variable: ip=`ipconfig getifaddr en0` echo $ip Get an ip address for en0: ipconfig getifaddr en0 Mac Network Commands Cheat SheetĪfter writing up the presentation for MacSysAdmin in Sweden, I decided to go ahead and throw these into a quick cheat sheet for anyone who’d like to have them all in one place. Also, note that this is from 2016, many things may have changed, and I don't use macOS anymore, so I probably can't help in case of questions, but maybe someone else can. Note: Since this seems to be helpful to some people, I formatted it to improve readability of the original.

If you know the author, please let me know so I give the attribution. Disclaimer: I'm not the original author of this sheet, but can't recall where I found it.
