Good morning!!
For the past few months, I have had a site-to-site VPN configured between two R3G routers running OpenWrt 23.05.5 and WireGuard 5.15.167. I know there are newer versions, but since it works fine, I follow the first rule of IT: If it ain’t broke, don’t fix it.
For work reasons, I need all traffic to always exit through the IP of the server router (which, in turn, connects to the ISP router), regardless of where I am working from.
Currently, my setup looks like this:
Site A (server) – ISP router – Internet – ISP router – Site B (client)
Site A is configured with a ddns.net domain.
In 99.99% of cases, Site B is (or will be) behind an ISP router.
My current configuration works perfectly until one day, out of nowhere, the handshake fails. When that happens, even restarting the interface does not reconnect it, and sometimes—only sometimes—restarting the router or leaving it for a while fixes the issue and it reconnects.
I’ve read in several posts that this might be caused by a time difference between the clocks on each side of the VPN, but I also wouldn’t be surprised if I have a misconfiguration somewhere.
In what I believe is a somewhat crude approach, I configured all traffic from Site B to go through the VPN, which is the only connection with access to the WAN. This setup is probably improvable.
A few minutes ago, I made some modifications, and immediately after, the handshake worked again. I’m sharing them here in case they were the missing configuration or if there’s another possible solution.
In the Firewall zones, I modified “lan” so that in “Advanced settings” → “Covered devices” → “radio0.network1”, which I understand makes ONLY WiFi devices use this rule.
At the same time, I created a new zone called “lan2” with the same configuration, except that this one does have access to the “wan” zone. In “Covered devices”, I selected “br-lan”, which I understand redirects the traffic of the entire network to that rule, except for what was previously mentioned in the “lan” rule.
Does this setup make sense? Could this change fix the issue with reconnections and handshakes from now on? How can I improve it?
Really thanks in advance <3
I’m attaching some configuration details that I often see being requested, these settings are from Site B:
ubus call system board; \
uci export network; \
uci export dhcp; uci export firewall; \
ip -4 addr ; ip -4 ro li tab all ; ip -4 ru
{
"kernel": "5.15.167",
"hostname": "WG_MAD",
"system": "MediaTek MT7621 ver:1 eco:3",
"model": "Xiaomi Mi Router 3G",
"board_name": "xiaomi,mi-router-3g",
"rootfs_type": "squashfs",
"release": {
"distribution": "OpenWrt",
"version": "23.05.5",
"revision": "r24106-10cc5fcd00",
"target": "ramips/mt7621",
"description": "OpenWrt 23.05.5 r24106-10cc5fcd00"
}
}
package network
config interface 'loopback'
option device 'lo'
option proto 'static'
option ipaddr '127.0.0.1'
option netmask '255.0.0.0'
config globals 'globals'
option ula_prefix 'fdb2:e4eb:bc35::/48'
option packet_steering '1'
config device
option name 'br-lan'
option type 'bridge'
list ports 'lan1'
list ports 'lan2'
config interface 'lan'
option device 'br-lan'
option proto 'static'
option ipaddr '192.168.3.1'
option netmask '255.255.255.0'
option ip6assign '60'
list dns '8.8.8.8'
config interface 'wan'
option device 'wan'
option proto 'dhcp'
config interface 'wan6'
option device 'wan'
option proto 'dhcpv6'
config interface 'WG_MAD'
option proto 'wireguard'
option private_key ''
option listen_port '51820'
list addresses '10.10.10.2/24'
list dns '8.8.8.8'
option mtu '1280'
config wireguard_WG_MAD
option description 'WG_CEB'
option public_key ''
option route_allowed_ips '1'
option endpoint_host 'myhost.ddns.net'
option endpoint_port '51820'
list allowed_ips '0.0.0.0/0'
option persistent_keepalive '0'
package dhcp
config dnsmasq
option domainneeded '1'
option boguspriv '1'
option filterwin2k '0'
option localise_queries '1'
option rebind_protection '1'
option rebind_localhost '1'
option local '/lan/'
option domain 'lan'
option expandhosts '1'
option nonegcache '0'
option cachesize '1000'
option authoritative '1'
option readethers '1'
option leasefile '/tmp/dhcp.leases'
option resolvfile '/tmp/resolv.conf.d/resolv.conf.auto'
option nonwildcard '1'
option localservice '1'
option ednspacket_max '1232'
option filter_aaaa '0'
option filter_a '0'
config dhcp 'lan'
option interface 'lan'
option start '100'
option limit '150'
option leasetime '12h'
option dhcpv4 'server'
option dhcpv6 'server'
option ra 'server'
list ra_flags 'managed-config'
list ra_flags 'other-config'
config dhcp 'wan'
option interface 'wan'
option ignore '1'
config odhcpd 'odhcpd'
option maindhcp '0'
option leasefile '/tmp/hosts/odhcpd'
option leasetrigger '/usr/sbin/odhcpd-update'
option loglevel '4'
package firewall
config defaults
option input 'REJECT'
option output 'ACCEPT'
option forward 'REJECT'
option synflood_protect '1'
config zone
option name 'lan'
list network 'lan'
option input 'ACCEPT'
option output 'ACCEPT'
option forward 'ACCEPT'
list device 'radio0.network1'
config zone
option name 'wan'
list network 'wan'
list network 'wan6'
option input 'REJECT'
option output 'ACCEPT'
option forward 'REJECT'
option masq '1'
option mtu_fix '1'
config rule
option name 'Allow-DHCP-Renew'
option src 'wan'
option proto 'udp'
option dest_port '68'
option target 'ACCEPT'
option family 'ipv4'
config rule
option name 'Allow-Ping'
option src 'wan'
option proto 'icmp'
option icmp_type 'echo-request'
option family 'ipv4'
option target 'ACCEPT'
config rule
option name 'Allow-IGMP'
option src 'wan'
option proto 'igmp'
option family 'ipv4'
option target 'ACCEPT'
config rule
option name 'Allow-DHCPv6'
option src 'wan'
option proto 'udp'
option dest_port '546'
option family 'ipv6'
option target 'ACCEPT'
config rule
option name 'Allow-MLD'
option src 'wan'
option proto 'icmp'
option src_ip 'fe80::/10'
list icmp_type '130/0'
list icmp_type '131/0'
list icmp_type '132/0'
list icmp_type '143/0'
option family 'ipv6'
option target 'ACCEPT'
config rule
option name 'Allow-ICMPv6-Input'
option src 'wan'
option proto 'icmp'
list icmp_type 'echo-request'
list icmp_type 'echo-reply'
list icmp_type 'destination-unreachable'
list icmp_type 'packet-too-big'
list icmp_type 'time-exceeded'
list icmp_type 'bad-header'
list icmp_type 'unknown-header-type'
list icmp_type 'router-solicitation'
list icmp_type 'neighbour-solicitation'
list icmp_type 'router-advertisement'
list icmp_type 'neighbour-advertisement'
option limit '1000/sec'
option family 'ipv6'
option target 'ACCEPT'
config rule
option name 'Allow-ICMPv6-Forward'
option src 'wan'
option dest '*'
option proto 'icmp'
list icmp_type 'echo-request'
list icmp_type 'echo-reply'
list icmp_type 'destination-unreachable'
list icmp_type 'packet-too-big'
list icmp_type 'time-exceeded'
list icmp_type 'bad-header'
list icmp_type 'unknown-header-type'
option limit '1000/sec'
option family 'ipv6'
option target 'ACCEPT'
config rule
option name 'Allow-IPSec-ESP'
option src 'wan'
option dest 'lan'
option proto 'esp'
option target 'ACCEPT'
config rule
option name 'Allow-ISAKMP'
option src 'wan'
option dest 'lan'
option dest_port '500'
option proto 'udp'
option target 'ACCEPT'
config zone
option name 'vpn'
option input 'ACCEPT'
option output 'ACCEPT'
option forward 'REJECT'
list network 'WG_MAD'
config forwarding
option src 'lan'
option dest 'vpn'
config forwarding
option src 'vpn'
option dest 'wan'
config redirect
option dest 'vpn'
option target 'DNAT'
option name 'WG'
list proto 'udp'
option src 'wan'
option src_dport '51820'
option dest_ip '10.10.10.2/32'
option dest_port '51820'
config rule
option name 'Allow-LuCI-WAN'
list proto 'tcp'
option src 'wan'
option dest_port '80'
option target 'ACCEPT'
config rule
option name 'Allow-SSH-WAN'
list proto 'tcp'
option src 'wan'
option dest_port '22'
option target 'ACCEPT'
config zone
option name 'lan2'
option input 'ACCEPT'
option output 'ACCEPT'
option forward 'ACCEPT'
list network 'lan'
list device 'br-lan'
config forwarding
option src 'lan2'
option dest 'wan'
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1000
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
3: wan@eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP qlen 1000
inet 192.168.1.151/24 brd 192.168.1.255 scope global wan
valid_lft forever preferred_lft forever
8: br-lan: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP qlen 1000
inet 192.168.3.1/24 brd 192.168.3.255 scope global br-lan
valid_lft forever preferred_lft forever
9: WG_MAD: <POINTOPOINT,NOARP,UP,LOWER_UP> mtu 1280 qdisc noqueue state UNKNOWN qlen 1000
inet 10.10.10.2/24 brd 10.10.10.255 scope global WG_MAD
valid_lft forever preferred_lft forever
default dev WG_MAD scope link
10.10.10.0/24 dev WG_MAD scope link src 10.10.10.2
*.*.*.108 via 192.168.1.1 dev wan
192.168.1.0/24 dev wan scope link src 192.168.1.151
192.168.3.0/24 dev br-lan scope link src 192.168.3.1
local 10.10.10.2 dev WG_MAD table local scope host src 10.10.10.2
broadcast 10.10.10.255 dev WG_MAD table local scope link src 10.10.10.2
local 127.0.0.0/8 dev lo table local scope host src 127.0.0.1
local 127.0.0.1 dev lo table local scope host src 127.0.0.1
broadcast 127.255.255.255 dev lo table local scope link src 127.0.0.1
local 192.168.1.151 dev wan table local scope host src 192.168.1.151
broadcast 192.168.1.255 dev wan table local scope link src 192.168.1.151
local 192.168.3.1 dev br-lan table local scope host src 192.168.3.1
broadcast 192.168.3.255 dev br-lan table local scope link src 192.168.3.1
0: from all lookup local
32766: from all lookup main
32767: from all lookup default
Note: "*.*.*.108" was the public IP of the Site A (server).