Specific network settings for sharing internet connection

ethernetinternet-sharingNetwork

I can successfully bridge my WLAN and Ethernet on my macbook(internet sharing) and have each network adapter set to dhcp. In my case the macbook is connecting to the internet with wireless and the ethernet port on the macbook allows another older laptop(which does not have wireless) to also access the net through the macbook. When i inspect the ip address of the wireless interface, it shows the expected local ip and gateway. However, the ethernet interface of the mac shows a private ip, 169.254.135.163 with a subnet mask of 255.255.0.0.

The older client laptop shows an ip of 192.168.2.2 and a gateway of 192.168.2.1
How did the macbook decide to pick these numbers and dole them out over its ethernet port?

When i set the ethernet ip address of the macbook to 192.168.1.2 with a mask of 255.255.255.0 and a gateway of 192.168.1.1, the client laptop can still access the net (and still has the same ip adresses) but the mac loses connectivity. Why should changing the ip address of the ethernet port on the mac cause its wireless interface to stop working?

Best Answer

Your Macbook is bridging 2 different networks.

The first, from your router, would presumably be 192.168.1.0
That would make the router itself 192.168.1.1 & it will then hand out DHCP addresses from 192.168.1.2 up to as high as .254

In order to prevent potential IP Address conflicts. Apple's Internet Sharing will use an address of one order higher for each Ethernet connection you ask it to use [with Thunderbolt or USB adapters, this could be many, on rare occasions] so the first one will be 192.168.2.x, the one after 192.168.3.x etc

The only thing that puzzles me slightly is that the reported self-assigned address is 169.254.x.x. This is a private, self-assigned address that an interface will use if it cannot find a DHCP server to assign it one.
For a bridged connection, though, I would have expected it to assign itself 192.168.2.1, as the gateway for your bridge & not be trying to pick up a DHCP address at all, as it is the 'router & gateway' to your new node.

The fact that your second machine can connect successfully with an assigned address of 192.168.2.2 & a gateway of 192.168.2.1 would tell me that the self-assigned address might be misreported somewhere along the line; as otherwise it oughtn't to be able to connect.

After some extensive Googling I discovered this, which may explain the apparent discrepancy.

If you toggle your Internet Sharing on and off, you'll see the bridge0: device appear and disappear from ifconfig. This makes things tricky depending on the static IP you assigned your Pi as well as your Mac. If you chose to use DCHP for your Mac Ethernet connection, your Pi will only work with a static IP that looks like 169.254.x.x; however, when you turn on Internet Sharing, your Pi will then only work with an IP that looks like 192.168.2.x. It turns out that if you used DHCP for your Ethernet connection and your Ethernet has an IP of 169.254.x.x AND you have Internet Sharing on, you can still connect to your Pi via a 192.168.2.x address since now the bridge0: device is the one handing out the IP address to connected devices.

TL:DR
Don't set DHCP on your shared connection in the Macbook, because it is supposed to be the 'master'. Allow the OS to set it up itself, which it will do correctly, with a fixed IP of 192.168.2.1 for itself & 192.168.2.2 ..3 ..4 etc for devices using it as a bridge