In order to make wsl-hosted services accessible from outside of the windows machine, there are two options:
- Shutdown WSL:
wsl --shutdown - Open Hyper-V Manager as administrator
- Select your pc, open Virtual Switch Manager
- Create new adapter, call it "WSL-Bridge"
- Set to "External network"
- open %USERPROFILE%/.wslconfig
- in
[wsl2] section, add: -
`networkingMode = bridged` nvmSwitch = WSL-Bridge- login into wsl
sudo ip addr add 192.168.1.121/24 dev eth0sudo ip addr flush dev eth0sudo dhclient eth0
vim /etc/netplan/01-netcfg.yaml
network:
version: 2
renderer: networkd
ethernets:
eth0:
dhcp4: yes
addresses: [192.168.1.121/24]
routes:
- to: default
via: 192.168.1.1sudo netplan apply
Will share windows network device with wsl
in %USERPROFILE%/.wslconfig under [wsl2] add networkingMode = mirrored