From 3085f1feb58607b5dfeff2ba21be9dc2d5b44eea Mon Sep 17 00:00:00 2001 From: Shreyas Zare Date: Sat, 19 Dec 2020 12:33:32 +0530 Subject: [PATCH] Scope: updated static ip validation in FindInterface() with explicit check for ipv4 dhcp server and with detailed error message. --- DnsServerCore/Dhcp/Scope.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/DnsServerCore/Dhcp/Scope.cs b/DnsServerCore/Dhcp/Scope.cs index d1179b6d..55ae6c37 100644 --- a/DnsServerCore/Dhcp/Scope.cs +++ b/DnsServerCore/Dhcp/Scope.cs @@ -438,9 +438,12 @@ namespace DnsServerCore.Dhcp { //found interface for this scope range - //check if address is static - if (ipInterface.DhcpServerAddresses.Count > 0) - throw new DhcpServerException("DHCP Server requires static IP address to work correctly but the network interface was found to have DHCP configured."); + //check if interface has dynamic ipv4 address assigned via dhcp + foreach (IPAddress dhcpServerAddress in ipInterface.DhcpServerAddresses) + { + if (dhcpServerAddress.AddressFamily == AddressFamily.InterNetwork) + throw new DhcpServerException("DHCP Server requires static IP address to work correctly but the network interface was found to have a dynamic IP address [" + ip.Address.ToString() + "] assigned by another DHCP server: " + dhcpServerAddress.ToString()); + } _interfaceAddress = ip.Address; _interfaceIndex = ipInterface.GetIPv4Properties().Index;