MacOS – How to emulate Internet Sharing from the command line

command lineinternet-sharingmacosNetworkvpn

I'm trying to set up my Macbook Air to share an OpenVPN connection for use while I'm on the road and don't want my iOS traffic to go over the open Internet. Sadly, Mountain Lion's Internet Sharing feature doesn't include the VPN interface in the list of shareable network interfaces, so I assume I'm going to have to emulate Internet Sharing from the command line.

I've figured out some of the moving pieces that are put in place by the InternetSharing wrapper:

  • ifconfig to set up the bridge interface
  • ipfw to set up forwarding of traffic
  • bootpd to offer DHCP service to clients
  • natpmpd to handle port forwarding
  • named in a cache configuration to handle DNS queries

One piece I haven't figured out is the configuration of the wireless network, namely the SSID and WPA2 configuration. What service is responsible for that, and how does one activate it? It seems like it might be airportd, but I don't see any relevant-looking options there.

Best Answer

This could possibly get you part of the way on your journey to the final solution, though it hasn't worked for me so far on mountain lion. I'd very much like to know what your solution is if you find one!