Thanks to visit codestin.com
Credit goes to github.com

Skip to content

jacob-pro/wsl2-dns-agent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

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

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •