DNS: Simplify dns logic and switch to using 'search' instead of 'domain' which is obsolete. (#14133)
* DNS: Simplify dns logic and switch to using 'search' instead of 'domain' which is obsolete. * add optional header for natnetworking * format * extend configuration test for virtioproxy networking mode --------- Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com>
Ben Hillis committed
Feb 2, 2026 at 16:06 UTC
8aadbb4da514abff4df6067d04d8f4893d85ea68
13 files changed
+67
-131
src/linux/init/GnsEngine.cpp
+5
-9
@@ -315,21 +315,17 @@ void GnsEngine::ProcessDNSChange(Interface& interface, const wsl::shared::hns::D
315
content << L"nameserver " << server << L"\n";
316
}
317
318
- if (!payload.Domain.empty())
319
- {
320
- content << L"domain " << payload.Domain << L"\n";
321
- }
322
-
318
+ // Use 'search' for DNS suffixes.
319
+ // Per resolv.conf(5): "The domain directive is an obsolete name for the search directive
320
+ // that handles one search list entry only."
321
+ // See: https://man7.org/linux/man-pages/man5/resolv.conf.5.html
322
if (!payload.Search.empty())
323
{
324
content << L"search " << wsl::shared::string::Join(wsl::shared::string::Split(payload.Search, L','), L' ') << L"\n";
325
}
326
327
GNS_LOG_INFO(
329
- "Setting DNS server domain to {}: {} on interfaceName {} ",
330
- payload.Domain.c_str(),
331
- content.str().c_str(),
332
- interface.Name().c_str());
328
+ "Setting DNS search to {}: {} on interfaceName {} ", payload.Search.c_str(), content.str().c_str(), interface.Name().c_str());
329
330
std::wofstream resolvConf;
331
resolvConf.exceptions(std::ofstream::badbit | std::ofstream::failbit);
src/windows/common/NatNetworking.cpp
+13
-22
@@ -26,8 +26,13 @@ static wil::srwlock g_endpointsInUseLock;
26
static std::vector<GUID> g_endpointsInUse;
27
28
NatNetworking::NatNetworking(
29
- HCS_SYSTEM system, wsl::windows::common::hcs::unique_hcn_network&& network, GnsChannel&& gnsChannel, Config& config, wil::unique_socket&& dnsHvsocket) :
30
- m_system(system), m_config(config), m_network(std::move(network)), m_gnsChannel(std::move(gnsChannel))
29
+ HCS_SYSTEM system,
30
+ wsl::windows::common::hcs::unique_hcn_network&& network,
31
+ GnsChannel&& gnsChannel,
32
+ Config& config,
33
+ wil::unique_socket&& dnsHvsocket,
34
+ LPCWSTR dnsOptions) :
35
+ m_system(system), m_config(config), m_network(std::move(network)), m_dnsOptions(dnsOptions), m_gnsChannel(std::move(gnsChannel))
36
{
37
m_connectivityTelemetryEnabled = config.EnableTelemetry && !WslTraceLoggingShouldDisableTelemetry();
38
@@ -48,7 +53,7 @@ NatNetworking::NatNetworking(
53
// prioritized means:
54
// - can only set 3 DNS servers (Linux limitation)
55
// - when there are multiple host connected interfaces, we need to use the DNS servers from the most-likely-to-be-used interface on the host
51
- m_mirrorDnsInfo.emplace();
56
+ m_useMirrorDnsSettings = true;
57
}
58
}
59
@@ -337,7 +342,7 @@ void NatNetworking::Initialize()
342
UpdateDns(endpointProperties.GatewayAddress.c_str());
343
344
// if using the shared access DNS proxy, ensure that the shared access service is allowed inbound UDP access.
340
- if (!m_mirrorDnsInfo && !m_dnsTunnelingResolver)
345
+ if (!m_useMirrorDnsSettings && !m_dnsTunnelingResolver)
346
{
347
// N.B. This rule works around a host OS issue that prevents the DNS proxy from working on older versions of Windows.
348
ConfigureSharedAccessFirewallRule();
@@ -433,35 +438,22 @@ _Requires_lock_held_(m_lock)
438
void NatNetworking::UpdateDns(std::optional<PCWSTR> gatewayAddress) noexcept
439
try
440
{
436
- if (!m_dnsTunnelingResolver && !m_mirrorDnsInfo && !gatewayAddress)
441
+ if (!m_dnsTunnelingResolver && !m_useMirrorDnsSettings && !gatewayAddress)
442
{
443
return;
444
}
445
446
networking::DnsInfo latestDnsSettings{};
447
443
- // true if the "domain" entry of /etc/resolv.conf should be configured
444
- // Note: the "domain" entry allows a single DNS suffix to be configured
445
- bool configureLinuxDomain = false;
446
-
448
// NAT mode with DNS tunneling
449
if (m_dnsTunnelingResolver)
450
{
451
latestDnsSettings = HostDnsInfo::GetDnsTunnelingSettings(m_dnsTunnelingIpAddress);
452
}
453
// NAT mode without Shared Access DNS proxy
453
- else if (m_mirrorDnsInfo)
454
+ else if (m_useMirrorDnsSettings)
455
{
455
- m_mirrorDnsInfo->UpdateNetworkInformation();
456
- const auto settings = m_mirrorDnsInfo->GetDnsSettings(DnsSettingsFlags::IncludeVpn);
457
-
458
- latestDnsSettings.Servers = std::move(settings.Servers);
459
-
460
- if (!settings.Domains.empty())
461
- {
462
- latestDnsSettings.Domains.emplace_back(std::move(settings.Domains.front()));
463
- configureLinuxDomain = true;
464
- }
456
+ latestDnsSettings = HostDnsInfo::GetDnsSettings(DnsSettingsFlags::IncludeVpn);
457
}
458
// NAT mode with Shared Access DNS proxy
459
else if (gatewayAddress)
@@ -472,11 +464,10 @@ try
464
465
if (latestDnsSettings != m_trackedDnsSettings)
466
{
475
- auto dnsNotification = BuildDnsNotification(latestDnsSettings, configureLinuxDomain);
467
+ auto dnsNotification = BuildDnsNotification(latestDnsSettings, m_dnsOptions);
468
469
WSL_LOG(
470
"NatNetworking::UpdateDns",
479
- TraceLoggingValue(dnsNotification.Domain.c_str(), "domain"),
471
TraceLoggingValue(dnsNotification.Options.c_str(), "options"),
472
TraceLoggingValue(dnsNotification.Search.c_str(), "search"),
473
TraceLoggingValue(dnsNotification.ServerList.c_str(), "serverList"));
src/windows/common/NatNetworking.h
+14
-2
@@ -18,7 +18,13 @@ namespace wsl::core {
18
class NatNetworking final : public INetworkingEngine
19
{
20
public:
21
- NatNetworking(HCS_SYSTEM system, wsl::windows::common::hcs::unique_hcn_network&& network, GnsChannel&& gnsChannel, Config& config, wil::unique_socket&& dnsHvsocket);
21
+ NatNetworking(
22
+ HCS_SYSTEM system,
23
+ wsl::windows::common::hcs::unique_hcn_network&& network,
24
+ GnsChannel&& gnsChannel,
25
+ Config& config,
26
+ wil::unique_socket&& dnsHvsocket,
27
+ LPCWSTR dnsOptions = LX_INIT_RESOLVCONF_FULL_HEADER);
28
~NatNetworking() override;
29
30
// Note: This class cannot be moved because m_networkNotifyHandle captures a 'this' pointer.
@@ -69,12 +75,18 @@ private:
75
// The latest DNS settings configured in Linux
76
_Guarded_by_(m_lock) networking::DnsInfo m_trackedDnsSettings {};
77
78
+ // If true, DNS settings are retrieved from host adapters (mirrored mode)
79
+ // rather than using the shared access DNS proxy
80
+ bool m_useMirrorDnsSettings = false;
81
+
82
+ // Options/header for /etc/resolv.conf
83
+ LPCWSTR m_dnsOptions = nullptr;
84
+
85
GnsChannel m_gnsChannel;
86
std::shared_ptr<networking::NetworkSettings> m_networkSettings;
87
networking::EphemeralHcnEndpoint m_endpoint;
88
ULONG m_networkMtu = 0;
89
77
- std::optional<networking::HostDnsInfo> m_mirrorDnsInfo;
90
networking::unique_notify_handle m_networkNotifyHandle{};
91
};
92
src/windows/common/VirtioNetworking.cpp
+6
-5
@@ -14,11 +14,12 @@ using wsl::core::VirtioNetworking;
14
static constexpr auto c_loopbackDeviceName = TEXT(LX_INIT_LOOPBACK_DEVICE_NAME);
15
16
VirtioNetworking::VirtioNetworking(
17
- GnsChannel&& gnsChannel, bool enableLocalhostRelay, std::shared_ptr<GuestDeviceManager> guestDeviceManager, wil::shared_handle userToken) :
17
+ GnsChannel&& gnsChannel, bool enableLocalhostRelay, LPCWSTR dnsOptions, std::shared_ptr<GuestDeviceManager> guestDeviceManager, wil::shared_handle userToken) :
18
m_guestDeviceManager(std::move(guestDeviceManager)),
19
m_userToken(std::move(userToken)),
20
m_gnsChannel(std::move(gnsChannel)),
21
- m_enableLocalhostRelay(enableLocalhostRelay)
21
+ m_enableLocalhostRelay(enableLocalhostRelay),
22
+ m_dnsOptions(dnsOptions)
23
{
24
}
25
@@ -66,7 +67,7 @@ void VirtioNetworking::Initialize()
67
}
68
69
// Get initial DNS settings for device options.
69
- auto initialDns = m_dnsUpdateHelper.GetCurrentDnsSettings(networking::DnsSettingsFlags::IncludeVpn);
70
+ auto initialDns = networking::HostDnsInfo::GetDnsSettings(networking::DnsSettingsFlags::IncludeVpn);
71
if (!initialDns.Servers.empty())
72
{
73
if (device_options.tellp() > 0)
@@ -260,7 +261,7 @@ try
261
UpdateMtu();
262
263
// Check for DNS changes and send update if needed.
263
- auto currentDns = m_dnsUpdateHelper.GetCurrentDnsSettings(networking::DnsSettingsFlags::IncludeVpn);
264
+ auto currentDns = networking::HostDnsInfo::GetDnsSettings(networking::DnsSettingsFlags::IncludeVpn);
265
if (currentDns != m_trackedDnsSettings)
266
{
267
m_trackedDnsSettings = currentDns;
@@ -274,7 +275,7 @@ void VirtioNetworking::SendDnsUpdate(const networking::DnsInfo& dnsSettings)
275
hns::ModifyGuestEndpointSettingRequest<hns::DNS> notification{};
276
notification.RequestType = hns::ModifyRequestType::Update;
277
notification.ResourceType = hns::GuestEndpointResourceType::DNS;
277
- notification.Settings = networking::BuildDnsNotification(dnsSettings);
278
+ notification.Settings = networking::BuildDnsNotification(dnsSettings, m_dnsOptions);
279
m_gnsChannel.SendHnsNotification(ToJsonW(notification).c_str(), m_adapterId);
280
}
281
src/windows/common/VirtioNetworking.h
+2
-2
@@ -13,7 +13,7 @@ namespace wsl::core {
13
class VirtioNetworking : public INetworkingEngine
14
{
15
public:
16
- VirtioNetworking(GnsChannel&& gnsChannel, bool enableLocalhostRelay, std::shared_ptr<GuestDeviceManager> guestDeviceManager, wil::shared_handle userToken);
16
+ VirtioNetworking(GnsChannel&& gnsChannel, bool enableLocalhostRelay, LPCWSTR dnsOptions, std::shared_ptr<GuestDeviceManager> guestDeviceManager, wil::shared_handle userToken);
17
~VirtioNetworking();
18
19
// Note: This class cannot be moved because m_networkNotifyHandle captures a 'this' pointer.
@@ -49,12 +49,12 @@ private:
49
std::optional<GnsPortTrackerChannel> m_gnsPortTrackerChannel;
50
std::shared_ptr<networking::NetworkSettings> m_networkSettings;
51
bool m_enableLocalhostRelay;
52
+ LPCWSTR m_dnsOptions = nullptr;
53
GUID m_localhostAdapterId;
54
GUID m_adapterId;
55
56
std::optional<ULONGLONG> m_interfaceLuid;
57
ULONG m_networkMtu = 0;
57
- networking::DnsUpdateHelper m_dnsUpdateHelper;
58
networking::DnsInfo m_trackedDnsSettings;
59
60
// Note: this field must be destroyed first to stop the callbacks before any other field is destroyed.
src/windows/common/WslCoreHostDnsInfo.cpp
+16
-32
@@ -105,12 +105,6 @@ wsl::core::networking::DnsInfo wsl::core::networking::HostDnsInfo::GetDnsTunneli
105
return dnsInfo;
106
}
107
108
-std::vector<wsl::core::networking::IpAdapterAddress> wsl::core::networking::HostDnsInfo::GetAdapterAddresses()
109
-{
110
- std::lock_guard<std::mutex> lock(m_lock);
111
- return m_addresses;
112
-}
113
-
108
std::vector<std::string> wsl::core::networking::HostDnsInfo::GetDnsServerStrings(
109
_In_ const PIP_ADAPTER_DNS_SERVER_ADDRESS& FirstDnsServer, _In_ USHORT IpFamilyFilter, _In_ USHORT MaxValues)
110
{
@@ -233,7 +227,7 @@ std::vector<std::string> wsl::core::networking::HostDnsInfo::GetInterfaceDnsSuff
227
228
wsl::core::networking::DnsInfo wsl::core::networking::HostDnsInfo::GetDnsSettings(_In_ DnsSettingsFlags Flags)
229
{
236
- std::vector<IpAdapterAddress> Addresses = GetAdapterAddresses();
230
+ std::vector<IpAdapterAddress> Addresses = AdapterAddresses::GetCurrent();
231
232
auto RemoveFilter = [&](const IpAdapterAddress& Address) {
233
// Ignore interfaces that are not currently "up".
@@ -326,12 +320,6 @@ wsl::core::networking::DnsInfo wsl::core::networking::HostDnsInfo::GetDnsSetting
320
return DnsSettings;
321
}
322
329
-void wsl::core::networking::HostDnsInfo::UpdateNetworkInformation()
330
-{
331
- std::lock_guard<std::mutex> lock(m_lock);
332
- m_addresses = AdapterAddresses::GetCurrent();
333
-}
334
-
323
std::string wsl::core::networking::GenerateResolvConf(_In_ const DnsInfo& Info)
324
{
325
std::string contents{};
@@ -345,7 +333,10 @@ std::string wsl::core::networking::GenerateResolvConf(_In_ const DnsInfo& Info)
333
contents += c_asciiNewLine;
334
}
335
348
- // Add domain information if it is available.
336
+ // Add DNS suffix information using 'search' directive.
337
+ // Per resolv.conf(5): "The domain directive is an obsolete name for the search directive
338
+ // that handles one search list entry only."
339
+ // See: https://man7.org/linux/man-pages/man5/resolv.conf.5.html
340
if (!Info.Domains.empty())
341
{
342
contents += "search ";
@@ -497,28 +488,21 @@ wsl::core::networking::DnsSuffixRegistryWatcher::DnsSuffixRegistryWatcher(Regist
488
m_registryWatchers.swap(localRegistryWatchers);
489
}
490
500
-wsl::shared::hns::DNS wsl::core::networking::BuildDnsNotification(const DnsInfo& settings, bool useLinuxDomainEntry)
491
+wsl::shared::hns::DNS wsl::core::networking::BuildDnsNotification(const DnsInfo& settings, PCWSTR options)
492
{
493
wsl::shared::hns::DNS dnsNotification{};
503
- dnsNotification.Options = LX_INIT_RESOLVCONF_FULL_HEADER;
504
- dnsNotification.ServerList = wsl::shared::string::MultiByteToWide(wsl::shared::string::Join(settings.Servers, ','));
505
-
506
- if (useLinuxDomainEntry && !settings.Domains.empty())
494
+ if (options)
495
{
508
- // Use 'domain' entry for single DNS suffix (typically used when mirroring host DNS without tunneling)
509
- dnsNotification.Domain = wsl::shared::string::MultiByteToWide(settings.Domains.front());
510
- }
511
- else
512
- {
513
- // Use 'search' entry for DNS suffix list
514
- dnsNotification.Search = wsl::shared::string::MultiByteToWide(wsl::shared::string::Join(settings.Domains, ','));
496
+ dnsNotification.Options = options;
497
}
498
517
- return dnsNotification;
518
-}
499
+ dnsNotification.ServerList = wsl::shared::string::MultiByteToWide(wsl::shared::string::Join(settings.Servers, ','));
500
520
-wsl::core::networking::DnsInfo wsl::core::networking::DnsUpdateHelper::GetCurrentDnsSettings(DnsSettingsFlags flags)
521
-{
522
- m_hostDnsInfo.UpdateNetworkInformation();
523
- return m_hostDnsInfo.GetDnsSettings(flags);
501
+ // Use 'search' entry for DNS suffix list.
502
+ // Per resolv.conf(5): "The domain directive is an obsolete name for the search directive
503
+ // that handles one search list entry only."
504
+ // See: https://man7.org/linux/man-pages/man5/resolv.conf.5.html
505
+ dnsNotification.Search = wsl::shared::string::MultiByteToWide(wsl::shared::string::Join(settings.Domains, ','));
506
+
507
+ return dnsNotification;
508
}
src/windows/common/WslCoreHostDnsInfo.h
+5
-42
@@ -1,7 +1,6 @@
1
// Copyright (C) Microsoft Corporation. All rights reserved.
2
3
#pragma once
4
-#include <mutex>
4
#include <string>
5
#include <vector>
6
@@ -42,9 +41,9 @@ std::string GenerateResolvConf(_In_ const DnsInfo& Info);
41
/// Builds an hns::DNS notification from DnsInfo settings.
42
/// </summary>
43
/// <param name="settings">The DNS settings to convert</param>
45
-/// <param name="useLinuxDomainEntry">If true, uses 'domain' entry for single suffix; otherwise uses 'search' for all
46
-/// suffixes</param> <returns>The hns::DNS notification ready to send via GNS channel</returns>
47
-wsl::shared::hns::DNS BuildDnsNotification(const DnsInfo& settings, bool useLinuxDomainEntry = false);
44
+/// <param name="options">The resolv.conf header options (defaults to LX_INIT_RESOLVCONF_FULL_HEADER)</param>
45
+/// <returns>The hns::DNS notification ready to send via GNS channel</returns>
46
+wsl::shared::hns::DNS BuildDnsNotification(const DnsInfo& settings, PCWSTR options = LX_INIT_RESOLVCONF_FULL_HEADER);
47
48
std::vector<std::string> GetAllDnsSuffixes(const std::vector<IpAdapterAddress>& AdapterAddresses);
49
@@ -53,27 +52,15 @@ DWORD GetBestInterface();
52
class HostDnsInfo
53
{
54
public:
56
- DnsInfo GetDnsSettings(_In_ DnsSettingsFlags Flags);
57
-
58
- void UpdateNetworkInformation();
55
+ static DnsInfo GetDnsSettings(_In_ DnsSettingsFlags Flags);
56
57
static DnsInfo GetDnsTunnelingSettings(const std::wstring& dnsTunnelingNameserver);
58
62
- const std::vector<IpAdapterAddress>& CurrentAddresses() const
63
- {
64
- return m_addresses;
65
- }
66
-
59
private:
68
- /// <summary>
69
- /// Internal function to retrieve the latest copy of interface information.
70
- /// </summary>
71
- std::vector<IpAdapterAddress> GetAdapterAddresses();
72
-
60
/// <summary>
61
/// Internal function to retrieve interface DNS servers.
62
/// </summary>
76
- std::vector<std::string> GetInterfaceDnsServers(const std::vector<IpAdapterAddress>& AdapterAddresses, _In_ DnsSettingsFlags Flags);
63
+ static std::vector<std::string> GetInterfaceDnsServers(const std::vector<IpAdapterAddress>& AdapterAddresses, _In_ DnsSettingsFlags Flags);
64
65
/// <summary>
66
/// Internal function to retrieve all Windows DNS suffixes.
@@ -84,30 +71,6 @@ private:
71
/// Internal function to convert DNS server addresses into strings.
72
/// </summary>
73
static std::vector<std::string> GetDnsServerStrings(_In_ const PIP_ADAPTER_DNS_SERVER_ADDRESS& DnsServer, _In_ USHORT IpFamilyFilter, _In_ USHORT MaxValues);
87
-
88
- /// <summary>
89
- /// Stores latest copy of interface information.
90
- /// </summary>
91
- std::mutex m_lock;
92
- _Guarded_by_(m_lock) std::vector<IpAdapterAddress> m_addresses;
93
-};
94
-
95
-/// <summary>
96
-/// Helper class that fetches current DNS settings from the host.
97
-/// Callers are responsible for tracking changes if needed.
98
-/// </summary>
99
-class DnsUpdateHelper
100
-{
101
-public:
102
- /// <summary>
103
- /// Fetches current DNS settings from the host.
104
- /// </summary>
105
- /// <param name="flags">Flags controlling which DNS settings to include</param>
106
- /// <returns>Current DNS settings</returns>
107
- DnsInfo GetCurrentDnsSettings(DnsSettingsFlags flags);
108
-
109
-private:
110
- HostDnsInfo m_hostDnsInfo;
74
};
75
76
using RegistryChangeCallback = std::function<void()>;
src/windows/service/exe/LxssInstance.cpp
+1
-4
@@ -784,9 +784,6 @@ try
784
// Impersonate the service.
785
auto runAsSelf = wil::run_as_self();
786
787
- // Update the instance's DNS information.
788
- m_dnsInfo.UpdateNetworkInformation();
789
-
787
// Update the resolv.conf file if it has changed.
788
_UpdateNetworkConfigurationFiles(false);
789
return;
@@ -799,7 +796,7 @@ void LxssInstance::_UpdateNetworkConfigurationFiles(_In_ bool UpdateAlways)
796
wsl::core::networking::DnsSettingsFlags flags = wsl::core::networking::DnsSettingsFlags::IncludeIpv6Servers;
797
WI_SetFlagIf(flags, wsl::core::networking::DnsSettingsFlags::IncludeVpn, m_enableVpnDetection);
798
802
- const auto dnsSettings = m_dnsInfo.GetDnsSettings(flags);
799
+ const auto dnsSettings = wsl::core::networking::HostDnsInfo::GetDnsSettings(flags);
800
std::string fileContents = GenerateResolvConf(dnsSettings);
801
std::lock_guard<std::mutex> lock(m_resolvConfLock);
802
if (!UpdateAlways && (fileContents == m_lastResolvConfContents))
src/windows/service/exe/LxssInstance.h
-5
@@ -224,11 +224,6 @@ private:
224
/// </summary>
225
LxssIpTables m_ipTables;
226
227
- /// <summary>
228
- /// Class for querying host dns information.
229
- /// </summary>
230
- wsl::core::networking::HostDnsInfo m_dnsInfo;
231
-
227
/// <summary>
228
/// Settings for updating /etc/resolv.conf.
229
/// </summary>
src/windows/service/exe/WslCoreVm.cpp
+1
-1
@@ -577,7 +577,7 @@ void WslCoreVm::Initialize(const GUID& VmId, const wil::shared_handle& UserToken
577
else if (m_vmConfig.NetworkingMode == NetworkingMode::VirtioProxy)
578
{
579
m_networkingEngine = std::make_unique<wsl::core::VirtioNetworking>(
580
- std::move(gnsChannel), m_vmConfig.EnableLocalhostRelay, m_guestDeviceManager, m_userToken);
580
+ std::move(gnsChannel), m_vmConfig.EnableLocalhostRelay, LX_INIT_RESOLVCONF_FULL_HEADER, m_guestDeviceManager, m_userToken);
581
}
582
else if (m_vmConfig.NetworkingMode == NetworkingMode::Bridged)
583
{
src/windows/service/exe/WslMirroredNetworking.cpp
+1
-2
@@ -434,8 +434,7 @@ void wsl::core::networking::WslMirroredNetworkManager::ProcessDNSChange()
434
}
435
else
436
{
437
- m_hostDnsInfo.UpdateNetworkInformation();
438
- m_dnsInfo = m_hostDnsInfo.GetDnsSettings(
437
+ m_dnsInfo = wsl::core::networking::HostDnsInfo::GetDnsSettings(
438
wsl::core::networking::DnsSettingsFlags::IncludeVpn | wsl::core::networking::DnsSettingsFlags::IncludeIpv6Servers |
439
wsl::core::networking::DnsSettingsFlags::IncludeAllSuffixes);
440
}
src/windows/service/exe/WslMirroredNetworking.h
-3
@@ -224,9 +224,6 @@ private:
224
_Guarded_by_(m_networkLock) DnsInfo m_trackedDnsInfo;
225
// The current DNS info on the host
226
_Guarded_by_(m_networkLock) DnsInfo m_dnsInfo;
227
- // m_hostDnsInfo is an optimization used to avoid allocating a large buffer every time we call
228
- // GetAdaptersAddresses when querying host DNS info
229
- _Guarded_by_(m_networkLock) HostDnsInfo m_hostDnsInfo;
227
228
std::wstring m_dnsTunnelingIpAddress;
229
test/windows/NetworkTests.cpp
+3
-2
@@ -1037,7 +1037,6 @@ class NetworkTests
1037
1038
wsl::shared::hns::DNS dns;
1039
dns.ServerList = L"1.1.1.1,1.1.1.2";
1040
- dns.Domain = L"microsoft.com";
1040
dns.Search = L"foo.microsoft.com,bar.microsoft.com";
1041
dns.Options = LX_INIT_RESOLVCONF_FULL_HEADER;
1042
RunGns(dns, ModifyRequestType::Update, GuestEndpointResourceType::DNS);
@@ -1047,7 +1046,6 @@ class NetworkTests
1046
const std::wstring expected = std::wstring(LX_INIT_RESOLVCONF_FULL_HEADER) +
1047
L"nameserver 1.1.1.1\n"
1048
L"nameserver 1.1.1.2\n"
1050
- L"domain microsoft.com\n"
1049
L"search foo.microsoft.com bar.microsoft.com\n";
1050
VERIFY_ARE_EQUAL(expected, out.c_str());
1051
}
@@ -4612,6 +4610,9 @@ class VirtioProxyTests
4610
const std::wregex pattern(L"(.|\\n)*nameserver [0-9. ]+(.|\\n)*");
4611
4612
VERIFY_IS_TRUE(std::regex_match(out, pattern));
4613
+
4614
+ // Verify that /etc/resolv.conf contains a 'search' line with DNS suffixes
4615
+ VERIFY_IS_TRUE(out.find(L"search ") != std::wstring::npos);
4616
}
4617
4618
TEST_METHOD(GuestPortIsReleased)