<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://www.rosemarknetworks.com/wiki/index.php?action=history&amp;feed=atom&amp;title=Force_Wireguard_DNS_Zone_Override</id>
	<title>Force Wireguard DNS Zone Override - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://www.rosemarknetworks.com/wiki/index.php?action=history&amp;feed=atom&amp;title=Force_Wireguard_DNS_Zone_Override"/>
	<link rel="alternate" type="text/html" href="https://www.rosemarknetworks.com/wiki/index.php?title=Force_Wireguard_DNS_Zone_Override&amp;action=history"/>
	<updated>2026-05-01T10:04:11Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.42.3</generator>
	<entry>
		<id>https://www.rosemarknetworks.com/wiki/index.php?title=Force_Wireguard_DNS_Zone_Override&amp;diff=151&amp;oldid=prev</id>
		<title>Maeve at 14:54, 7 July 2025</title>
		<link rel="alternate" type="text/html" href="https://www.rosemarknetworks.com/wiki/index.php?title=Force_Wireguard_DNS_Zone_Override&amp;diff=151&amp;oldid=prev"/>
		<updated>2025-07-07T14:54:33Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 14:54, 7 July 2025&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l6&quot;&gt;Line 6:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 6:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  Add-DnsClientNrptRule -Comment &amp;#039;NameOfVPNTunnel&amp;#039; -Namespace &amp;#039;.dnszone.com&amp;#039; -NameServers 203.0.113.0&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  Add-DnsClientNrptRule -Comment &amp;#039;NameOfVPNTunnel&amp;#039; -Namespace &amp;#039;.dnszone.com&amp;#039; -NameServers 203.0.113.0&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This works, but the problem is that this rule will always be active. If you know for sure that the device&amp;#039;s network situation will never change, this is fine, but if it&amp;#039;s a mobile workstation that may be repurposed you should avoid this if possible. We can tell Wireguard to dynamically create and remove these rules using the PostUp and PostDown hooks in the Wireguard config. The problem is that these are disabled by default due to the potential room for abuse. The solution is to enable these using a registry edit:&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This works, but the problem is that this rule will always be active. If you know for sure that the device&amp;#039;s network situation will never change, this is fine, but if it&amp;#039;s a mobile workstation that may be repurposed you should avoid this if possible. We can tell Wireguard to dynamically create and remove these rules using the PostUp and PostDown hooks in the Wireguard config. The problem is that these are disabled by default due to the potential room for abuse. The solution is to enable these using a registry edit:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Set-ItemProperty -Path &lt;/del&gt;HKLM&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;:&lt;/del&gt;\&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;SOFTWARE&lt;/del&gt;\&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Wireguard -Name &lt;/del&gt;DangerousScriptExecution &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;-Type DWord -Value &lt;/del&gt;1&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;reg add &lt;/ins&gt;HKLM\&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Software&lt;/ins&gt;\&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;WireGuard /v &lt;/ins&gt;DangerousScriptExecution &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;/t REG_DWORD /d &lt;/ins&gt;1 &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;/f&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt; &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;If this results in &amp;quot;The operation was completed successfully&amp;quot; we can now add these lines to our wireguard config:&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;If this results in &amp;quot;The operation was completed successfully&amp;quot; we can now add these lines to our wireguard config:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  PostUp = powershell.exe -Command &amp;quot;&amp;amp; { Add-DnsClientNrptRule -Comment &amp;#039;NameOfVPNTunnel&amp;#039; -Namespace &amp;#039;.dnszone.com&amp;#039; -NameServers 203.0.113.0 }&amp;quot;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  PostUp = powershell.exe -Command &amp;quot;&amp;amp; { Add-DnsClientNrptRule -Comment &amp;#039;NameOfVPNTunnel&amp;#039; -Namespace &amp;#039;.dnszone.com&amp;#039; -NameServers 203.0.113.0 }&amp;quot;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  PostDown = powershell.exe -Command &amp;quot;&amp;amp; { Get-DnsClientNrptRule | where Comment -eq &amp;#039;NameOfVPNTunnel&amp;#039; | foreach { Remove-DnsClientNrptRule -Name $_.Name -Force } }&amp;quot;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;  PostDown = powershell.exe -Command &amp;quot;&amp;amp; { Get-DnsClientNrptRule | where Comment -eq &amp;#039;NameOfVPNTunnel&amp;#039; | foreach { Remove-DnsClientNrptRule -Name $_.Name -Force } }&amp;quot;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Maeve</name></author>
	</entry>
	<entry>
		<id>https://www.rosemarknetworks.com/wiki/index.php?title=Force_Wireguard_DNS_Zone_Override&amp;diff=150&amp;oldid=prev</id>
		<title>Maeve: Created page with &quot;Sometimes you may have a situation in which you require a machine using a Wireguard tunnel to always use a specific DNS server to resolve specific zones. One case where we needed this was an Active Directory DNS zone that also matched a publicly available DNS zone. The publicly available records resolved to one end of a NAT&#039;d IP range, but the AD DNS zone had records pointing to the other side. When connecting locally in the network, this was fine, but some Windows clien...&quot;</title>
		<link rel="alternate" type="text/html" href="https://www.rosemarknetworks.com/wiki/index.php?title=Force_Wireguard_DNS_Zone_Override&amp;diff=150&amp;oldid=prev"/>
		<updated>2025-07-03T17:41:01Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;Sometimes you may have a situation in which you require a machine using a Wireguard tunnel to always use a specific DNS server to resolve specific zones. One case where we needed this was an Active Directory DNS zone that also matched a publicly available DNS zone. The publicly available records resolved to one end of a NAT&amp;#039;d IP range, but the AD DNS zone had records pointing to the other side. When connecting locally in the network, this was fine, but some Windows clien...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Sometimes you may have a situation in which you require a machine using a Wireguard tunnel to always use a specific DNS server to resolve specific zones. One case where we needed this was an Active Directory DNS zone that also matched a publicly available DNS zone. The publicly available records resolved to one end of a NAT&amp;#039;d IP range, but the AD DNS zone had records pointing to the other side. When connecting locally in the network, this was fine, but some Windows clients were resolving through the LAN&amp;#039;s DNS regardless of the search domain set in the Wireguard config.&lt;br /&gt;
&lt;br /&gt;
To fix this we can leverage the power of the [https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2012-r2-and-2012/dn593632(v=ws.11) Name Resolution Policy Table].&lt;br /&gt;
&lt;br /&gt;
You could simply fix this by executing this command:&lt;br /&gt;
 Add-DnsClientNrptRule -Comment &amp;#039;NameOfVPNTunnel&amp;#039; -Namespace &amp;#039;.dnszone.com&amp;#039; -NameServers 203.0.113.0&lt;br /&gt;
This works, but the problem is that this rule will always be active. If you know for sure that the device&amp;#039;s network situation will never change, this is fine, but if it&amp;#039;s a mobile workstation that may be repurposed you should avoid this if possible. We can tell Wireguard to dynamically create and remove these rules using the PostUp and PostDown hooks in the Wireguard config. The problem is that these are disabled by default due to the potential room for abuse. The solution is to enable these using a registry edit:&lt;br /&gt;
 Set-ItemProperty -Path HKLM:\SOFTWARE\Wireguard -Name DangerousScriptExecution -Type DWord -Value 1&lt;br /&gt;
If this results in &amp;quot;The operation was completed successfully&amp;quot; we can now add these lines to our wireguard config:&lt;br /&gt;
 PostUp = powershell.exe -Command &amp;quot;&amp;amp; { Add-DnsClientNrptRule -Comment &amp;#039;NameOfVPNTunnel&amp;#039; -Namespace &amp;#039;.dnszone.com&amp;#039; -NameServers 203.0.113.0 }&amp;quot;&lt;br /&gt;
 PostDown = powershell.exe -Command &amp;quot;&amp;amp; { Get-DnsClientNrptRule | where Comment -eq &amp;#039;NameOfVPNTunnel&amp;#039; | foreach { Remove-DnsClientNrptRule -Name $_.Name -Force } }&amp;quot;&lt;/div&gt;</summary>
		<author><name>Maeve</name></author>
	</entry>
</feed>