microsoft / microsoft/WSL

Add Connection-specific DNS Suffix for WSL2 reachable networks to resolv.conf

Open
#8,522 3 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature
Dominant language
C++
Stars
33.7k
Forks
1.8k
Avg merge
3d 17h
Merged PRs (30d)
116

Description

**Is your feature request related to a problem? Please describe.**
Currently there's some mangling done by (probably) Windows virtual switch/DNS resolver? Not all DNS queries that work with Windows work in WSL2. For what's not working usually helps if I just add that specific Connection-specific DNS Suffix as `search SUFFIX` and eventually any domains from connection DNS Search List to `/etc/resolv.conf`.

In situations where I can use e.g. `ping host` on Windows I need to use `ping host.fully.qualified.domain.name` in WSL2 which is sometimes annoying.

**Describe the solution you'd like**
I'd like if `init` (or even better; some Windows side thing when connectivity changes re-) generated `/etc/resolv.conf` so that all known DNS lookup suffixes are automatically added as `search` stanzas. Maybe this could be sub-option of whether or not to generate `resolv.conf`.

**Describe alternatives you've considered**
Currently I am using simple script that is triggered by Windows Scheduler; Event type "Microsoft-Windows-NetworkProfile/Operational" and "Event Id" 1000. Script utilizes lame Powershell query to get suffixes:

``` powershell
Write-Host search @(Get-DnsClient | Select-Object -Property ConnectionSpecificSuffix | Where-Object {\$_.ConnectionSpecificSuffix -ne \"\"} | %{\$_.ConnectionSpecificSuffix})")
```

**Additional context**
I believe if WSL has access to network it should behave same (in terms of DNS resolver and other aspects) as host OS.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the init path that generates /etc/resolv.conf and inspect how connectivity changes are handled. Compare its behavior with the supplied PowerShell Get-DnsClient query and NetworkProfile event 1000; done means connection-specific DNS suffixes appear as search entries in resolv.conf after network changes.

Written by the indexing model from the issue text.

Assessment

Tech stack
linux, powershell
Domain
networking, operating-systems
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.