A comprehensive guide for setting up secure remote SSH access to your OpenWrt router from anywhere in the world using WireGuard VPN—without exposing your SSH port to the internet.
- Overview
- Prerequisites
- Part 1: Dynamic DNS Setup
- Part 2: WireGuard VPN Server Setup
- Part 3: Client Configuration
- Part 4: Testing & Troubleshooting
- Security Best Practices
- FAQ
This guide walks you through setting up a secure VPN tunnel to your home network in four parts:
| Step | Component | Purpose |
|---|---|---|
| 1 | Dynamic DNS | Give your home network a fixed hostname |
| 2 | WireGuard Server | Configure VPN server on OpenWrt router |
| 3 | WireGuard Client | Set up remote devices (desktop, laptop, phone) |
| 4 | Testing | Verify secure connection and access |
By using WireGuard, you create an encrypted tunnel that lets you access your router and devices as if you were on your local WiFi—securely and privately.
- An OpenWrt-compatible router with OpenWrt installed
- Access to OpenWrt's LuCI web interface
- A device to use as a VPN client (desktop, laptop, smartphone)
- Basic networking knowledge
- Administrative access to your router
Your ISP assigns a public IP that changes periodically. Dynamic DNS solves this by linking a fixed hostname to your current IP.
- Visit a DDNS provider. We recommend DuckDNS (free, reliable).
- Sign up and create a hostname, e.g.,
my-router.duckdns.org. - Note your hostname and token — you'll need them soon.
- Open your OpenWrt LuCI interface and log in.
- Navigate to System → Software.
- Click Update lists and wait for completion.
- Search for
luci-app-ddnsand install it.
-
Go to Services → Dynamic DNS.
-
Click Add new service, name it (e.g.,
my_duckdns), and click Create service. -
Fill in these fields:
Field Value Enabled ✅ Check Lookup Hostname my-router.duckdns.orgDDNS Service Provider duckdns.orgDomain my-router.duckdns.orgUsername my-router(without.duckdns.org)Password Your DuckDNS token Use HTTP Secure ✅ Check -
Go to the Advanced Settings tab.
-
Change IP address source from
NetworktoURL. -
Enter this URL:
http://checkip.dyndns.com- This is crucial for Double NAT users.
-
Click Save, then return to the main Dynamic DNS page and click Save & Apply.
- Click Start or Reload for your service.
- Wait 30 seconds, then click Edit and view the Log File Viewer tab.
- Look for:
OK ...... update successful✅
Now we'll install and configure WireGuard on your router.
- Go to System → Software.
- Search for and install:
wireguard-toolsluci-proto-wireguard
- Log out and log back in to the LuCI interface for changes to take effect.
- Navigate to Network → Interfaces.
- Click Add new interface:
- Name:
wg0 - Protocol: WireGuard VPN
- Name:
- Click Create interface.
- On the configuration page:
- Click Generate Key to create your Private Key. The Public Key will auto-generate.
- ✅ Copy and save your Public Key — clients need this.
- Listen Port:
51820(or another high-numbered port) - IP Addresses:
10.0.0.1/24(doesn't conflict with your LAN)
- Click Save.
-
Go to Network → Firewall.
-
Under Zones, click Add:
Field Value Name vpnInput rejectOutput acceptForward rejectMasquerading ✅ Check Covered Networks wg0Allow Forward from Source Zones lan -
Click Save.
-
Go to the Traffic Rules tab and click Add:
Field Value Name Allow-WireGuard-WANProtocol UDPSource Zone wanDestination Port 51820Action accept -
Click Save, then Save & Apply.
Each device connecting to the VPN needs a unique key pair. Never reuse keys across devices.
# Create a private key
wg genkey > my-desktop.private
# Generate the corresponding public key
wg pubkey < my-desktop.private > my-desktop.public
# Secure the private key
chmod 600 my-desktop.private# Debian/Ubuntu
sudo apt install wireguard-tools
# Fedora/RHEL
sudo dnf install wireguard-tools
# openSUSE
sudo zypper install wireguard-tools
# Arch
sudo pacman -S wireguard-tools-
Display your public key:
cat my-desktop.public
-
In OpenWrt LuCI, go to Network → Interfaces → wg0 and click the Peers tab.
-
Click Add peer:
Field Value Description Linux DesktopPublic Key Paste output from step 1 Allowed IPs 10.0.0.2/32Route Allowed IPs ✅ Check -
Click Save, then Save & Apply.
Create /etc/wireguard/openwrt.conf with root privileges:
sudo nano /etc/wireguard/openwrt.confPaste this configuration (replace bracketed values):
[Interface]
Description = Linux Desktop
PrivateKey = [PASTE CONTENT OF my-desktop.private]
Address = 10.0.0.2/32
DNS = 192.168.1.1
[Peer]
Description = OpenWrt Router
PublicKey = [PASTE ROUTER'S PUBLIC KEY FROM wg0 PAGE]
Endpoint = my-router.duckdns.org:51820
AllowedIPs = 0.0.0.0/0
PersistentKeepalive = 25Save the file and secure it:
sudo chmod 600 /etc/wireguard/openwrt.conf-
Install the WireGuard App from the Play Store.
-
Open the app and tap the
+button. -
Select "Create from scratch" — this generates a new key pair automatically.
-
Name your tunnel (e.g.,
My Phone). -
Add this peer in OpenWrt:
-
Copy the Public Key displayed in the app.
-
In OpenWrt, go to Network → Interfaces → wg0 → Peers and click Add peer:
Field Value Description My PhonePublic Key Paste from app Allowed IPs 10.0.0.3/32Route Allowed IPs ✅ Check -
Click Save, then Save & Apply.
-
-
Back in the WireGuard app, configure the Interface:
- Addresses:
10.0.0.3/24 - DNS servers:
192.168.1.1
- Addresses:
-
Add Peer details in the app:
- Public Key: Paste router's public key
- Endpoint:
my-router.duckdns.org:51820 - Allowed IPs:
0.0.0.0/0 - Persistent Keepalive:
25
-
Save the configuration.
- Install the WireGuard App from the App Store.
- Tap
+and select "Create from scratch". - Follow the same steps as Android (5-8 above).
On Linux:
sudo wg-quick up openwrtOn Mobile:
- Open the WireGuard app and toggle the connection on.
- Disconnect from your home WiFi — use a different network (mobile hotspot, public WiFi) to verify true remote access.
- Test SSH connection:
ssh root@192.168.1.1
- You should see the OpenWrt login prompt. ✅
# Check WireGuard interface status
sudo wg show
# View connection logs
sudo journalctl -u wg-quick@openwrt -n 50
# Test connectivity
ping 192.168.1.1On Linux:
sudo wg-quick down openwrtOn Mobile:
- Toggle the connection off in the WireGuard app.
- Use strong firewall rules — only allow necessary traffic.
- Rotate keys periodically — regenerate peer keys every 6-12 months.
- Keep OpenWrt updated — regularly check System → Software for updates.
- Use unique keys per device — never share peer keys.
- Monitor connected peers — check Network → Interfaces → wg0 for unexpected connections.
- Enable OpenWrt's built-in firewall — don't disable it.
- Don't expose SSH directly to the internet (that's why we use WireGuard).
- Don't share your DDNS token publicly.
- Don't use the same WireGuard private key on multiple devices.
- Don't disable firewall masquerading for the VPN zone.
- Don't use weak DDNS credentials.
A: Check the log file in Services → Dynamic DNS. Common issues:
- Incorrect token
- Network connectivity problems
- ISP blocking DuckDNS (try a different provider)
A: Yes! Repeat Part 3 for each new device. Assign unique IPs (e.g., 10.0.0.4/32, 10.0.0.5/32).
A: Once connected via VPN, use the internal IP addresses of your LAN devices. For example:
ssh user@192.168.1.50A: You can regenerate it. The peer will need to create a new configuration with the new public key.
A: Yes. WireGuard has a smaller attack surface, cleaner code, and generally better performance.
A: Yes, but ensure the firewall rule matches your chosen port.
A: This guide focuses on IPv4. For IPv6 support, add IPv6 addresses in the WireGuard interface configuration (e.g., fd86:ea04:1115::1/64).
Found an issue or have suggestions? Feel free to open an issue or submit a pull request!
This guide is provided as-is for educational purposes. Always ensure you follow your local laws and regulations regarding VPN usage.