Last active
June 6, 2021 09:28
-
-
Save ilwsm/28eb6459c12857e60d80753d16b929b0 to your computer and use it in GitHub Desktop.
Configure WSL2 network inerfaces
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# in sudo visudo | |
username ALL=(ALL:ALL) NOPASSWD: /usr/sbin/ip | |
# in ~/.bashrc | |
# 192.168.1.10 - my gateway | |
# 192.168.1.199 - my WSL2 static ip | |
EXIST=`ip ro show default via 192.168.1.10 dev eth0 | wc -l` | |
if ! [ $EXIST -eq 1 ] | |
then | |
echo Configure interfaces | |
sudo ip addr flush dev eth0 | |
sudo ip addr add 192.168.1.199/24 dev eth0 | |
sudo ip ro add default via 192.168.1.10 dev eth0 | |
echo | |
ip a show eth0 | |
ip ro | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://stackoverflow.com/questions/61002681/connecting-to-wsl2-server-via-local-network
https://github.com/shayne/wsl2-hacks/blob/master/README.md
https://www.reddit.com/r/bashonubuntuonwindows/comments/hdmspt/using_bridged_networking_to_get_outside_access_to/