One method of bridging network interfaces

Oct 09, '06 07:30:05AM

Contributed by: gboudrea

Here's my setup: on my ethernet LAN, I have my mini, my Xbox, and a Windows PC; on my wifi LAN, I have my mini, my internet router, and two other Macs. So I was looking for something that I would install on my mini so that my router would be accessible to my Xbox and Windows PC, and that would allow me to connect to those two from any Mac. Basically, I needed to bridge my ethernet and wifi LAN using Mac OS X.

Possible solutions:

  1. Use an Airport Express. Easy (simply configure the ethernet port with a static IP and disable all other features to have it bridge ethernet/wifi traffic), but not that cheap...
  2. Use IPNetRouterX. It looked easy to use, but I didn't really like the idea of forking over US$100 for a proprietary piece of software.
  3. Find some way to configure Mac OS X built-in ipfw/natd to do it.
I searched the web here and there, and nobody seemed to have done something similar.

So here's how I did it.

  1. Configured the mini wifi and ethernet network interfaces to be on separate subnets; I used 192.168.1.255 for wifi, and 192.168.2.255 for ethernet.
  2. Enabled Internet Sharing on my mini, to make the Airport's internet connection available to the ethernet-connected machines. This took care of half the problem: getting the Xbox and Windows PC to access the router.
  3. Edited /etc/hostconfig on my mini (to be the bridge in my setup). I changed IPFORWARDING=-NO- to IPFORWARDING=-YES-. Note: You can add that line if you don't have it. Then reboot.
  4. On each Mac I wanted to be able to access the Xbox / Windows PC, I created a static route to specify that I wanted to use my mini to reach those machines:
    sudo route add -host xbox_ip mini_wifi_ip
    sudo route add -host winpc_ip mini_wifi_ip
    This tells your Mac that to reach either xbox_ip or winpc_ip, it needs to use mini_wifi_ip as the gateway. The mini will then receive packets for the Xbox and Windows PC, that it will now forward to the appropriate machine. (Replace the sample names with your network's relevant IP addresses.)
  5. To make those static routes persistent accross reboots, I had to follow this how-to.
And done. I could now successfully ping and connect to either the Xbox or Windows PC from my wifi-connected Macs, and the Xbox and Windows PC could access the internet.

Comments (17)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20060930205108232