Keep “Internet Sharing” alive after rebooting Mountain Lion

You may certainly find guides on how to share an Internet connection (e.g. from your Ethernet to wireless devices via embedded Wi-Fi) on a Mac computer running Mountain Lion 10.8.x but maybe you are in the same boat as I was, some time ago: do the exact opposite.

Due to the serious economical conditions in my home country, I had to leave wife, child, family and friends and move to another country in Europe where I found employment anew. However, renting a furnished flat was easy; getting a telephone and ADSL connection proved impossible.

I therefore had the landlord talk to my neighbour and convince him to eventually share his Wi-Fi with me, at a monthly fee, therefore providing me with a link to the “outside world” in the evenings (that is, FaceTime with my family).

However, I still wanted to hook up to the Internet my 2 Hackintosh computers and my WDTV Live device, besides my iPad. I had to devise a plan and share Wi-Fi Internet through Ethernet.

My smaller Hackintosh (a Gigabyte GA-H61N-USB3 with Intel Core i3-2125 and 8GB RAM) is used as a file/media server and seemed ideal for the task. Back then, while running 10.8.2, I thought that using Server.app would solve my problems. However, being computer-literate but networking-apprentice, I could not set it up properly and abandoned all hope.

I then turned to the famous, easy “Internet Sharing” feature of the Mac OS X system, but doing the opposite of what most users did; and it was tricky. After purchasing an OEM 802.11n USB dongle with a flexible antenna (running with the official Realtek RTL8192CU8 driver) the task was to properly configure the settings so I could share Internet via Ethernet to my other devices too: my powerful Hackintosh and WDTV Live player, all hooked to a Gigabit switch.

First step was to set up the Wi-Fi dongle driver, then I made sure the connection was working by using DHCP for quicker, fool-proof results. In this case, the ADSL wireless router was serving a range of 192.168.1.x addresses, whilst the DNS assigned was the router/gateway itself, i.e. 192.168.1.1:

Mountain Lion 'Internet Sharing' Wi-Fi Settings

Then, after a lot of searching and experimenting, I realised that the Wi-Fi dongle (en1) had to be first in the list of network devices, as it’s the one that is providing the connection to the Internet. The Ethernet (en0) connection would thus be second:

Mountain Lion 'Internet Share' Service Order

The next step was the tricky one: the Ethernet (en0) connection must get a manual IP address so that DHCP (a service running on Mountain Lion, this time) can serve any wired devices. This IP range had to be different, however, to the one served by the wireless modem/router and in this case I decided to go with 192.168.2.x and that meant I needed to assign 192.168.2.1 on this computer (to start the DHCP pool):

Mountain Lion 'Internet Share' Ethernet Setup

As it can be seen, the tricky part lied to the Router and DNS settings, as Ethernet (en0) now is relying on Wi-Fi (en1) to have all packets properly routed to the Internet. Both these settings had to be set as 192.168.1.1, pointing to the wireless modem/router. The Subnet remained the same 255.255.255.0 for the sake of simplicity.

The final step involved just activating the actual “Internet Sharing” itself. In the “Sharing” preferences pane and after clicking on the “Internet Sharing” service, I made sure that my source was set to the 802.11n WLAN Adapter, sharing to computers using Ethernet. When ticked both the “destination” and the service itself, I could see that my other devices immediately picked up an IP address and got connected to the Internet.

Mountain Lion 'Internet Share' Set Connections

As with each Hackintosh set-up, there are changes and updates needing to reboot the computer. Coming from Windows mentality I often reboot this Hackintosh file/media server, sometimes due to the frame-buffering issues that appear on the vanilla Intel HD 3000 display driver. Even after updating to 10.8.4, the new problem found was that upon reach reboot and despite the “Internet Sharing” service being ticked (implying “active”) the actual underlying service would not kick-start. I always had to manually stop and re-start this service by un-ticking and re-ticking this service on the list. Otherwise, wired devices had no access to Internet and curiously enough, could not get an IP address either.

Mountain Lion 'Internet Share' Confirm Start

This was a harder bug to crunch, as for countless times I was literally “digging” in Google results to find a solution using a multitude of keywords. The answer came after reading for a third or fourth time the insightful article “Running DHCP on Mountain Lion Server” where I found that the bootpd deamon is responsible for my problem. Moreover, it seems that Apple programmers decided to keep this daemon dormant at each reboot, as seen in the untouched file /System/Library/LaunchDaemons/bootps.plist where the <Disabled> key is set to <true> by default, meaning that Mac OS X forces the user to manually start DHCP, whenever it is needed. I guess this is the right way to do things but Apple programmers could at least have “Internet Sharing” stopped and un-checked at each shutdown!

The necessary edit is to change this <Disabled> key in line 6 from <true> to <false> and just reboot the system. Better make a backup copy of the file bootps.plist, just in case. This change is quite sensitive and needs to be performed only if the computer is intended to always behave as a DHCP server just like in my own case; now, it is not necessary to stop and re-start the service after each reboot, as long as “Internet Sharing” remains untouched.

Mountain Lion 'Internet Share' Activate Sharing

After activating “Internet Sharing” and following this article found on StackExchange.com, I could now see how connectivity works with the new bridge created on the file/media server:

$ ifconfig
lo0: flags=8049 mtu 16384
	options=3
	inet6 fe82::1%lo0 prefixlen 64 scopeid 0x1 
	inet 127.0.0.1 netmask 0xff000000 
	inet6 ::1 prefixlen 128
en0: flags=8963 mtu 1500
	options=2b
	ether 00:e0:40:48:e0:40 
	media: autoselect (1000baseT )
	status: active
en1: flags=8863 mtu 1500
	ether 08:02:0a:0d:4c:05 
	inet6 fe82::4a02:2aff:fe9d:4c35%en1 prefixlen 64 scopeid 0x5 
	inet 192.168.1.39 netmask 0xffffff00 broadcast 192.168.1.255
	media: autoselect
	status: active
bridge0: flags=8863 mtu 1500
	ether a8:d2:4a:10:d0:b9 
	inet 192.168.2.1 netmask 0xffffff00 broadcast 192.168.2.255
	Configuration:
		priority 0 hellotime 0 fwddelay 0 maxage 0
		ipfilter disabled flags 0x2
	member: en0 flags=3
	         port 4 priority 0 path cost 0

 
NOTE: The boodpd daemon starts with the network settings found in /etc/bootpd.plist which were created when “Internet Sharing” was previously activated. This file must not be confused with the actual daemon launch behaviour in bootps.plist.