User Tools

Site Tools


WireGuard extras




Web interface

Install the necessary packages if you want to manage VPN settings and view VPN status via web interface.

# Install packages
opkg update
opkg install luci-proto-wireguard luci-app-wireguard
  • Navigate to LuCI → Network → Interfaces to configure WireGuard.
  • Navigate to LuCI → Status → WireGuard Status to view WireGuard status.

Dynamic IP

Periodically re-resolve inactive peer hostnames for VPN peers with dynamic IP addresses.

# Periodically re-resolve inactive peers
cat << "EOF" >> /etc/crontabs/root
* * * * * /usr/bin/wireguard_watchdog


Implement plain routing between server side LAN and client side LAN assuming that:

  • - server side LAN
  • - client side LAN
  • - VPN network
  • - VPN server
  • - VPN client

Add route to client side LAN on VPN server.

uci set network.wgclient.route_allowed_ips="1"
uci -q delete network.wgclient.allowed_ips
uci add_list network.wgclient.allowed_ips=""
uci add_list network.wgclient.allowed_ips=""
uci commit network
/etc/init.d/network restart

Add route to server side LAN on VPN client.

uci set network.wgserver.route_allowed_ips="1"
uci -q delete network.wgserver.allowed_ips
uci add_list network.wgserver.allowed_ips=""
uci add_list network.wgserver.allowed_ips=""
uci commit network
/etc/init.d/network restart

Consider VPN network as private and assign VPN interface to LAN zone on VPN client.

uci del_list"wg0"
uci add_list"wg0"
uci commit firewall
/etc/init.d/firewall restart

Split gateway

If VPN gateway is not your LAN gateway. Implement plain routing between LAN network and VPN network assuming that:

  • - LAN network
  • - VPN gateway
  • - VPN network

Add port forwarding for VPN server on LAN gateway.

uci -q delete firewall.wg
uci set firewall.wg="redirect"
uci set"Redirect-WireGuard"
uci set firewall.wg.src="wan"
uci set firewall.wg.src_dport="51820"
uci set firewall.wg.dest="lan"
uci set firewall.wg.dest_ip=""
uci set"ipv4"
uci set firewall.wg.proto="udp"
uci set"DNAT"
uci commit firewall
/etc/init.d/firewall restart

Add route to VPN network via VPN gateway on LAN gateway.

uci -q delete network.vpn
uci set network.vpn="route"
uci set network.vpn.interface="lan"
uci set""
uci set network.vpn.gateway=""
uci commit network
/etc/init.d/network restart


Enable NAT6 with IPv6 masquerading if you have no public prefix for VPN6 network.

opkg update
opkg install kmod-ipt-nat6
cat << EOF > /etc/firewall.nat6
iptables-save -t nat \
| sed -e "/\s[DS]NAT\s/d" \
| ip6tables-restore -T nat
uci -q delete firewall.nat6
uci set firewall.nat6="include"
uci set firewall.nat6.path="/etc/firewall.nat6"
uci set firewall.nat6.reload="1"
uci commit firewall
/etc/init.d/firewall restart

DNS over VPN

Utilize DNS over VPN to prevent DNS leak.

Disable peer DNS and configure a VPN-routed DNS provider on OpenWrt client.

Modify the VPN connection using NetworkManager on Linux desktop client.

nmcli connection modify id WG_CON ipv4.dns-priority -90 ipv6.dns-priority -90

Kill switch

Prevent traffic leak on OpenWrt client isolating VPN interface in a separate firewall zone.

uci -q delete firewall.vpn
uci set firewall.vpn="zone"
uci set"vpn"
uci set firewall.vpn.input="REJECT"
uci set firewall.vpn.output="ACCEPT"
uci set firewall.vpn.forward="REJECT"
uci set firewall.vpn.masq="1"
uci set firewall.vpn.mtu_fix="1"
uci -q delete firewall.lan_vpn
uci set firewall.lan_vpn="forwarding"
uci set firewall.lan_vpn.src="lan"
uci set firewall.lan_vpn.dest="vpn"
uci del_list"wg0"
uci add_list"wg0"
uci set firewall.lan_wan.enabled="0"
uci commit firewall
/etc/init.d/firewall restart
This website uses cookies. By using the website, you agree with storing cookies on your computer. Also you acknowledge that you have read and understand our Privacy Policy. If you do not agree leave the website.More information about cookies
docs/guide-user/services/vpn/wireguard/extra.txt · Last modified: 2020/08/09 09:42 by vgaetera