Setting up Access Devices on an OpenWRT Router with Wireguard VPN
In this article, we will discuss how to set up access devices on an OpenWRT router with Wireguard VPN. We will cover the key concepts and provide detailed context on the topic. The OpenWRT router in this example serves IP addresses in the subnet 10.0.1.1/24, while the Wireguard VPN running on the router serves IP addresses in the subnet 10.10.0.1/24. We will also cover how to connect to the VPN.
Prerequisites
Before we begin, it is assumed that you have a working OpenWRT router and have installed Wireguard VPN on it. It is also assumed that you have basic knowledge of networking and command line interfaces.
Setting up Access Devices
To set up access devices on the OpenWRT router with Wireguard VPN, you will need to configure the router to allow connections from the access devices. This can be done by adding a new interface in the Wireguard VPN configuration.
First, log in to the OpenWRT router via SSH and navigate to the Wireguard VPN configuration directory:
cd /etc/wireguardNext, create a new interface configuration file for the access devices:
touch wg0.accessOpen the new interface configuration file in a text editor:
nano wg0.accessAdd the following configuration to the file:
[Interface]
PrivateKey =
Address = 10.10.0.2/32
[Peer]
PublicKey =
Endpoint = :
AllowedIPs = 0.0.0.0/0, ::/0 Replace
Save and close the file. Next, add the new interface to the Wireguard VPN configuration:
cat wg0.access >> wg0.confRestart the Wireguard VPN service to apply the changes:
wg-quick down wg0 && wg-quick up wg0The access device can now connect to the OpenWRT router via Wireguard VPN using the configuration provided in the wg0.access file.
Connecting to the VPN
To connect to the VPN, the access device will need to have Wireguard VPN installed. The configuration file for the access device can be obtained from the OpenWRT router by copying the wg0.access file to the access device.
On the access device, install Wireguard VPN and copy the wg0.access file to the appropriate directory:
sudo apt-get install wireguard
scp root@:/etc/wireguard/wg0.access /etc/wireguard/wg0.conf Start the Wireguard VPN service on the access device:
sudo wg-quick up wg0The access device is now connected to the OpenWRT router via Wireguard VPN.
References
- OpenWRT: https://openwrt.org/
- Wireguard VPN: https://www.wireguard.com/
- Wireguard VPN on OpenWRT: https://openwrt.org/docs/guide-user/services/vpn/wireguard