Set mtu to 1280
opened this issue · comments
Hello! Thank you so much for this.
The only problem I've faced is that no mtu value is set in the generated profile which results in the connection not working properly (ping&dns would usually work but https browsing never does).
In order to fix this, we need to set the mtu of the wg interface to 1280 which is the same value set by the official Android client. After this change the connection works just like the official Android client.
Do you have an explanation of why reducing the MTU makes your internet work? I"ve been using the default MTU (1480?) for almost a year without any issues. I am happy to make this change if we can prove it is needed.
You could check with the ping command to see that the mtu value that needs to be set is supposed to be lower. https://kb.netgear.com/19863/Ping-Test-to-determine-Optimal-MTU-Size-on-Router
I made a small bash script that automates the instructions above and makes it work on linux. It does take some time (less than 10 secs) : https://paste.debian.net/1161002/
If you decide to use the script run it like this: ./script.sh 1.1.1.1
.
While the mtu value the script keeps giving me is 1392 (which is probably works better), the cf's android client has it set to 1280 so I'd rather just use whatever they use on their official android client.
Sorry I can't give you any explanation besides that it worked for me.
Thank you for the information! I ran some tests myself and here's what I found:
- Windows 10,
netsh interface ipv4 show subinterfaces
:- Wi-fi: 1500
- Wireguard (default): 1420
- Android 9,
cat /sys/class/net/*/mtu
:- wlan0: 1500
- tun0 (Wireguard through 1.1.1.1 app): 1280
I did some more reading on the choice of a MTU, and here are some references:
- https://keremerkan.net/posts/wireguard-mtu-fixes/
- https://en.wikipedia.org/wiki/Maximum_transmission_unit
Essentially, the difference comes down to how you are connected to the internet - if through PPPoE, then the maximum MTU supported is usually 1420, while for direct Ethernet connection it should be 1500. This is sometimes mitigated by the router, as it can forcefully fragment frames that are too large, but this causes excess CPU usage and you may not always have such a router. Cloudflare seem to have gone for the lowest possible MTU to ensure highest compatibility, while still supporting IPv6 - that is - MTU of 1280. I ran some quick tests and performance with a MTU of 1280 seems to be slightly worse for me than the default 1420, but I will run better testing tomorrow and report here.
While it's slightly worse to have 1280 mtu than the precise mtu for your network setup, it would still be better than having it not work by default.
It's better to have defaults that work for most people and then leave the optimizations for people who are capable of that. I've seen some issues here that I think were caused by mtu problems (#39 #32 and #16 ).
I also want to note that while leaving the mtu as default would rarely work on my network, my speed is more than halved. Here are my speedtest stats:
- No Warp: 110-120Mbps
- With warp and default 1420 mtu: 50Mbps
- With warp and 1280 mtu: 110-120Mbps
- With warp and 1392 mtu: 110-120Mbps
I don't have any speed change with warp when my mtu is set properly (1280 vs 1392).
I agree with you. I will set the default MTU to 1280 and leave an optimization notice in the README. Thanks a lot!