synology-wireguard: Synology DSM 6.2.2-24922 breaking WireGuard?
Two days ago my NAS restarted and upgraded to 6.2.2-24922 (from 6.2.1-23824-6) by itself. Since then I can no longer connect using WireGuard.
Changelog doesn’t seem to list anything obvious (https://www.synology.com/en-global/releaseNote/DS218j#ver_24922). My kernel compile is fresh, but the version is the same Linux Poseidon 3.10.105 #24922 SMP Fri May 10 02:48:35 CST 2019 armv7l GNU/Linux synology_armada38x_ds218j.
Does anyone else experience the same?
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 1
- Comments: 52 (18 by maintainers)
Links to this issue
Commits related to this issue
- Updated README (fixes #10) — committed to runfalk/synology-wireguard by runfalk 5 years ago
hi, My Workaround , Might help someone out there .
----Failed pair— SynoNetwork : 192.168.x.x/16 or /24 Wireguard : 192.168.x.x/16 or /24 ----working pair— SynoNetwork : 192.168.x.x/16 Wireguard : 192.169.x.x/16 ----working pair— SynoNetwork : 192.168.x.x/16 Wireguard : 10.0.x.x/16
Device : DS218 Play
eth0 : inet addr:192.168.123.97 wg0 : inet addr:192.168.114.1 wg1 : inet addr:10.0.1.1 wg2 : inet addr:192.169.114.1
cat /etc/VERSION
majorversion=“6” minorversion=“2” productversion=“6.2.3” buildphase=“GM” buildnumber=“25426” smallfixnumber=“0” builddate=“2020/05/12” buildtime=“05:59:17”
wg --version : wireguard-tools v1.0.20200319 - https://git.zx2c4.com/wireguard-tools/
pre-compiled package source : https://github.com/runfalk/synology-wireguard/releases
file : WireGuard-rtd1296-1.0.20200401.spk
Boot up scripts : ( as per github readme ).
Non-working config wg0
wg0.conf [Interface] Address = 192.168.114.1/16 ListenPort = XXXXX PrivateKey = ------- PostUp = iptables -A FORWARD -i %i -j ACCEPT; iptables -A FORWARD -o %i -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE; sleep 5; ip route add 192.168.0.0/16 dev %i PostDown = iptables -D FORWARD -i %i -j ACCEPT; iptables -D FORWARD -o %i -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE
[Peer] PublicKey = ------- AllowedIPs = 192.168.114.2/32
[Peer] PublicKey = ------- AllowedIPs = 192.168.114.3/32
[Peer] PublicKey = ------- AllowedIPs = 192.168.114.4/32
working config wg1
[Interface] Address = 10.0.1.1/16 PostUp = iptables -A FORWARD -i %i -j ACCEPT; iptables -A FORWARD -o %i -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE ; sleep 5 ; ip route add 10.0.0.0/16 dev %i PostDown = iptables -D FORWARD -i %i -j ACCEPT; iptables -D FORWARD -o %i -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE ListenPort = XXXXX PrivateKey = -------
[Peer] PublicKey = ------- AllowedIps = 10.0.1.2/32
[Peer] PublicKey = ------- AllowedIps = 10.0.1.3/32
[Peer] PublicKey = ------- AllowedIps = 10.0.1.4/32
working config wg2
wg2.conf [Interface] Address = 192.169.114.1/16 ListenPort = XXXXX PrivateKey = ------- PostUp = iptables -A FORWARD -i %i -j ACCEPT; iptables -A FORWARD -o %i -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE; sleep 5; ip route add 192.169.0.0/16 dev %i PostDown = iptables -D FORWARD -i %i -j ACCEPT; iptables -D FORWARD -o %i -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE
[Peer] PublicKey = ------- AllowedIPs = 192.169.114.2/32
[Peer] PublicKey = ------- AllowedIPs = 192.169.114.3/32
[Peer] PublicKey = ------- AllowedIPs = 192.169.114.4/32
I managed to add the route in the
PostUpwith a sleep as well.Here is my
PostUp:I did not need to change the
PostDownas the route is deleted onwg-quick down.Without the sleep, it complains about
wg0not being there.I just tested on a fresh restart and it seems to work. Hope it helps.
It looks like wireguard is no longer setting the return route. If this is set manually, the connection works. But I failed to write this in PostUp.
Steps to reproduce:
or
ip route add 10.0.1.1/16 dev wg0I debugged this issue for a bit and found something interesting. These are the commands that
wg-quick up wg0issues when I run it with mywg0.conf:so I played around with manually issuing these commands and found that switching the last two commands does not expose the issue, meaning when the second last command is issued only after the last command, the following route is correctly added to the routing table as desired (output from
ip route):Moreover, I monitored the routing table using
ip monitor allwhile runningwg-quick up wg0and this gave me the following output:where the first
[LINK]log belongs to theip link addcommand, the following[ADDR]and[ROUTE]logs belong to theip -4 addresscommand and finally the remaining[LINK]and[ROUTE]logs except for the last[ROUTE]log belong to theip link setcommand. The last[ROUTE]log always appears a bit delayed clearly well after thewg-quickcommand finished. It deletes the route we’re missing and that has previously and correctly been set up by theip link setcommand bringing up thewg0interface!Finally, manually issuing the four commands shows, that the route deletion only happens, when the last command is issued quickly enough after the second last one. So when waiting 3-5 seconds after the
ip -4 addresscommand, before issuing the finalip link setcommand, the route does not get deleted and stays in the routing table as desired.In conclusion, it actually seems like
wg-quickis setting up all its routing correctly, but somehow something triggers the removal of this one route. I suspect that some running process (likely unrelated to WireGuard) is monitoring the routing tables for[ADDR]events and then queues this (delayed) route deletion. I did not have any luck yet in identifying which process this might be though, so the last part remains just a guess due to lacking hard evidence.This doesn’t work for me :
PostUp = iptables -A FORWARD -i wg0 -j ACCEPT; iptables -t nat -A POSTROUTING -o ovs_bond0 -j MASQUERADE; sleep 5; ip route add 10.0.1.1/32 dev wg0;And this generate errors :
PostUp = iptables -A FORWARD -i wg0 -j ACCEPT; iptables -t nat -A POSTROUTING -o ovs_bond0 -j MASQUERADE; sleep 5; ip route add 10.0.1.1/24 dev wg0;I have to use full mask like beyond to make it works properly :
PostUp = iptables -A FORWARD -i wg0 -j ACCEPT; iptables -t nat -A POSTROUTING -o ovs_bond0 -j MASQUERADE; sleep 5; ip route add 10.0.1.0/24 dev wg0;