【OpenWrt】WIFI 中继(relay)设置

Posted by 西维蜀黍 on 2020-11-21, Last Modified on 2021-09-21

This image shows an example setup. LAN interface of the Wi-Fi extender device MUST be on a different subnet for relayd to work (since it is routing traffic, it expects 2 different subnets).

Since both ethernet ports and Access Point Wi-Fi network are on the same LAN interface, all clients connecting to the Ethernet ports and to the Access Point Wi-Fi network of the Wi-Fi extender device will be routed by relayd and will be connected to your main network.

The LAN interface subnet will be used only as a “management” interface, as devices connecting to the Wi-Fi repeater will be on the main network’s subnet instead. You will have to set your PC with a static address in the same subnet as the LAN interface (like 192.168.2.10 for our example) to connect again to the Wi-Fi repeater’s Luci GUI or SSH.

LAN Interface

Set your PC’s ethernet or Wi-Fi settings at static IP 192.168.2.10 and default gateway 192.168.2.1, then connect again to the wifi repeater (through ethernet or wifi). When you finish all of the following steps, remember to reset your PC’s IP address back to the original address (or DHCP), otherwise you won’t have Internet access. The repeater won’t route traffic from the 192.168.2.0/24 subnet.

Wi-Fi

We will now set up the client Wi-Fi network, the configuration needed to connect to another Wi-Fi network. Once you are connected again to the Wi-Fi extender, go in the wireless networks page, and click on Scan button.

Choose the Wi-Fi network you want to connect to from the page and click “Join Network”.

Enter the Wi-Fi password, leave the “name of new network” as “wwan” and select lan firewall zone. Click Save.

Repeater Interface

Go in the Interfaces page, we will now add the relayd interface that will join the lan and wwan interfaces. Click on Add New Interface.

Write a name for it (repeater_bridge is the name I used in the example), and then choose Relay bridge in the Protocol of the new interface field. Click Submit.

You may need to reboot your device before the Relay bridge option appears.

This “Local IPv4 address” needs to match the IP address assigned by the Wifi-network (eg. from 192.168.1.0/24 range, but do not enter the netmask here!) otherwise this bridge will not be accessible from the clients connected directly to the primary router and the relayd-daemon will not start. It makes sense to either fix the IP in the DHCP servers MAC-IP mapping table or configure then WWAN interface of OpenWRT to a fix IP which is not being used in Wifi-networks DHCP-range (I used 192.168.1.2, as my DHCP server only serves IP addresses higher than 192.168.1.100).

Reference