zerotier / ZeroTierOne

A Smart Ethernet Switch for Earth
https://zerotier.com
Other
13.94k stars 1.62k forks source link

zerotier-cli set <my_network_id> mtu=1300 does not apply #2326

Closed nszceta closed 5 days ago

nszceta commented 3 weeks ago
$ sudo zerotier-cli set <my_network_id> mtu=1300
$ sudo zerotier-cli get <my_network_id> mtu
1300
$ ip link show ztbpamon2r
4: ztbpamon2r: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1300 qdisc pfifo_fast state UNKNOWN mode DEFAULT group default qlen 1000
    link/ether <censored>
$ sudo zerotier-cli set <my_network_id> mtu=1300
$ sudo zerotier-cli get <my_network_id> mtu
2800
$ ip link show ztbpamon2r
4: ztbpamon2r: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 2800 qdisc pfifo_fast state UNKNOWN mode DEFAULT group default qlen 1000
    link/ether <censored>
sudo zerotier-cli set <my_network_id> mtu=1300

No

$ zerotier-one --version
ZeroTier One version 1.14.0

$ zerotier-cli --version
ZeroTier One version 1.14.0 build 0 (platform 1 arch 4)

Linux raspberrypi 6.6.28+rpt-rpi-v8 #1 SMP PREEMPT Debian 1:6.6.28-1+rpt1 (2024-04-22) aarch64 GNU/Linux

My current workaround:

$ cat /etc/systemd/system/zt-mtu-monitor.service 
[Unit]
Description=Monitor and set MTU for ZT interfaces
After=network.target
StartLimitIntervalSec=0

[Service]
Type=simple
ExecStart=/bin/bash -c 'while true; do for i in $(ip -o link show | awk -F": " \'/zt/  {print $2}\'); do ip link set $i mtu 1300 || true; done; sleep 5; done'
Restart=always
RestartSec=5
StartLimitBurst=0

[Install]
WantedBy=multi-user.target
nszceta commented 2 weeks ago

This workaround is 100% necessary for certain endpoints to be reachable at all behind certain hotspots. They are connected to the hotspot over an ethernet connection which may be why ZT erroneously believes the connection is capable of a high MTU. Unless MTU is 1300 connections completely stall out to these endpoints. This is a critical problem.

joseph-henry commented 1 week ago

Hey, sorry that it isn't clear that you can't change that property via the CLI. It's reasonable to assume you could!

What you can do instead is change the MTU for the network from the Central API like so:

curl -X POST -H "Authorization: token xxxxxxxxxx" https://api.zerotier.com/api/v1/network/<nwid> -d '{ "config": { "mtu": 1300 } }'
nszceta commented 1 week ago

Sweet I'll give it a shot

nszceta commented 1 week ago

What are the consequences of having MTU set to 1300 for my devices behind a hotspot and 2800 for everything else on that network?

joseph-henry commented 1 week ago

I think you might just see some difference in throughput performance. Depending on what type of traffic you're sending an MTU difference of even 1 could radically change performance if the packet division point isn't optimal. I'd play around with the number to find what's right for you.