Which IP ranges and subnet does OSX internet connection sharing use by default?
I'm using a TP-Link portable router to share a wireless internet connection from my mac to the router via ethernet. This seems to work but I notice that the IP on a device connected to the router is 192.168.2.14.
I'm curious to know which IP range internet connection sharing will use by default and whether this can be changed via the terminal.
I'm currently on Mountain Lion but also interested in any relevant differences in Mavericks.
ifconfig shows:
bridge0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
ether ac:de:48:08:15:b5
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<LEARNING,DISCOVER>
port 5 priority 0 path cost 0
Is this bridge the mechanism for internet sharing?
Sorry: I'm a bit short of time and so this isn't a complete answer, but hopefully it gives you a starting point.
From the answers to this question, it seems that /usr/libexec/InternetSharing
creates /etc/bootpd.plist
when Internet Sharing is turned on, and removes it again when it is turned off. I think this file is the cause for the ifconfig
values you are seeing.
On my machine, when it exists, among other things, that file contains
<key>net_address</key>
<string>192.168.2.0</string>
<key>net_mask</key>
<string>255.255.255.0</string>
<key>net_range</key>
<array>
<string>192.168.2.2</string>
<string>192.168.2.254</string>
</array>
I'm guessing that 192.168.2 is the default range, as my machine is producing the same results as yours.
I think you could try modifying /etc/bootpd.plist
once the file has been created to set your own range. You might then need to restart bootp
.
I don't know how to configure InternetSharing to use a different default. (I had a brief look at /System/Library/CoreServices/InternetSharing.bundle and the output of strings /usr/libexec/InternetSharing
, but couldn't see anything obvious.) One of the answers to the question I mentioned above suggests creating a cron job or launch agent to overwrite the /etc/bootpd.plist
with the settings you require automatically.
These details are for Mavericks. If I understand right, Mountain Lion uses named
instead: see the question, and the article it refers to also.
However... bootp
is only the subsystem that tells your other devices what addresses they should use (via DHCP). The Mac also has to forward packets from those devices to your wireless connection, and vice versa. I don't know how that forwarding is configured, and it might well be set up to forward only packets from/to the 192.168.2 subnet.