Differences

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

Link to this comparison view

Next revision
Previous revision
Next revisionBoth sides next revision
docs:guide-user:network:wifi:wifiextenders:ap_sta [2024/06/24 05:29] – created bluewavenetdocs: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:
-====== Configure A(ccess) P(oint or 'hotspot'+ STA(tion or 'client'====== +======  Wi-Fi Repeater using AP+STA mode====== 
-AP+STA mode allows OpenWrt to connect to a wireless hotspot (AP) and provide wireless access from that hotspot to anything connected to the OpenWrt AP and Ethernet ports, the ''br-lan'' device. +//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 repeatercheck one of the earlier versions of this page. richb-hanover; 9Aug2024//
-This assumes that your OpenWrt device has the default settings where the AP and Ethernet port are bridged.+
  
-===== Manual configuration ===== +A Wi-Fi Repeater is a configuration of an OpenWrt router that "extends" 
-The changes below assume an OpenWrt default configuration, the relevant files are: +the network.
-  * [[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]] +
-  * [[docs:guide-user:base-system:dhcp|/etc/config/dhcp]]+
  
-==== 1. Backup the relevant configuration files ==== +An OpenWrt router operating in AP+STA mode 
-<code bash> +(sometimes referred to as "wi-fi tethering") does this 
-cp /etc/config/firewall /etc/config/firewall.bak +by making a wireless uplink to a hotspot (an access point or "AP"
-cp /etc/config/network /etc/config/network.bak+and then repeating to other devices connected 
 +wirelessly or to its Ethernet interface. 
 + 
 +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.  
 + 
 +**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/wireless /etc/config/wireless.bak cp /etc/config/wireless /etc/config/wireless.bak
-cp /etc/config/dhcp /etc/config/dhcp.bak+cp /etc/config/firewall /etc/config/firewall.bak 
 +cp /etc/config/dhcp     /etc/config/dhcp.bak
 </code> </code>
  
-==== 2. Modify the relevant configuration files' sections ====+===== Configuring the Wi-Fi Repeater ====
 +Use the script below to change the configuration. It 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>
-# Add WWAN network to WAN 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
  
-Change the default OpenWrt IP address +The WWAN interface is the "uplink". It obtains a DHCP address from the upstream hotspot. 
-# Note that OpenWrt AP IP address must be in a different subnet than the hotspot (AP) IP address+echo 'Configuring WWAN'
-uci set network.lan.ipaddr="192.168.2.1" +
-# Add the WWAN interface+
 uci set network.wwan="interface" uci set network.wwan="interface"
 uci set network.wwan.proto="dhcp" uci set network.wwan.proto="dhcp"
Line 34: Line 73:
 /etc/init.d/network restart /etc/init.d/network restart
  
-# Add Wi-Fi interface+# 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"
-The encryption and ssid values need 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 incorrect, the router disables its own AP. 
-When the hotspot is not available or it is incorrectly defined in the wireless configuration file, OpenWrt will disable the AP. +If that happens, you would lose wireless access to your router, and could only connect through its Ethernet port. 
-This means that you can only access your OpenWrt device through its Ethernet port. +The following step installs a script that tests for hotspot availability after boot. 
-The following will describe how to get OpnWrt to test for the 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 will automatically reconfigure itself to AP Only mode+
-This will allow wireless access to your OpenWrt device again.+
  
 <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 101: Line 140:
 </code> </code>
  
-==== 4. wwanHotspot: maintain allways 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]]. 
-In one place 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.+ 
 +==== 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.
  
 This daemon may be used instead of the method described in step 3. This daemon may be used instead of the method described in step 3.
 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 114: 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