Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save benduran/426abb66f6f266c5901024a3e424370b to your computer and use it in GitHub Desktop.
Save benduran/426abb66f6f266c5901024a3e424370b to your computer and use it in GitHub Desktop.
Set MTU size in WSL to fix discrepancies between VPN clients on Windows Host and the WSL machine

Update MTU without entering a password¶

This corrects issues you might have with various VPN Clients having discrepancies with MTU size between WSL and the Windows Host.

Create a file /usr/local/sbin/mtu and add the following:

#!/bin/bash

ip link set dev eth0 mtu 1400

Then update the permissions by running sudo chmod u+x,go-rwx /usr/local/sbin/mtu

Next create /etc/sudoers.d/mtu using the command sudo visudo -f /etc/sudoers.d/mtu. Now add the following to the file, replacing <YOUR_USERNAME_HERE> with the output of whoami:

<YOUR_USERNAME_HERE> ALL=(root) NOPASSWD: /usr/local/sbin/mtu

Finally, in your .zshrc or .bashrc add the line:

sudo mtu

To apply your changes, exit and run wsl --shutdown from Powershell.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment