Packet forwarding on OS X Mavericks

airportfirewallinternet-sharingNetworkwifi

I need my MacBook Air (Mavericks 10.9.2) to share the Internet connection (wi-fi;en0) with BeagleBone Black (BBB) which is in the 192.168.7.0 subnet (en6).

ifconfig:

$ ifconfig
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384
    options=3<RXCSUM,TXCSUM>
    inet6 ::1 prefixlen 128 
    inet 127.0.0.1 netmask 0xff000000 
    inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1 
    nd6 options=1<PERFORMNUD>
gif0: flags=8010<POINTOPOINT,MULTICAST> mtu 1280
stf0: flags=0<> mtu 1280
en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
    ether 7c:d1:c3:ee:f3:dd 
    inet6 fe80::7ed1:c3ff:feee:f3dd%en0 prefixlen 64 scopeid 0x4 
    inet 192.168.2.35 netmask 0xffffff00 broadcast 192.168.2.255
    nd6 options=1<PERFORMNUD>
    media: autoselect
    status: active
en5: flags=8963<UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500
    options=60<TSO4,TSO6>
    ether 32:00:18:d5:b1:40 
    media: autoselect <full-duplex>
    status: inactive
en6: flags=863<UP,BROADCAST,SMART,RUNNING,SIMPLEX> mtu 1486
    ether 90:59:af:58:5e:96 
    inet 192.168.7.1 netmask 0xfffffffc broadcast 192.168.7.3
    media: autoselect
    status: active
bridge0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
    options=63<RXCSUM,TXCSUM,TSO4,TSO6>
    ether 7e:d1:c3:ee:e2:00 
    Configuration:
        id 0:0:0:0:0:0 priority 0 hellotime 0 fwddelay 0
        maxage 0 holdcnt 0 proto stp maxaddr 100 timeout 1200
        root id 0:0:0:0:0:0 priority 0 ifcost 0 port 0
        ipfilter disabled flags 0x2
    member: en5 flags=3<LEARNING,DISCOVER>
            ifmaxaddr 0 port 5 priority 0 path cost 0
    nd6 options=1<PERFORMNUD>
    media: <unknown type>
    status: inactive
p2p0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 2304
    ether 0e:d1:c3:ee:f3:dd 
    media: autoselect
    status: inactive

Here are my Internet Sharing settings

Internet Sharing settings

I'm unable to ping 8.8.8.8 from BBB though I shared wi-fi with BeagleBoneBlack. Whether I share internet connection or not ipfw gives same result

$ sudo ipfw list
65535 allow ip from any to any

I tried disabling firewall in vain.
I could share my internet connection from Ubuntu machine through iptables. Here I need to masquerade packets through gateway interface.

Should I have configured anything like a NAT on the bridge between en0 (internet access) and en6?

Best Answer

The Internet Sharing service will handle all the translation requirements by itself. For some reason, though, it's necessary to use the Network Preferences pane to manually confirm the information the bridging interface has already come up with on its own. (Since the BBB has its own DHCP server, perhaps the Mac is willing to accept the BBB's DHCP offer in the 192.168.7.x subnet as a suggestion, but then reinforces the fact that as the DNS it holds the keys to the external world, thereby imposing its configuration on the communication process. I don't know. I do digress, however.)

After turning on Internet Sharing for the BBB in the Sharing pane, switch to the Network pane of System Preferences. Select the en6 service in the lefthand window, click "Advanced" at the lower right, and select the "TCP/IP" pane. If it's not already filled in, Under "Configure IPv4," select "Manually" from the drop-down menu, enter 192.168.7.1 for both the IPv4 and router addresses and 255.255.255.252 as the subnet mask. This leaves 192.168.7.2 for the BBB and 192.168.7.3 as the broadcast address. You can ignore the IPv6 configuration section. Next, select the "DNS" pane from the top row of tabs. Click on the '+' mark just below the window and add 192.168.7.1. In the right hand window, add "local" (without the quote marks) to the search domains.

FYI, I'm sure you'll want to know that ipfw has been deprecated and replaced by pfctl in OS 10.9.