Simple utility to set the WSL2 subnet to a specific range

Overview

WSL subnet utility

This is a small Go utility to set the WSL2 host and subnet. It achieves this by:

  • deleting the existing WSL network
  • creating a new one with the specified subnet (defaulting to 192.168.100.0/24)

Windows automatically creates the WSL network when a WSL2 environment is started, so we need to pre-empt this by creating our own network with our settings before that happens.

Important notes

  • this needs to be done before starting any WSL2 (or Docker on WSL2) environments
  • if you need to do this afterwards, restart WSL2 environments by shutting them down with wsl --shutdown; they should work correctly after they're re-launched.
  • you may need to disable Docker auto-start: this needs to run first
  • the utility needs to be run in an elevated mode (administrator) in order to alter the network configuration
    • you'll get an Access denied error if you are not elevated
    • run in an elevated console
    • or schedule as a task (noted below)

Basic command line help can be obtained with wsl-subnet --help

Installing this as a task is possible via the Task Scheduler:

  • Use At system startup as the trigger
  • Run under the SYSTEM account

Build

cd src
go build .

This will yield a single, static executable: wsl-subnet.exe

References and acknowledgements

We're making use the Windows Host Compute Network interfaces to do this:

Fortunately, Microsoft has supplied the hcsshim Go library to interact with these interfaces at a higher level. This library is used by various projects, including (at some stage), Docker itself.

This is a simple utility inspired partly by the various Powershell scripts out there to control WSL booting and subnet assignment, including:

Check those out if you need something more complex.

You might also like...
Automatically register a list of domain names, add them to Cloudflare and set DNS records.

NameCannon Automatically register a list of domain names, add them as zones on Cloudflare, then add DNS records. Usage $ ./NameCannon --namesiloSecret

Zscan a scan blasting tool set
Zscan a scan blasting tool set

Zscan a scan blasting tool set 简介 Zscan是一个开源的内网端口扫描器、爆破工具和其他实用工具的集合体。以主机发现和端口扫描为基础,可以对mysql、mssql、redis、mongo、postgres、ftp、ssh等服务进行爆破,还有其他netbios、smb、

Tiny utility to download file from GitHub

gget I needed a way to download file from GitHub without going to its raw version and I made this tiny program. If there is a way to do it with a cURL

DNS benchmarking utility For Golang

DNSBench — DNS benchmarking utility Installation go get -u github.com/leonklingele/dnsbench/... dnsbench -help Run benchmark dnsbench -domains google.

Web app utility to get server list data from Minecraft servers.

Ping Web app utility to get server list data from Minecraft servers. Avalible at https://ping.turtley12.dev/app, Running yourself Before compiling and

RuuviBridge - Utility to bridge RuuviTag data between various sources and consumers

RuuviBridge RuuviBridge is designed to act as a "data bridge" between various so

MAC Address & Prefix Utility for Go

macaddr MAC Address & Prefix Utility for Go Installation go get -d github.com/thatmattlove/go-macaddr Usage Single MAC Address mac, err := macaddr.Pa

Fetch-npm-package - A small utility that can be used to fetch a given version of a NPM package

Use fetch-npm-package package version output-dir E.g. fetch-npm-package is

Utility to migate ChirpStack v3 data into ChirpStack v4.

ChirpStack v3 to v4 data-migration This utilty migrates data from a single ChirpStack Application Server instance and one or multiple ChirpStack Netwo

Owner
Michael Barber
Principal Engineer (C#) at Paddy Power in Dublin
Michael Barber
Use ICMP requests to check the alive subnet.

Doge-AliveCheck Use ICMP requests to check the alive subnet. Build go build -ldflags "-s -w" -trimpath Usage Doge-AliveCheck.exe

TimWhite 21 Aug 28, 2022
Automatically update your Windows hosts file with the WSL2 VM IP address

Automatically update your Windows hosts file with the WSL2 VM IP address

null 1.3k Sep 23, 2022
A pair of local reverse proxies (one in Windows, one in Linux) for Tailscale on WSL2

tailscale-wsl2 TL;DR Running two reverse proxies (one in Windows, one in the WSL2 Linux VM), the Windows Tailscale daemon can be accessed via WSL2: $

Danny Hermes 25 Aug 10, 2022
go HTTP client that makes it plain simple to configure TLS, basic auth, retries on specific errors, keep-alive connections, logging, timeouts etc.

goat Goat, is an HTTP client built on top of a standard Go http package, that is extremely easy to configure; no googling required. The idea is simila

VSPAZ 1 Jun 25, 2022
Simple endpoint to create chat for specific application.

About Chat System Simple endpoint to create chat for specific application. Note This endpoints depend on chat-system repoistory, so you ought to run c

null 0 Nov 20, 2021
Application written in Go which polls Time-series data at specific intervals and saves to persistent storage

TPoller Server Overview The purpose of this application is to poll time-series data per time interval from any (telemetry) application running a gRPC

Bartlomiej Mika 4 Feb 10, 2022
A proxy to hide NFT metadata during the sale and prevent people from sniping specific NFTs.

NFT Sale Proxy A proxy to hide NFT metadata during the sale and prevent people from sniping specific NFTs. Check alephao/nft-sale-proxy-examples to se

Aleph Retamal 24 Jul 27, 2022
A quick and dirty but useful tool to download each text/html page from the wayback machine for a specific domain and search for keywords within the saved content

wayback-keyword-search A quick and dirty but useful tool to download each text/html page from the wayback machine for a specific domain and search for

null 55 Sep 25, 2022
Capdns is a network capture utility designed specifically for DNS traffic. This utility is based on tcpdump.

Capdns is a network capture utility designed specifically for DNS traffic. This utility is based on tcpdump. Some of its features include: Unde

Infvie Envoy 10 Feb 26, 2022
🦄️ 🎃 👻 Clash Premium 规则集(RULE-SET),兼容 ClashX Pro、Clash for Windows 客户端。

简介 本项目生成适用于 Clash Premium 内核的规则集(RULE-SET),同时适用于所有使用 Clash Premium 内核的 Clash 图形用户界面(GUI)客户端。使用 GitHub Actions 北京时间每天早上 6:30 自动构建,保证规则最新。 说明 本项目规则集(RUL

Loyalsoldier 5.9k Sep 21, 2022