Code Monkey home page Code Monkey logo

wsl2-hosts's Introduction

IMPORTANT: As of 13.05.2023 the WSL2 IP seems to no longer change on restart so this tool should no longer be needed.

What is this

The WSLW instance has an IP that changes on every boot up. This is a tool that can be used to automatically update the hosts file on Windows with the WSL2 IP.

How does this work?

The server (server.py) should run on the Windows machine. On WSL startup, you can start client.py inside WSL to send a message to the server containing the WSL IP. When the server receives the message, it updates all the lines in the Windows hosts file that contain '# WSL' by replacing the first word (the IP) (e.g. 172.29.249.42 mysite.local # WSL)

Prerequisites

Python on both Windows and the WSL instance.

How to run this?

  1. Make sure that all the lines in the hosts file have one IP per line and end with # WSL

172.29.249.42 mysite.local # WSL

  1. Copy the server.py file into server.pyw
  2. Create a Windows Task Scheduler task that starts server.pyw with admin privileges on Windows startup
  3. On WSL startup, run python client.py inside the WSL instance

wsl2-hosts's People

Contributors

stefanbutura avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.