Skip to content

Instantly share code, notes, and snippets.


Kyle Charlebois Kcharle

View GitHub Profile
Kcharle /
Last active Nov 30, 2021
(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\