Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

bill99

macrumors member
Original poster
Aug 16, 2019
96
6
Hello,

is it possible that user A gets it's IP from the DHCP-server meanwhile user B uses a static IP(v4)
when he logs into the same iMac (without making changes in the Network Settings) ?


Thank you!

Bill
 

bill99

macrumors member
Original poster
Aug 16, 2019
96
6
It works, but not really like i hoped it would...

Setting up the different network location is very easy and does work. But when I sign-in again to macOS with the "regular" user accound, it does not automatically switch back to the original IP-address, but the IP defined for the
special user is still active.
 

bogdanw

macrumors 603
Mar 10, 2009
5,751
2,773
Locations can be instantly changed using the networksetup utility from Terminal. The same commands can be included in launch agents for each user or simple apps that start at login.

The command looks like this
Code:
networksetup -switchtolocation "location name"

Examples from Terminal:
Code:
networksetup -switchtolocation "Admin"

Code:
networksetup -switchtolocation "User"

AppleScript that can be saved as apps from Script Editor and added to login items:
Code:
do shell script "networksetup -switchtolocation 'Admin'"

Code:
do shell script "networksetup -switchtolocation 'User'"

How to create a launch agent or a small app in Script Editor
https://forums.macrumors.com/threads/login-items-hide.2366349/post-31680952
https://forums.macrumors.com/threads/login-items-hide.2366349/post-31700153
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.