Bridge on a Mac Mini 2018. Wireless(Wi-Fi) & Ethernet. No NAT. No Internet Sharing.

Network level 2 bridge in Linux is very easy, you get brctl, you get the job done. Is it the same on Mac? Let's find out.


TL;DR

  1. create an empty bridge
    System Preferences -> Network -> (Unlock) ->  Setting(left hand side lower part, the grey gear icon) -> Manage Virtual Interface -> the '+' button -> New Bridge -> Create -> write down the corresponding BSD name bridgeX ->  Done -> Apply.
  2. turn off IPv4 DHCP for interfaces
    Ethernet -> Configure IPv4: Off -> Apply

    the newly created bridge -> Configure IPv4: Off -> Apply
  3. add bridge member (required after every reboot)
    terminal: sudo ifconfig bridgeX addm en0 addm en1 up   (where bridgeX is the one created in step 1)
    see 'Caveats' for solution.
Long story
I have a switch connecting my mac and NAS for local access. I use landlord's WIFI to access Internet. NAS has no wifi adapter and need to access Internet.

I know brctl (bridge utils) works great in Linux, but I don't know how it is done on mac.
After googling and youtubing, I found that most of them referring to the Internet sharing function (a.k.a NAT), not bridge, at least that's not what I learnt about bridge. So I decided to tried it out myself and I did it. It works, albeit with some minor issues.

I am aware that a repeater/extender would do the work, but I don't want to spend CAD40 for a repeater.
Caveats
Run a command after every reboot is painful, make it happened automatically.

make sure the command is correct. I will use the following as an example.
sudo /sbin/ifconfig bridge0 addm en0 addm en1 up

1. add to sudo
open terminal and run
sudo SUDO_EDITOR=nano visudo
input your own password

append the following line at the end.
ALL ALL=NOPASSWD:/sbin/ifconfig bridge0 addm en0 addm en1 up
Ctrl+X, y, <ENTER> to save & exit   (Do not change the filename!)

test in another terminal by running the command, see if the system asks for password. If yes, something wrong with your configuration.
sudo /sbin/ifconfig bridge0 addm en0 addm en1 up

2. setup automate job
2.1 Run Automator application -> New -> Application -> Choose -> Left side, choose Utilities -> drag 'Run Shell Script' to the right panel.
2.2. fill in the textbox
sudo /sbin/ifconfig bridge0 addm en0 addm en1 up
2.3. save
save the project as an application file.
2.4. System Preferences -> Search 'Login Items' -> add the application file.

Comments

Popular posts from this blog

DELL U4320Q ddccontrol in Linux switch input

UEFI boot.