Installing VPN on an OpenWrt Router
Step 1. Installing OpenWrt on the Router
- Verify that your router supports OpenWrt 23.05.0 or later:
- https://openwrt.org/toh/start
- https://firmware-selector.openwrt.org (alternative resource)
- Install OpenWrt 23.05.0 or later on your router, ensuring you select the appropriate version for your specific router model.
Using this guide, you won’t be able to configure a VPN on routers running OpenWrt 22.03.x or earlier.
Step 2. Installing AmneziaWG on the OpenWrt Router
Before starting, disable any active VPN connections on the device you'll be using to connect to the router.
- Open a command line/terminal and run
ssh root@192.168.1.1
, where192.168.1.1
is your router's IP address. Depending on your network configuration, your router may use a different IP address (e.g.,192.168.0.1
). - When prompted, confirm the connection by typing
yes
. - Run
ping github.com
to verify that the router has internet connectivity.
- Execute the following command to run the installation script, which will automatically install the AmneziaWG package for your router:
sh <(wget -O - https://raw.githubusercontent.com/Slava-Shchipunov/awg-openwrt/refs/heads/master/amneziawg-install.sh)
- When the script completes, type
n
when prompted.
Special thanks to Slava Shchipunov for creating the script!
For more details about the script, see the author’s repository on GitHub.
Step 3. Creating a VPN Connection on the Router
- Access the router's web interface by entering the router's IP address into your web browser (e.g.,
192.168.1.1
). - Go to Network → Interfaces.
- Click Add new interface.
- Enter a name for your VPN interface and select AmneziaWG VPN as the protocol → click Create interface.
- In the window that appears, click Load configuration.
- Either paste the entire contents of your configuration file or drag and drop the configuration file into the window → click Import settings.
How to get a configuration file:
- in the Subscription Dashboard if you have an Amnezia Premium subscription
- in the AmneziaVPN app if you have your own server — share VPN access in the AmneziaWG native format
- Go to the Firewall Settings tab → click the Create / Assign firewall-zone drop-down list → enter a name for the new zone in the field below the zone list → press Enter → click Save.
- In the window that appears, on the Interfaces tab, click Save & Apply.
Step 4. Configuring the Router's Firewall
- Go to Network → Firewall.
- Click Edit to the right of the lan zone.
- Click the Allow forward to destination zones drop-down list → check the box next to your previously created firewall zone → click Save.
- Check the Masquerading option for your previously created firewall zone → click Save & Apply.
- Go to Network → Interfaces.
- Click Edit to the right of the VPN interface you created earlier.
- Open the Peers tab → click Edit to the right of the configuration file you imported earlier.
- Check Route Allowed IPs → click Save → click Save again.
- In the window that appears, while on the Interfaces tab, click Save & Apply → go to System in the top-menu → Reboot.
- Click Perform reboot.
After the router reboots, check connectivity — the internet should start working through the VPN.
Updating the VPN Configuration with a New Configuration File
- Go to Network → Interfaces.
- Click Edit to the right of the created VPN interface.
- In the window that appears, click Load configuration.
- Either paste the entire contents of your new configuration file or drag and drop it into the window → click Import settings → click OK to confirm.
- On the Peers tab, click Delete to the right of the old configuration file → Save.
- Click Edit to the right of the newly imported configuration file → check Route Allowed IPs → click Save → click Save again.
- In the window that appears, on the Interfaces tab, click Save & Apply.