[REOPEN] "unstable" SSH connection with Wireguard

Post new topic   Reply to topic    DD-WRT Forum Index -> Advanced Networking
Author Message
frashman
DD-WRT Novice


Joined: 19 Aug 2020
Posts: 17

PostPosted: Fri Sep 11, 2020 9:56    Post subject: [REOPEN] "unstable" SSH connection with Wireguard Reply with quote
Hi,

recently I switched from openvpn to wireguard to connect multiple debian and android clients. Im using an ASUS RT-ACU68U as wireguard server (oet2) for my clients and the router itself is a client to a commercial VPN provider (oet1). All traffic (local and wireguard clients) is routed through the commercial VPN. The endpoint for my wireguard clients is the ISP IP (wireguard client > ISP network > router > commercial wireguard VPN > internet).

Everything is working as before with openvpn and all clients can connect and communicate with each other with top speed. I'm using SSHFS to mount my data storage (a mini PC connected via ethernet) and here is the issue. It seems that the connection is unstable. While copying large files or "streaming" a movie from the storage, the connection is sometimes interrupted. Every Peer is affected. This is really annoying because my daily backup (borgbackup via SSH) fails almost every time.

So I tried different MTU settings (1460, 1420, 1400, 1300). With a MTU of 1460 the speed is very low. 1420 and lower is working fine expect the packet losses or whatever this is.

Here is an example:
Code:
user@10.0.1.40:~$ scp user@10.0.0.2:/data/test/* .
File1.test                                                      100%  472MB   2.6MB/s   03:05
File2.test                                                      100%  363MB   2.7MB/s   02:14
File3.test                                                       15%   76MB   3.5MB/s   01:58 ETA
ssh_dispatch_run_fatal: Connection to 10.0.0.2 port 22: message authentication code incorrect
lost connection


Just after the "lost connection" i can rerun the command and it is working like nothing happend - and maybe it is interrupted at another time.

Ping with 0.1s interval = 83% packet loss to Server
Code:
root@10.0.1.40:~# mtr -rw -c 100 -i 0.1 10.0.0.2
Start: 2020-09-11T10:33:03+0200
HOST: work          Loss%   Snt   Last   Avg  Best  Wrst StDev
  1.|-- 10.0.1.1       83.0%   100   20.0  20.5  19.6  22.3   0.8
  2.|-- 10.0.0.2       0.0%   100   20.4  21.6  18.7  59.0   4.8


Ping with 1s interval = 0% packet loss to Server
Code:
root@10.0.1.40:~# mtr -rw -c 100 -i 1 10.0.0.2
Start: 2020-09-11T10:34:54+0200
HOST: work          Loss%   Snt   Last   Avg  Best  Wrst StDev
  1.|-- 10.0.1.1       0.0%   100   28.8  21.2  18.6  28.8   1.8
  2.|-- 10.0.0.2       0.0%   100   19.9  21.2  19.0  29.3   1.8


server config:
Code:
root@10.0.0.1:~# wg showconf oet2
[Interface]
ListenPort = 51820
PrivateKey = xxxxxxxxxxxxxxx

*strip*

[Peer]
PublicKey = xxxxxxxxxxxxxxx
PresharedKey = xxxxxxxxxxxxxxx
AllowedIPs = 10.0.1.40/32
Endpoint = xxx.xxx.xxx.xxx:1598
PersistentKeepalive = 25


client config:
Code:
root@work:~# cat /etc/wireguard/wg0.conf
[Interface]
Address = 10.0.1.40/16
PrivateKey = xxxxxxxxxxxxxxx
ListenPort = 51820
DNS = 10.0.1.1
MTU = 1400
[Peer]
PublicKey = xxxxxxxxxxxxxxx
Endpoint = myISP.IP:51820
AllowedIPs = 0.0.0.0/0
PresharedKey = xxxxxxxxxxxxxxx
PersistentKeepalive = 25


Has someone an idea what i can do?


Last edited by frashman on Tue Sep 15, 2020 7:20; edited 2 times in total
Sponsor
egc
DD-WRT Guru


Joined: 18 Mar 2014
Posts: 12887
Location: Netherlands

PostPosted: Fri Sep 11, 2020 13:56    Post subject: Reply with quote
Which build?

See forum guide lines in my signature at the bottom of this post.

Also see Wireguard guides

_________________
Routers:Netgear R7000, R6400v1, R6400v2, EA6900 (XvortexCFE), E2000, E1200v1, WRT54GS v1.
Install guide R6400v2, R6700v3,XR300:https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=316399
Install guide R7800/XR500: https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=320614
Forum Guide Lines (important read):https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=324087
frashman
DD-WRT Novice


Joined: 19 Aug 2020
Posts: 17

PostPosted: Fri Sep 11, 2020 14:12    Post subject: Reply with quote
egc wrote:
Which build?


DD-WRT: v3.0-r43904

Debian Buster: wireguard-tools v1.0.20200513
egc
DD-WRT Guru


Joined: 18 Mar 2014
Posts: 12887
Location: Netherlands

PostPosted: Sat Sep 12, 2020 7:36    Post subject: Reply with quote
Those are not the newest versions especially form theWG tools.

Consider upgrading to the latest.

But is smells like an MTU problem remember also the client MTU settings often need to be adapted

_________________
Routers:Netgear R7000, R6400v1, R6400v2, EA6900 (XvortexCFE), E2000, E1200v1, WRT54GS v1.
Install guide R6400v2, R6700v3,XR300:https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=316399
Install guide R7800/XR500: https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=320614
Forum Guide Lines (important read):https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=324087
Per Yngve Berg
DD-WRT Guru


Joined: 13 Aug 2013
Posts: 6868
Location: Romerike, Norway

PostPosted: Sat Sep 12, 2020 8:35    Post subject: Reply with quote
To find the largest MTU, ping with the no fragmentation switch set.

ping -4 <host> -M do -s 1420

When set to large, the packets will no longer go through.
frashman
DD-WRT Novice


Joined: 19 Aug 2020
Posts: 17

PostPosted: Sat Sep 12, 2020 12:14    Post subject: Reply with quote
egc wrote:
Those are not the newest versions especially form theWG tools.

Consider upgrading to the latest.

But is smells like an MTU problem remember also the client MTU settings often need to be adapted


Okay, done. But the problem remains.

Per Yngve Berg wrote:
To find the largest MTU, ping with the no fragmentation switch set.

ping -4 <host> -M do -s 1420

When set to large, the packets will no longer go through.


I've seen this many times, but I have trouble understanding how it helps. If I set the MTU on the server and client side to 1400 bytes and try to ping 1420 bytes it doesn't work, and when I try ping 1372 bytes it works. No surprise in that. Can you please explain how to find the right MTU for the server and client? Does the size for server and client have to be the same or does the client have to be 28 bytes smaller?
egc
DD-WRT Guru


Joined: 18 Mar 2014
Posts: 12887
Location: Netherlands

PostPosted: Sat Sep 12, 2020 12:32    Post subject: Reply with quote
In the WG server setup guide is a troubleshooting section with some details
_________________
Routers:Netgear R7000, R6400v1, R6400v2, EA6900 (XvortexCFE), E2000, E1200v1, WRT54GS v1.
Install guide R6400v2, R6700v3,XR300:https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=316399
Install guide R7800/XR500: https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=320614
Forum Guide Lines (important read):https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=324087
Per Yngve Berg
DD-WRT Guru


Joined: 13 Aug 2013
Posts: 6868
Location: Romerike, Norway

PostPosted: Sat Sep 12, 2020 13:10    Post subject: Reply with quote
Run it with VPN disabled.

https://lists.zx2c4.com/pipermail/wireguard/2017-December/002201.html

Does you WAN use plain Ethernet (1500) or PPPoE?
frashman
DD-WRT Novice


Joined: 19 Aug 2020
Posts: 17

PostPosted: Sat Sep 12, 2020 16:49    Post subject: Reply with quote
Per Yngve Berg wrote:
Run it with VPN disabled.

https://lists.zx2c4.com/pipermail/wireguard/2017-December/002201.html

Does you WAN use plain Ethernet (1500) or PPPoE?


My WAN is using 1500.

The ping method didn't work for me. I got several good results with high MTU, but the packet lost with SSH was still there. So I tried more settings and it seems that an MTU of 1300 bytes on both sides is stable. I thought I had already tried this.

Anyway, thanks a lot for your help.
frashman
DD-WRT Novice


Joined: 19 Aug 2020
Posts: 17

PostPosted: Tue Sep 15, 2020 7:19    Post subject: Reply with quote
I closed this thread too soon. I'm still having connection issues. Now I have an MTU of 1000 and the interruptions are less frequent but still there.

Are there any other options you can think of?
Zyxx
DD-WRT Guru


Joined: 28 Dec 2018
Posts: 739

PostPosted: Tue Sep 15, 2020 10:19    Post subject: Reply with quote
Wireguard is only UDP, there are no mechanisms to resend pakets available compared to TCP/IP.
If a hop between "you" and "target" suffers from overload, it might also result in a lossy connection.

Does a mtr between "you" and "target" show any oddities?
I often use this syntax to force mtr to resolve AS names and doing udp:

mtr -4 your.target.xyz -u -b -z

(run it without VPN enabled ofc.)
frashman
DD-WRT Novice


Joined: 19 Aug 2020
Posts: 17

PostPosted: Tue Sep 15, 2020 10:50    Post subject: Reply with quote
Zyxx wrote:
Wireguard is only UDP, there are no mechanisms to resend pakets available compared to TCP/IP.
If a hop between "you" and "target" suffers from overload, it might also result in a lossy connection.

Does a mtr between "you" and "target" show any oddities?
I often use this syntax to force mtr to resolve AS names and doing udp:

mtr -4 your.target.xyz -u -b -z

(run it without VPN enabled ofc.)


I have no packet loss without a VPN. Everything seems to be fine. I've been using OpenVPN over UDP with the same setup for many years and haven't had any such problems. So I would like to rule out configuration or hardware problems - except Wireguard of course
SurprisedItWorks
DD-WRT Guru


Joined: 04 Aug 2018
Posts: 1447
Location: Appalachian mountains, USA

PostPosted: Tue Sep 15, 2020 14:32    Post subject: Reply with quote
You may need a lower mtu for oet2 than for oet1. After all, its packets via oet1 and your commercial provider pass through a different network than oet1 itself sees.
_________________
2x Netgear XR500 and 3x Linksys WRT1900ACSv2 on 53544: VLANs, VAPs, NAS, station mode, OpenVPN client (AirVPN), wireguard server (AirVPN port forward) and clients (AzireVPN, AirVPN, private), 3 DNSCrypt providers via VPN.
frashman
DD-WRT Novice


Joined: 19 Aug 2020
Posts: 17

PostPosted: Thu Sep 17, 2020 17:33    Post subject: Reply with quote
SurprisedItWorks wrote:
You may need a lower mtu for oet2 than for oet1. After all, its packets via oet1 and your commercial provider pass through a different network than oet1 itself sees.


This is already the case, but it is also unimportant as it is the client-to-client connection via Wireguard running over the ISP network. The commercial VPN is not involved.

oet1 (MTU 1420): commercial VPN > Router (NAT) > local clients, oet2
oet2 (MTU 1000): wireguard client > ISP > Router (VLAN2) > local client

the oet2 wireguard clients and local clients using oet1 as gateway, but the connection itself is established via ISP (or VLAN2)
SurprisedItWorks
DD-WRT Guru


Joined: 04 Aug 2018
Posts: 1447
Location: Appalachian mountains, USA

PostPosted: Thu Sep 17, 2020 22:41    Post subject: Reply with quote
Ah! Sometimes I just hope my ignorant ramblings will trigger someone else to have a thought that's actually useful! Very Happy
_________________
2x Netgear XR500 and 3x Linksys WRT1900ACSv2 on 53544: VLANs, VAPs, NAS, station mode, OpenVPN client (AirVPN), wireguard server (AirVPN port forward) and clients (AzireVPN, AirVPN, private), 3 DNSCrypt providers via VPN.
Display posts from previous:    Page 1 of 1
Post new topic   Reply to topic    DD-WRT Forum Index -> Advanced Networking All times are GMT

Navigation

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum