MacOS – Turn Internet Sharing off automatically when on specific network

internet-sharingmacosNetwork

At home I connect my MacBook Pro, running OS X El Capitan, to the Internet using Ethernet, and share the connection with my phone via Wi-Fi.

At work I connect the MacBook Pro to the company network using Ethernet, and Internet Sharing is not allowed.

Is there a way to automatically turn Internet Sharing on and off depending on which network I am on?

A solution which detects the Ethernet network, somehow, the presence or absence of specific Wi-Fi network, or indeed the actual geographic location would do the job.

I am aware that I can set the 'Location' via the Apple menu, but can that control the Internet Sharing options, and can detecting the location not be done automatically? Selecting the location manually is too much like hard work.

Best Answer

Yes, you can use ControlPlane. It is designed to do exactly the sort of thing you've mentioned.

Example of setting up an Internet Sharing toggle

You'll need to define a context (like "Home" or "Work" or "Out & About") or a few contexts, and then define what clues show what context is active, and then define what actions to take when a context becomes active or ceases to be active.

In most cases a context corresponds to a location (or vague type of location, like "Out & About"). But you could have a "Hotspot" context and a "Wi-Fi" context and an "Ethernet" context, if that suited your needs better. Or you could have "Metered" and "Unmetered" contexts.

You can also enable multiple simultaneous contexts, but that gets complicated and confusing, and I don't recommend it at first.

You can use presence of networks, geographical location, and perhaps dozens of other things to determine your location/context. It's quite powerful (but after a while you'll notice things missing, like the ability to directly trigger an action from an evidence source, without the need to use a context as an intermediary). I heartily recommend it, even though you may eventually wish it did a lot more than it does.