Urluba

Q: 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

Close

Q: How to set up a network bridge ?

  • All replies
  • Helpful answers

  • by BrianFL,

    BrianFL BrianFL Dec 3, 2011 6:41 AM in response to Urluba
    Level 1 (50 points)
    Dec 3, 2011 6:41 AM in response to Urluba

    I don't know if this can be done that way.

    If you want to share a connection from your MacMini, go to the Sharing System Preference. Choose Internet Sharing from the list on the left, from there, the choices are self-explanatory.

     

    Hope this helps!

  • by Urluba,

    Urluba Urluba Dec 4, 2011 1:02 PM in response to BrianFL
    Level 1 (0 points)
    Dec 4, 2011 1:02 PM in response to BrianFL

    Hi,

     

    In fact I am using Internet Sharing but to bring my LAN to a network device behind my Mac mini. What bother me is having this device on a different and 'dedicated' network. I'd like to have only one LAN.

     

    Thanks anyway!

  • by krodelabestiole,

    krodelabestiole krodelabestiole Feb 8, 2012 9:58 AM in response to Urluba
    Level 1 (0 points)
    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 ?

  • by Camelot,

    Camelot Camelot Feb 8, 2012 11:10 AM in response to krodelabestiole
    Level 8 (47,233 points)
    Mac OS X
    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.

  • by dexpetkovic,

    dexpetkovic dexpetkovic Apr 28, 2015 4:24 AM in response to Camelot
    Level 1 (0 points)
    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
      1. 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?

  • by Pierre Albarede,

    Pierre Albarede Pierre Albarede Feb 25, 2016 1:16 PM in response to dexpetkovic
    Level 1 (10 points)
    Photos for Mac
    Feb 25, 2016 1:16 PM in response to dexpetkovic