teddysun / across

Across the Great Wall we can reach every corner in the world
https://teddysun.com
Apache License 2.0
4.94k stars 2.22k forks source link

How to change the mtu of interface wg0 #88

Closed Wjcccccccccc closed 2 years ago

Wjcccccccccc commented 2 years ago

I deployed my Kubernetes cluster on Wireguard, now I found out there are some packages lost, and I noticed the mtu of Client side is 1420, but the Server side is 8921.

ubuntu@ip-172-31-1-87:~$ systemctl status wg-quick@wg0.service 
● wg-quick@wg0.service - WireGuard via wg-quick(8) for wg0
     Loaded: loaded (/lib/systemd/system/wg-quick@.service; enabled; vendor preset: enabled)
     Active: active (exited) since Tue 2021-09-07 14:18:58 UTC; 12min ago
       Docs: man:wg-quick(8)
             man:wg(8)
             https://www.wireguard.com/
             https://www.wireguard.com/quickstart/
             https://git.zx2c4.com/wireguard-tools/about/src/man/wg-quick.8
             https://git.zx2c4.com/wireguard-tools/about/src/man/wg.8
    Process: 471 ExecStart=/usr/bin/wg-quick up wg0 (code=exited, status=0/SUCCESS)
    Process: 1104 ExecReload=/bin/bash -c exec /usr/bin/wg syncconf wg0 <(exec /usr/bin/wg-quick strip wg0) (code=exited, status=0/SUCCESS)
   Main PID: 471 (code=exited, status=0/SUCCESS)
      Tasks: 0 (limit: 4642)
     Memory: 576.0K
     CGroup: /system.slice/system-wg\x2dquick.slice/wg-quick@wg0.service

Sep 07 14:18:58 ip-172-31-1-87 wg-quick[471]: [#] echo WireGuard PreUp
Sep 07 14:18:58 ip-172-31-1-87 wg-quick[539]: WireGuard PreUp
Sep 07 14:18:58 ip-172-31-1-87 wg-quick[471]: [#] ip link add wg0 type wireguard
Sep 07 14:18:58 ip-172-31-1-87 wg-quick[471]: [#] wg setconf wg0 /dev/fd/63
Sep 07 14:18:58 ip-172-31-1-87 wg-quick[471]: [#] ip -4 address add 10.88.88.1/16 dev wg0
Sep 07 14:18:58 ip-172-31-1-87 wg-quick[471]: [#] ip link set mtu 8921 up dev wg0
Sep 07 14:18:58 ip-172-31-1-87 wg-quick[471]: [#] iptables -A FORWARD -i wg0 -j ACCEPT; iptables -A FORWARD -o wg0 -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
Sep 07 14:18:58 ip-172-31-1-87 systemd[1]: Finished WireGuard via wg-quick(8) for wg0.
Sep 07 14:19:02 ip-172-31-1-87 systemd[1]: Reloading WireGuard via wg-quick(8) for wg0.
Sep 07 14:19:02 ip-172-31-1-87 systemd[1]: Reloaded WireGuard via wg-quick(8) for wg0.

so how can I change this command:

ip link set mtu 8921 up dev wg0
Wjcccccccccc commented 2 years ago

I find it in the /usr/bin/wg-quick script.