From 2c75b451becbf3e74466df54e2b3bdbe02ac7abf Mon Sep 17 00:00:00 2001 From: sullrich Date: Wed, 2 Dec 2009 19:59:34 -0500 Subject: [PATCH] Disallow virtual IP addresses withing the range Ticket #50 --- usr/local/www/services_dhcp.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/usr/local/www/services_dhcp.php b/usr/local/www/services_dhcp.php index 7d45643ef1..6b238afb37 100755 --- a/usr/local/www/services_dhcp.php +++ b/usr/local/www/services_dhcp.php @@ -222,15 +222,20 @@ if ($_POST) { $input_errors[] = "A valid IP address must be specified for the TFTP server."; if (($_POST['nextserver'] && !is_ipaddr($_POST['nextserver']))) $input_errors[] = "A valid IP address must be specified for the network boot server."; - + if(gen_subnet($ifcfgip, $ifcfgsn) == $_POST['range_from']) $input_errors[] = "You cannot use the network address in the starting subnet range."; if(gen_subnet_max($ifcfgip, $ifcfgsn) == $_POST['range_to']) $input_errors[] = "You cannot use the broadcast address in the ending subnet range."; - //if(is_inrange($ifcfgip, $_POST['range_from'], $_POST['range_to'])) - // $input_errors[] = "Address range includes the interface IP $ifcfgip."; - + // Disallow a range that includes the virtualip + foreach($config['virtualip']['vip'] as $vip) { + if(strtoupper($vip['interface']) == strtoupper($if)) + if($vip['subnet']) + if(is_inrange($vip['subnet'], $_POST['range_from'], $_POST['range_to'])) + $input_errors[] = "The virtual IP address {$vip['subnet']} falls within the subnet range."; + } + if (!$input_errors) { /* make sure the range lies within the current subnet */ $subnet_start = (ip2long($ifcfgip) & gen_subnet_mask_long($ifcfgsn));