Skip to content

Instantly share code, notes, and snippets.

@nothingrealhappen
Last active October 31, 2024 03:24
Show Gist options
  • Save nothingrealhappen/69d17ecc3b978456f2a7404ca128fcb5 to your computer and use it in GitHub Desktop.
Save nothingrealhappen/69d17ecc3b978456f2a7404ca128fcb5 to your computer and use it in GitHub Desktop.
static ip for wsl

create /etc/init.wsl for below contents

#!/bin/bash
ip addr del $(ip addr show eth0 | grep 'inet ' | awk '{print $2}') dev eth0
ip addr add 192.168.1.xxx/24 dev eth0
# point to your gateway
ip route add default via 192.168.1.xxx dev eth0
# /etc/wsl.conf
[network]
generateResolvConf = false

[boot]
command = /etc/init.wsl

DNS settings:

# /etc/resolv.conf
# change to your dns server or public one
nameserver xxx.xx.x.x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment