Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set mtu to 1280 #40

Closed
ghost opened this issue Aug 23, 2020 · 5 comments
Closed

Set mtu to 1280 #40

ghost opened this issue Aug 23, 2020 · 5 comments
Labels
enhancement New feature or request

Comments

@ghost
Copy link

ghost commented Aug 23, 2020

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.

@ViRb3
Copy link
Owner

ViRb3 commented Aug 24, 2020

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.

@ghost
Copy link
Author

ghost commented Aug 24, 2020

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.

@ViRb3
Copy link
Owner

ViRb3 commented Aug 24, 2020

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:

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.

@ViRb3 ViRb3 added the enhancement New feature or request label Aug 24, 2020
@ghost
Copy link
Author

ghost commented Aug 25, 2020

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).

@ViRb3
Copy link
Owner

ViRb3 commented Aug 25, 2020

I agree with you. I will set the default MTU to 1280 and leave an optimization notice in the README. Thanks a lot!

@ViRb3 ViRb3 closed this as completed in bd80ecf Aug 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant