Skip to content

Instantly share code, notes, and snippets.

@zachallaun
Last active February 2, 2023 15:20
Show Gist options
  • Save zachallaun/83a6b9844cf6a447eb049a8176e5bb3a to your computer and use it in GitHub Desktop.
Save zachallaun/83a6b9844cf6a447eb049a8176e5bb3a to your computer and use it in GitHub Desktop.
Fixing Wireguard/Tailscale on WSL2

The default eth0 network interface on WSL2 has an MTU of 1280, which isn't sufficient for large packets sent over the Wireguard protocol.

You can confirm the issue by running ip a and seeing that the MTU of the eth0 interface is 1280.

To fix this, you need to set the MTU of the eth0 interface to 1500. This has to be done every time WSL starts.

Edit /etc/wsl.conf to include:

[boot]
command = "bash /etc/init-wsl.sh"

Create an /etc/init-wsl.sh:

#!/bin/bash
ip link set dev eth0 mtu 1500

Run wsl.exe --shutdown to restart WSL. Start a new terminal and run ip a to confirm that the MTU is set to 1500.

Other misc stuff:

WSL conf stuff if you're on a version of WSL with systemctl support:

/etc/wsl.conf:

[boot]
command = "bash /etc/init-wsl.sh"
systemd = true

This starts systemd so that you don't have to start services manually.

Unable to call windows commands

Magic command to fix being unable to call Windows commands from WSL2:

sudo update-binfmts --disable cli

This is apparently caused by the mono-runtime package; removing it also fixes the issue:

sudo apt remove mono-runtime
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment