Skip to content

Instantly share code, notes, and snippets.

@axxapy
Last active September 1, 2025 03:36
Show Gist options
  • Select an option

  • Save axxapy/245769b4e2be04cc0780b03904360441 to your computer and use it in GitHub Desktop.

Select an option

Save axxapy/245769b4e2be04cc0780b03904360441 to your computer and use it in GitHub Desktop.
WSL network

In order to make wsl-hosted services accessible from outside of the windows machine, there are two options:

1. Bridge mode

  1. Shutdown WSL: wsl --shutdown
  2. Open Hyper-V Manager as administrator
  3. Select your pc, open Virtual Switch Manager
  4. Create new adapter, call it "WSL-Bridge"
  5. Set to "External network"
  6. open %USERPROFILE%/.wslconfig
  7. in [wsl2] section, add:
  8. `networkingMode = bridged`
    
  9. nvmSwitch = WSL-Bridge
  10. login into wsl
  11. sudo ip addr add 192.168.1.121/24 dev eth0
  12. sudo ip addr flush dev eth0
  13. sudo dhclient eth0

To make persistent

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.1

sudo netplan apply

2. Mirrored mode

Will share windows network device with wsl

in %USERPROFILE%/.wslconfig under [wsl2] add networkingMode = mirrored

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