From 4bde5b0871a26ffd55ef1f908646e210318122d4 Mon Sep 17 00:00:00 2001 From: Shreyas Zare Date: Sat, 17 Oct 2020 18:30:04 +0530 Subject: [PATCH] DhcpServer: changed sequence of FindThisDnsServerAddress() call in ActivateScopeAsync() after the FindInterface() so that the DNS address is correctly read. --- DnsServerCore/Dhcp/DhcpServer.cs | 8 ++++---- DnsServerCore/Dhcp/Scope.cs | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/DnsServerCore/Dhcp/DhcpServer.cs b/DnsServerCore/Dhcp/DhcpServer.cs index 60e4215a..ee666b8b 100644 --- a/DnsServerCore/Dhcp/DhcpServer.cs +++ b/DnsServerCore/Dhcp/DhcpServer.cs @@ -795,10 +795,6 @@ namespace DnsServerCore.Dhcp try { - //find this dns server address in case the network config has changed - if (scope.UseThisDnsServer) - scope.FindThisDnsServerAddress(); - //find scope interface for binding socket if (waitForInterface) { @@ -821,6 +817,10 @@ namespace DnsServerCore.Dhcp throw new DhcpServerException("DHCP Server requires static IP address to work correctly but no network interface was found to have any static IP address configured."); } + //find this dns server address in case the network config has changed + if (scope.UseThisDnsServer) + scope.FindThisDnsServerAddress(); + IPAddress interfaceAddress = scope.InterfaceAddress; dhcpEP = new IPEndPoint(interfaceAddress, 67); diff --git a/DnsServerCore/Dhcp/Scope.cs b/DnsServerCore/Dhcp/Scope.cs index 179d62f5..fe013229 100644 --- a/DnsServerCore/Dhcp/Scope.cs +++ b/DnsServerCore/Dhcp/Scope.cs @@ -448,7 +448,7 @@ namespace DnsServerCore.Dhcp { NetworkInterface[] networkInterfaces = NetworkInterface.GetAllNetworkInterfaces(); - //find interface in current scope range + //find interface in current scope network range uint networkAddressNumber = _networkAddress.ConvertIpToNumber(); uint subnetMaskNumber = _subnetMask.ConvertIpToNumber();