3

I have a laptop on which I have setup a bridge interface between the Ethernet and WiFi devices in order to connect non-WiFi devices to the network before they go into their final, wired, position. I use the bridge instead of forwarding/routing because it allows ARP and broadcasts through. In order for this to work I manually enable 4addr mode each time I activate the bridge: iw dev wlp3s0 set 4addr on and it is important to note that the WiFi network also has to support this.

I would like to automate this and have tried with various methods:

  1. NetworkManager dispatcher.d scripts (pre-up as well)
  2. udev rule

The problem with the first one is that the dispatcher.d script (both normal and pre-up) run after the device has connected to the SSID by which point it is too late to enable 4addr. The second approach is too broad and just turns on 4addr on boot, which means I can't connect to any WiFi networks that don't support 4addr.

Is there a way to set 4addr mode (or just run a script) before NetworkManager tells the WLAN card to connect to a specified network?

wutr
  • 51

1 Answers1

2

Short answer: No, NetworkManager can't enable 4addr based on connection, but using udev to create a second virtual wlan interface mostly solves my problem.

I have come up with the following solution which I think is better than manually enabling 4addr, but still leaves some features to be desired as you need to first manually disconnect your 'normal' WiFi connection before activating the bridge.

I use a udev rule to create a second WLAN interface on boot which has 4addr enabled permanently. Then I set up the bridge to use this new interface for the WLAN part and make sure all other WiFi connections are explicitly set to use the original WLAN interface (all using the KDE NetworkManager Applet)

Finally in my case it is important to disable auto-connect for the bridge members and let the bridge enable them when required.

/etc/udev/rules.d/90-wlan-bridge.rules

ACTION=="add", SUBSYSTEM=="ieee80211", KERNEL=="phy0", RUN="/usr/bin/iw phy %k interface add brwlan type managed 4addr on"

nmcli connection modify 'wlan-eth-bridge' connection.autoconnect-slaves 1
nmcli connection modify 'bridge-member-wlan' connection.autoconnect 0
nmcli connection modify 'bridge-member-eth' connection.autoconnect 0
wutr
  • 51