Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revisionBoth sides next revision
docs:guide-user:network:wifi:wifiextenders:ap_sta [2024/08/09 04:50] – Editorial pass richb-hanoverdocs:guide-user:network:wifi:wifiextenders:ap_sta [2024/08/12 18:12] – Editorial tweaks to the backup/configuration page richb-hanover
Line 1: Line 1:
-======  Wi-Fi Extender/Repeater with STA (client) link to upstream AP (Hotspot)  ====== +======  Wi-Fi Repeater using AP+STA mode====== 
-AP+STA mode (sometimes referred to as "wi-fi tethering") allows an OpenWrt router to make wireless uplink to another hotspot ("access point" or AP). It then repeats data from the uplink to other devices connected to the OpenWrt device wirelessly or on its Ethernet interface.+//THIS DOCUMENT IS IN FLUX FOR THE NEXT FEW DAYS. Although I believe it is correct, none of this has been tested. If you need to configure repeater, check one of the earlier versions of this pagerichb-hanover; 9Aug2024//
  
-AP+STA mode is by far the simplest means of extending Wi-Fi coverage. //**It does not require any changes to the upstream access point.**//\\+Wi-Fi Repeater is a configuration of an OpenWrt router that "extends" 
 +the network.
  
-===== Manual configuration ===== +An OpenWrt router operating in AP+STA mode 
-This procedure assumes that your OpenWrt device has the default settings and that the AP and Ethernet port are bridged. +(sometimes referred to as "wi-fi tethering") does this 
-This makes changes to these configuration files: +by making a wireless uplink to a hotspot (an access point or "AP") 
-  * [[docs:guide-user:base-system:basic-networking|/etc/config/network]] +and then repeating to other devices connected 
-  * [[docs:guide-user:network:wifi:basic|/etc/config/wireless]] +wirelessly or to its Ethernet interface.
-  * [[docs:guide-user:firewall:firewall_configuration|/etc/config/firewall]] +
-  * [[docs:guide-user:base-system:dhcp|/etc/config/dhcp]]+
  
-==== 1. Backup the relevant configuration files ==== +AP+STA mode is by far the simplest means of extending Wi-Fi coverage because it does not require any changes to the upstream access point.  
-Use these commands to save backup copies of the configuration files. + 
-<code bash>+**Terminology:** this page refers to 
 +the upstream access point (AP) as the **hotspot**; 
 +the OpenWrt Wi-Fi repeater/extender as the **router**; 
 +STA refers to the fact that the router connects to the hotspot as a "station" (a regular Wi-Fi device). 
 + 
 +===== Make Backups ===== 
 +The procedure below updates the updates the following files 
 +to configure your router to act as a Wi-Fi repeater/extender. 
 +It assumes that your router has the default settings and that its wireless and Ethernet are bridged. 
 +([[docs:guide-user:base-system:basic-networking|/etc/config/network]], 
 +[[docs:guide-user:network:wifi:basic|/etc/config/wireless]], 
 +[[docs:guide-user:firewall:firewall_configuration|/etc/config/firewall]], and 
 +[[docs:guide-user:base-system:dhcp|/etc/config/dhcp]]) 
 + 
 + 
 +Before you begin, it's always wise to make backups of all your configuration files. 
 +<code> 
 +# Back up the configuration files 
 +echo 'Backing up configuration files'
 cp /etc/config/network  /etc/config/network.bak cp /etc/config/network  /etc/config/network.bak
 cp /etc/config/wireless /etc/config/wireless.bak cp /etc/config/wireless /etc/config/wireless.bak
Line 21: Line 38:
 </code> </code>
  
-==== 2. Modify the configuration files ==== +===== Configuring the Wi-Fi Repeater ===== 
-Run this script (or execute the commands sequentially)You may need to change parameters (such as the IP subnet or the Wi-Fi credentials) before using these commands.+Use the script below to change the configurationIt performs these tasks: 
 + 
 +  * Configure the router's LAN interface to 192.168.2.1 (default) Assume LAN subnet mask is 255.255.255.0 
 +  * Create a WWAN interface to get a DHCP from the hotspot 
 +  * Add the WWAN interface to the "wan" firewall zone 
 +  * Configure WWAN interface to use 'radio0' in STA mode 
 +  * Set the Wi-Fi credentials so the router can connect to the hotspot 
 + 
 +To use the script, edit the IP address and the Wi-Fi credentials at the top of the file, then [[:docs:guide-user:network:wifi:wifiextenders:ap_sta#how_to_run_these_scripts|run the script.]] 
 <code bash> <code bash>
-The WWAN network is in the WAN firewall zone+Fill in these values, then run the script 
 +ROUTER_LAN_IP='192.168.2.1' 
 +HOTSPOT_ENCRYPTION_MODE='none'  
 +HOTSPOT_SSID='upstream-hotspot-wifi-ssid' 
 +HOTSPOT_PASSWORD='super-secret-password' 
 + 
 +# Set the router's LAN IP address to a different subnet from the hotspot (AP) IP address. 
 +echo 'Setting the LAN IP address to $ROUTER_LAN_IP' 
 +uci set network.lan.ipaddr=$ROUTER_LAN_IP 
 + 
 +# Add the WWAN network is in the WAN firewall zone 
 +echo 'Setting firewall zone for "wwan"'
 uci add_list firewall.@zone[1].network="wwan" uci add_list firewall.@zone[1].network="wwan"
 uci commit firewall uci commit firewall
 /etc/init.d/firewall restart /etc/init.d/firewall restart
  
-# You should ensure that the router's LAN IP address is a different subnet from the hotspot (AP) IP address. +# The WWAN interface is the "uplink". It obtains a DHCP address from the upstream hotspot. 
-uci set network.lan.ipaddr="192.168.2.1" +echo 'Configuring WWAN'
-# The WWAN interface is the "uplink". It obtains a DHCP address from the upstream AP.+
 uci set network.wwan="interface" uci set network.wwan="interface"
 uci set network.wwan.proto="dhcp" uci set network.wwan.proto="dhcp"
Line 37: Line 73:
 /etc/init.d/network restart /etc/init.d/network restart
  
-The Wi-Fi interface for the uplinkSTA mode, with the proper Wi-Fi credentials (SSID, encryption mode, key)+Add the Wi-Fi interface for the uplink
 +STA mode, with the proper Wi-Fi credentials (SSID, encryption mode, key) 
 +echo 'Configuring the Wi-Fi uplink'
 uci set wireless.wwan="wifi-iface" uci set wireless.wwan="wifi-iface"
 uci set wireless.wwan.device="radio0" uci set wireless.wwan.device="radio0"
 uci set wireless.wwan.network="wwan" uci set wireless.wwan.network="wwan"
 uci set wireless.wwan.mode="sta" uci set wireless.wwan.mode="sta"
-You should change the encryption and ssid values to match those of the hotspot (AP) +Change the encryption and ssid values to match those of the hotspot (AP) 
-uci set wireless.wwan.encryption="none" +uci set wireless.wwan.encryption=$HOTSPOT_ENCRYPTION_MODE 
-uci set wireless.wwan.key="super_secret_key" +uci set wireless.wwan.ssid=$HOTSPOT_SSID 
-uci set wireless.wwan.ssid="hotspot or AP ssid"+uci set wireless.wwan.key=$HOTSPOT_PASSWORD
 uci commit wireless uci commit wireless
 wifi reload wifi reload
 </code> </code>
  
-:!: An alternative **event-driven** recovery solution is to be found [[https://forum.openwrt.org/viewtopic.php?pid=309131#p309131|here]]. +==== Revert to AP-Only mode (Optional) ==== 
- +//This is an optional, but recommended step.//\\ 
-==== 3. Revert to AP Only mode on boot when Hotspot is not available ==== +When the upstream hotspot is not available or if the wireless configuration file (created above) is incorrectthe router disables its own AP. 
-When the hotspot/upstream AP is not available or it is incorrectly defined in the wireless configuration file, OpenWrt disables its own AP. +If that happens, you would lose wireless access to your router, and could only connect through its Ethernet port. 
-If that happens, you would only be able to access your OpenWrt device through its Ethernet port. +The following step installs a script that tests for hotspot availability after boot. 
-The following script tests for hotspot availability after boot. +If the router cannot connect to the hotspot after 30 seconds, it automatically reconfigures itself to AP Only mode so you an again access the router wirelessly.
-If OpenWrt can not connect to the hotspot after 30 seconds, OpenWrt automatically reconfigures itself to AP Only mode+
-You will then be able to access your OpenWrt device again wirelessly.+
  
 <code bash> <code bash>
 # Create AP Only and AP+STA wireless configuration files # Create AP Only and AP+STA wireless configuration files
-cp /etc/config/wireless.original /etc/config/wireless.ap-only+cp /etc/config/wireless.bak /etc/config/wireless.ap-only
 cp /etc/config/wireless /etc/config/wireless.ap+sta cp /etc/config/wireless /etc/config/wireless.ap+sta
  
Line 104: Line 140:
 </code> </code>
  
-==== 4. wwanHotspot: maintain always up a dual wifi config, Access Point and HotSpot client ====+:!: An alternative **event-driven** recovery solution is to be found [[https://forum.openwrt.org/viewtopic.php?pid=309131#p309131|here]]. 
 + 
 +==== wwanHotspot: maintain always up a dual wifi config, Access Point and HotSpot client (Optional) ====
 In one location there may be several Hotspots that may be available or not according to the comings and goings of their owners; we will enter the parameters of each one of them in the configuration file therefore wwanHotspot will connect and disconnect the OpenWrt HotSpot client to one of them as they become available. In one location there may be several Hotspots that may be available or not according to the comings and goings of their owners; we will enter the parameters of each one of them in the configuration file therefore wwanHotspot will connect and disconnect the OpenWrt HotSpot client to one of them as they become available.
  
Line 110: Line 148:
 Download the latest version of [[https://github.com/jordi-pujol/wwanHotspot/|wwanHotspot]] and follow the instructions. Download the latest version of [[https://github.com/jordi-pujol/wwanHotspot/|wwanHotspot]] and follow the instructions.
  
-==== 5. Disable DNS rebind protection ====+==== Disable DNS rebind protection (Optional) ====
 Disable DNS rebind protection if you need to trust upstream resolvers. Disable DNS rebind protection if you need to trust upstream resolvers.
  
Line 117: Line 155:
 uci commit dhcp uci commit dhcp
 /etc/init.d/dnsmasq restart /etc/init.d/dnsmasq restart
 +</code>
 +
 +==== How to run these scripts ====
 +
 +To run one of the scripts above,
 +[[:docs:guide-quick-start:sshadministration|ssh into the router]], then perform each of these steps:
 +<code bash>
 +# Copy the script into your favorite editor and make any changes
 +# When you're ready, copy that text then paste it in when indicated
 +# Run each of the steps below sequentially
 +
 +ssh root@192.168.2.1 # use the actual address for your router
 +cd /tmp
 +cat > config.sh 
 +# paste in the contents of the script, then hit ^D (Control-D)
 +sh config.sh
 +# Presto! 
 </code> </code>
  
  • Last modified: 2024/09/06 13:37
  • by richb-hanover