Coder Social home page Coder Social logo

sa-dbilling / wsl2-dns-agent Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jacob-pro/wsl2-dns-agent

0.0 0.0 0.0 81 KB

Agent to automatically update your WSL2 resolv.conf when using a VPN

License: GNU General Public License v3.0

Rust 99.32% Makefile 0.68%

wsl2-dns-agent's Introduction

WSL2 DNS Agent for Cisco AnyConnect Users

Build status

An agent that automatically patches your WSL2 DNS configuration when using Cisco AnyConnect (or similar VPNs that block split-tunneling).

Thanks to @pyther for the inspiration for this tool.

How it works

  1. The agent detects when you connect/disconnect from a VPN.
  2. The agent finds the highest priority DNS servers being used by Windows.
  3. The agent detects your WSL2 distributions, for each distribution it ensures that generateResolvConf is disabled, and then writes the DNS servers to /etc/resolv.conf.

Usage

Ensure you have first fixed the route table for WSL2, and not broken the Windows DNS server priority in the process. See the guide for how to do this.

Simply download wsl2-dns-agent.exe from the releases page

Save it to your startup folder (%APPDATA%\Microsoft\Windows\Start Menu\Programs\Startup).

Launch the application.

Note: You must have the chattr command installed within your WSL2 distribution.

Diagnostics

You can view the application log by clicking on the tray icon and "View Log".

Note that this tool should apply DNS servers based on their priority in Windows.

For example, from Windows Command Prompt try running:

C:\Users\jdhalsey>nslookup.exe google.com
Server:  OpenWrt.lan
Address:  10.2.9.254

Non-authoritative answer: ...

Therefore 10.2.9.254 will be the first server written to /etc/resolv.conf. If the server is not what you expected then please look at the DNS guide

Advanced options

For advanced use cases you can edit the config file in %APPDATA%\WSL2 DNS Agent\config.toml

Example config:

show_notifications = false

# Default options for distributions
[defaults]
apply_dns = true
patch_wsl_conf = true
# If the distribution was previously Stopped, then shutdown once the DNS update is complete
# Note: This option is usually not needed on Windows 11 (because vmIdleTimeout will do it for you)
shutdown = false

# Set options for a specific distribution
[distributions.Ubuntu]
apply_dns = false

Note: the default configuration will ignore Docker Desktop, since the changes are unnecessary.

wsl2-dns-agent's People

Contributors

jacob-pro avatar omegaice 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.