From ad74afa91e6db9c4470b8b49e736d50d7d6d88da Mon Sep 17 00:00:00 2001 From: Shreyas Zare Date: Sun, 4 Oct 2020 13:49:31 +0530 Subject: [PATCH] DhcpServer: fixed issue in FindScope() which required the relay agent ip address to be in the scope range. --- DnsServerCore/Dhcp/DhcpServer.cs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/DnsServerCore/Dhcp/DhcpServer.cs b/DnsServerCore/Dhcp/DhcpServer.cs index a708b0c0..b36275e2 100644 --- a/DnsServerCore/Dhcp/DhcpServer.cs +++ b/DnsServerCore/Dhcp/DhcpServer.cs @@ -610,7 +610,7 @@ namespace DnsServerCore.Dhcp //unicast request foreach (Scope scope in _scopes.Values) { - if (scope.Enabled && scope.IsAddressInRange(remoteAddress)) + if (scope.Enabled && scope.IsAddressInRange(request.ClientIpAddress)) return scope; } @@ -624,15 +624,16 @@ namespace DnsServerCore.Dhcp foreach (Scope scope in _scopes.Values) { - if (scope.Enabled && scope.InterfaceAddress.Equals(IPAddress.Any)) + if (scope.Enabled && scope.InterfaceAddress.Equals(IPAddress.Any) && scope.IsAddressInNetwork(request.RelayAgentIpAddress)) { if (scope.GetReservedLease(request) != null) return scope; //found reserved lease on this scope if (!request.ClientIpAddress.Equals(IPAddress.Any) && scope.IsAddressInRange(request.ClientIpAddress)) - foundScope = scope; //client IP address is in scope range - else if ((foundScope == null) && scope.IsAddressInRange(request.RelayAgentIpAddress)) - foundScope = scope; //relay agent IP address is in scope range + return scope; //client IP address is in scope range + + if ((foundScope == null) && !scope.AllowOnlyReservedLeases) + foundScope = scope; } }