Skip to content

Instantly share code, notes, and snippets.

View Kcharle's full-sized avatar

Kyle Charlebois Kcharle

View GitHub Profile
@Kcharle
Kcharle / wsl-auto-update-hosts.md
Last active November 30, 2021 14:38
(Python) WSL - Update Windows Hosts File IP's Automatically

WSL 2 - Automatically update all entries in /mnt/c/Windows/System32/drivers/etc/hosts

Requirements - Before running this script, you will need to add the following as the first line of your hosts file #previp:place_current_ip_here

Make sure to replace place_current_ip_here with the current value returned in wsl from hostname -I, this is what the script looks for the know what to replace.

To run - Open a Powershell instance with administrator privileges and execute the python script python \path\to\file\wsl-hosts-rename.py