magnific0 / wondershaper

Command-line utility for limiting an adapter's bandwidth
GNU General Public License v2.0
1.72k stars 257 forks source link

wondershaper/GCE - standard MTU causes fragmentation, some Google sites fail. #39

Closed mwoolweaver closed 4 years ago

mwoolweaver commented 4 years ago

MTU not being set properly will cause connectivity issues. It seems wondershaper sets a default value of 1500 which probably ok in most cases but google use a 1460 MTU for the GCE network so this will cause intermittent connectivity issues.

Wondershaper should mimic the GCE MTU of 1460 and everything seems to work as it should.

More info can be found in the links below

https://www.reddit.com/r/WireGuard/comments/aru07q/wireguard_slow/

https://github.com/StreisandEffect/streisand/issues/1089

https://github.com/StreisandEffect/streisand/issues/1552

magnific0 commented 4 years ago

@mwoolweaver I'm open to fixing this issue. However, my time and knowledge are limited. Where does wondershaper actually set this MTU to 1500? Can you provide a line?

https://github.com/magnific0/wondershaper/blob/master/wondershaper

Or is that a default value for tc?

mwoolweaver commented 4 years ago

It’s very possible that this is a default value. I haven’t used wondershaper in a couple months. I was using it to limit upload/download speeds of a python script I was using to tweet pihole stats amongst other things.

https://github.com/mwoolweaver/tweetStats

I’m not sure of the best way to address the issue for more users. My idea would be to check the interface that is be I used for internet access but I’m sure how to go about determining the which interface that is? Or would it better to use ifconfig to check for the lowest MTU value and set a value lower than that?

magnific0 commented 4 years ago

Thanks, that's what I understand too. In that case it's probably smarter to do it for the entire interface separate from wondershaper. The instructions for this are:

View current MTU

ifconfig

Outputs something like:

eth0      Link encap:Ethernet  HWaddr 00:0F:EA:91:04:07
         inet addr:192.168.1.2  Bcast:192.168.1.255  Mask:255.255.255.0
         inet6 addr: fe80::20f:eaff:fe91:407/64 Scope:Link
         UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
         RX packets:141567 errors:0 dropped:0 overruns:0 frame:0
         TX packets:141306 errors:0 dropped:0 overruns:0 carrier:0
         collisions:0 txqueuelen:1000
         RX bytes:101087512 (96.4 MiB)  TX bytes:32695783 (31.1 MiB)
         Interrupt:18 Base address:0xc000

Or use ip command:

ip link list

Which looks like:

1: lo:  mtu 16436 qdisc noqueue
   link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0:  mtu 1500 qdisc pfifo_fast qlen 1000
   link/ether 00:0f:ea:91:04:07 brd ff:ff:ff:ff:ff:ff
3: sit0:  mtu 1480 qdisc noop
   link/sit 0.0.0.0 brd 0.0.0.0

In this examples MTU set to 1500 for eth0. To change this to 1460 use either:

ifconfig eth0 mtu 1460

or

ip link set dev eth0 mtu 1460

Example taken from https://www.cyberciti.biz/faq/how-can-i-setup-the-mtu-for-my-network-interface/ accessed April 4, 2020.

mwoolweaver commented 4 years ago

But if I remember correctly wondershaper creates a network interface for itself to control the flow of traffic and that’s the interface that doesn’t have the MTU set. In my case the MTU for eth0 is 1460 and I had to adjust the interface for wondershaper to match that or I had this issue.