Skip to content
midnitesnake edited this page Apr 22, 2013 · 11 revisions

Mac OS X Internet Connection Sharing

Warning! Warning!!!! Don't use the reset button after changing these settings! I think it will brick the Pineapple, need someone with a usb serial adapter to confirm!!!

Second Warning!!! You might want to make sure you have a serial adapter first before modifying the settings in the Pineapple!! If you screw it up, you will lose communication with it over ethernet!!

Quick and dirty internet connection sharing in OSX Lion.

Lion's ICS is locked to the 192.168.2.0/24 network.
There's probably a way to edit some config file, but the only thing in my house that can run it is my wife's macbook air.
This guy ain't messing her laptop up!!! Sooo, we edit the pineapple…

There are two files we need to change, /etc/config/network and /etc/config/dhcp .
Configure your laptop to the pineapple network, 172.16.42.42 so we can ssh in and edit things.
Cd over to /etc/config and do a;
cp dhcp dhcp.bak cp network network.bak

Now nano network and replace with this;

Copyright (C) 2006 OpenWrt.org
config interface loopback
                option ifname   lo
                option proto    static
                option ipaddr   127.0.0.1
                option netmask  255.0.0.0
config interface lan
                option ifname   eth0
                option type      bridge
                option proto    static
                option ipaddr   192.168.2.254
                option netmask  255.255.255.0
                option gateway  192.168.2.1
                option dns        8.8.8.8
config interface wan
           option ifname                eth1
           option proto         dhcp
config switch eth0
           option enable_vlan           1
config switch_vlan
           option device                eth0
           option vlan          1
           option ports         "0 1"
config interface usb
        option ifname usb0
        option proto dhcp

Warning! Warning!!!! Untested - Alternative OSX Setup; Customise NAT Range

Copy the plist file /Library » Preferences » SystemConfiguration » com.apple.nat.plist to your temp directory,
sudo cp /Library/Preferences/SystemConfiguration/com.apple.nat.plist /tmp

Use Xcode's Property List Editor (or any other property list editor) to edit the file in your temp directory. Add a new key (child) to the NAT dict. Call it SharingNetworkNumberStart. The type should be String, and the value is the IP network you want to use (eg 172.16.42.0).

plutil -convert xml1 /tmp/com.apple.nat.plist

As an example, here's what an edited file looks like:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>NAT</key>
	<dict>
		<key>AirPort</key>
		<dict>
			<key>40BitEncrypt</key>
			<integer>1</integer>
			<key>Channel</key>
			<integer>0</integer>
			<key>Enabled</key>
			<integer>0</integer>
			<key>Extreme</key>
			<string></string>
			<key>NetworkName</key>
			<string>pimpedwifi</string>
			<key>NetworkPassword</key>
			<data>################</data>
		</dict>
		<key>Enabled</key>
		<integer>1</integer>
		<key>PrimaryInterface</key>
		<dict>
			<key>Device</key>
			<string>HUAWEIMobile-Modem</string>
			<key>Enabled</key>
			<integer>0</integer>
			<key>HardwareKey</key>
			<string></string>
			<key>PrimaryUserReadable</key>
			<string>HUAWEI Mobile</string>
		</dict>
		<key>PrimaryService</key>
		<string>C42284CE-6803-42A7-9F54-627DB90321DF</string>
		<key>SharingDevices</key>
		<array>
			<string>en0</string>
		</array>
		<key>SharingNetworkNumberStart</key>
		<string>172.16.42.0</string>
	</dict>
</dict>
</plist>

Save your changes. Copy the edited file back to the original location.

sudo cp /tmp/com.apple.nat.plist /Library/Preferences/SystemConfiguration/

Now you can (re-)start Internet Sharing, and it will run on your defined subnet.

Hopefully some day Apple will add this as a config option in the Sharing System Preferences panel.

Clone this wiki locally