Skip to content

Instantly share code, notes, and snippets.

@Renan-Di
Last active October 27, 2022 12:51
Show Gist options
  • Save Renan-Di/348a8b795c3e8ddfde238b0317c3f88c to your computer and use it in GitHub Desktop.
Save Renan-Di/348a8b795c3e8ddfde238b0317c3f88c to your computer and use it in GitHub Desktop.
Configure mtu inside wsl to avoid conectivity problems when using vpn
#! /bin/bash
mkdir ~/start-scripts
cat <<EOF >> ~/start-scripts/change-mtu.sh
#! /bin/bash
ip link set dev eth0 mtu 1350
EOF
chmod +x ~/start-scripts/change-mtu.sh
echo "sudo ~/start-scripts/change-mtu.sh" >> ~/.bashrc
sudo -i
echo "$USER ALL=NOPASSWD: $HOME/start-scripts/change-mtu.sh" | EDITOR='tee -a' sudo -n -e /etc/sudoers.d/mtu
@josetesan
Copy link

You can also run
echo -e "wsl.exe -u root ip link set dev eth0 mtu 1350" >> ~/.bashrc

and it will work swell.

@RobertKillick
Copy link

RobertKillick commented Oct 27, 2022

You can also run
echo -e "wsl.exe -u root ip link set dev eth0 mtu 1350" >> ~/.bashrc

and it will work swell.

This is the tidy little solution I was looking for, thanks!

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