Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@Juul
Last active December 6, 2023 13:00
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Juul/be2f32c910bfbe98c1d7ff5662f62c06 to your computer and use it in GitHub Desktop.
Save Juul/be2f32c910bfbe98c1d7ff5662f62c06 to your computer and use it in GitHub Desktop.
4-address mode aka WDS for OpenWRT

To turn a router into a bridge between wifi and ethernet, with the router being a wifi client/station, you need 4-address mode aka Wireless Distributions System or WDS.

This does not necessarily work between vendors so make sure your AP and client use chips from the same manufacturer.

It seems that enabling WDS on an AP's wifi interface does not prevent non-WDS clients from connecting normally, at least in my limited experience.

On the AP you simply add option wds '1' to the relevant wifi-iface section. E.g:

config wifi-iface 'default_radio0'
  option device 'radio0'
  option network 'lan'
  option ifname 'wlan0'
  option mode 'ap'
  option ssid 'my-wifi-ssid'
  option encryption 'psk2'
  option key 'PASSWORD'
  option wds '1'

On the client you simply add a wifi-iface section with the sta mode and also add the same wds line, e.g:

config wifi-iface 'wds_radio1'                                      
  option device 'radio0'                                          
  option network 'lan' # causes this interface to be bridged to br-lan (see below)
  option ifname 'wlan0                                         
  option mode 'sta'                                                
  option ssid 'my-wifi-ssid                          
  option encryption 'psk2'                                        
  option key 'PASSWORD
  option wds '1'

Make sure you specify the same wifi channel on both client and AP. If you want maximum bandwidth you will probably want to add something like option htmode 'VHT80' or similar in the relevant wifi-device sections on both AP and client. Beware that this can exclude devices from connecting to the AP if they don't support such wide channels. There is other stuff you can do for speed like "greenfield mode" but that's not the point of this guide.

Now on the client you need to bridge the ethernet and wifi interfaces. The modern way of doing this (on latest stable OpenWRT as of March 2022) is something like the following in /etc/network/interfaces:

config device                                                         
        option name 'br-lan'                                                                     
        option type 'bridge'                                           
        list ports 'eth0.1'                                          
        list ports 'eth0.2'                                           

config interface 'lan'                                                 
        option device 'br-lan'                                         
        option proto 'dhcp'

Of course the actual names of the ethernet devices will vary depending on your device. You will note that no wifi interfaces were specified as being part of the bridge. That's because the recommended way of adding wifi interfaces to a bridge is instead to specify which "network" the wifi interface is a part of in the /etc/config/wireless file. As seen in the example above, this is accomplished by the line:

  option network 'lan'

Finally make sure you comment out any sections in /etc/config/network that are trying to make use of your bridged interfaces (e.g. the config interface 'wan' stuff) and make sure to disable the dhcp server stuff by commenting out any config dhcp and config odhcpd sections in /etc/config/dhcp.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment