Apple - Start/Stop Internet Sharing via Terminal in Yosemite without AppleScript

I stumbled across a seemingly stupidly easy way to enable/disable Internet Sharing the other day. There's just a bit of prep work to be done first.

  1. Open System Preferences > Network
  2. Highlight the interface you want to share your connection FROM and click the gear below the interface list
  3. Select 'Duplicate Service...'
  4. Give the duplicated service a name and save it
  5. Set the service to 'DHCP with manual address' (because some DHCP servers will not assign an additional address to a MAC) and input a valid IP

That's the prep work done. Now you just need to change your IS settings to share from the new service instead of the existing one. Then, you can use networksetup -setnetworkserviceenabled <networkservice> <on off> to toggle the network service you just created on or off. Doing so disables IS as there is no service to receive internet access from, and you still retain access on your machine because there is still an active interface connected to your network!