You can make a difference in the Apple Support Community!

When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

How to set up a network bridge ?

Hi,


I try to set up a network bridge between ethernet and wifi using lion on a mac mini. Using ifconfig, I have successfully created a "bridge0" interface with en0 and en1 but it is not working. Tcpdump shows arp requests are not forwarded through the interfaces.

Has anyone successfully done it ?


Thanks

Mac mini, Mac OS X (10.7.2)

Posted on Dec 1, 2011 1:27 AM

Reply
6 replies

Feb 8, 2012 9:58 AM in response to Urluba

good question


I'm trying to setup the same config

here is what ive done so far :


$ sudo -s

$ ifconfig bridge0 create

$ ifconfig bridge0 up addm en0 addm en1


last command line add en0 (ethernet) and en1 (wifi) to the bridge interface (bridge0)


this way i get a new interface in my network manager called "bridge Configuration"

this seems like something is planned by mac os

still, it doesnt work (pings from devices on the wifi network to 192.168.1.1 which is the main router get no return)


did anyone succeed to create a working bridge on lion ?

Feb 8, 2012 11:10 AM in response to krodelabestiole

Setting up the bridge is only half the battle. By default the OS isn't going to pass traffic across it, nor do devices on either side of the bridge know to use the bridge link.

At the very least you need to configure ARP so that the Mac responds to requests for devices on the other side of the bridge - i.e. when the device on WiFi sends out an ARP request for the router, the Mac responds, even though it isn't the gateway machine.


You could use proxyall to have the Mac proxy all ARP traffic across the bridge, or add specific ARP entries to the ARP table.


sudo sysctl -w net.link.ether.inet.proxyall=1


You might also need to enable IP Forwarding:


sudo sysctl -w net.inet.ip.forwarding=1


With the usual caveats that sysctl changes like this are transient and lost at reboot - add them to /etc/sysctl.conf to apply them at boot.

Apr 28, 2015 4:24 AM in response to Camelot

Hello all,

Even with all the configuration that Camelot proposed above, I failed to make this setup work consistently for my usecase. The thing is that I want to proxy all traffic from mobile device using Charles. So, the setup works without involving Charles proxy, but does not work when I configure proxy (that is running on macbook) on the mobile device.


It seems that in case I disable IPv4 and IPv6 on the WiFi interface (to create Layer2 environment) and create a bridge where both Eth and WiFi are members of, the mobile device ARP query for the Ethernet port MAC address does not get responded to by the Ethernet port. That is needed for proxying the traffic via the macbook as Eth port IP serves as proxy IP address. Of course, once I remove proxy config from mobile device, everything works as charm.


I have no idea why this happens having in mind that proxyall and forwarding have been set to 1.


Here is the procedure I did:


  1. Turn on Internet Sharing in System Preferences -> Sharing. Configure WiFi sharing and make sure it is selected (To computers using Wi-Fi)
  2. Reboot and make sure that it works on startup.
  3. Make sure that IPv6 is disabled by checking the System Preferences -> Network -> Wi-Fi and then on TCP-IP both IPv4 and IPv6 should be off. To disable IPv6 on Wi-Fi port run

    sudo networksetup -setv6off Wi-Fi

  4. Then disable Internet Sharing via the Sharing GUI
  5. sudo ifconfig bridge create
  6. Use ifconfig to check bridge that was created and record its bridgeId (i.e. bridge1)
  7. sudo ifconfig bridge1 addm en0 addm en1 up
  8. Enable Interned sharing via the Sharing GUI
  9. sudo sysctl -w net.link.ether.inet.proxyall=1
  10. sudo sysctl -w net.inet.ip.forwarding=1
  11. Wireshark trace shows that Ethernet port does not respond to ARP requests when Ethernet port IP address is set on mobile device as (Charles) proxy IP address.


Any clues?

How to set up a network bridge ?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.