summaryrefslogtreecommitdiffstats
path: root/etc/rc.initial.setlanip
diff options
context:
space:
mode:
authorPhil Davis <phil.davis@world.inf.org>2013-12-09 01:53:14 -0800
committerRenato Botelho <garga@FreeBSD.org>2013-12-09 09:49:33 -0200
commitb3b3d115cca367a6491707d850f51c75b9a07852 (patch)
treec66f6898871efac3aa64ea39dde2fcf6ae3363f5 /etc/rc.initial.setlanip
parent2c712868366c8dbced8840235efe262641a937cf (diff)
downloadpfsense-b3b3d115cca367a6491707d850f51c75b9a07852.zip
pfsense-b3b3d115cca367a6491707d850f51c75b9a07852.tar.gz
Check that DHCP end IP is >= DHCP start IP
Diffstat (limited to 'etc/rc.initial.setlanip')
-rwxr-xr-xetc/rc.initial.setlanip52
1 files changed, 29 insertions, 23 deletions
diff --git a/etc/rc.initial.setlanip b/etc/rc.initial.setlanip
index 1089c83..13a9bdc 100755
--- a/etc/rc.initial.setlanip
+++ b/etc/rc.initial.setlanip
@@ -360,30 +360,36 @@ function console_configure_dhcpd($version = 4) {
$subnet_start = ($version === 6) ? gen_subnetv6($intip6, $intbits6) : gen_subnet($intip, $intbits);
$subnet_end = ($version === 6) ? gen_subnetv6_max($intip6, $intbits6) : gen_subnet_max($intip, $intbits);
do {
- echo sprintf(gettext("Enter the start address of the %s client address range:"), $label_IPvX) . " ";
- $dhcpstartip = chop(fgets($fp));
- if ($dhcpstartip === "") {
- fclose($fp);
- exit(0);
- }
- $is_ipaddr = ($version === 6) ? is_ipaddrv6($dhcpstartip) : is_ipaddrv4($dhcpstartip);
- $is_inrange = is_inrange($dhcpstartip, $subnet_start, $subnet_end);
- if (!$is_inrange)
- echo gettext("This IP address must be in the interface's subnet") . "\n";
- } while (!$is_ipaddr || !$is_inrange);
+ do {
+ echo sprintf(gettext("Enter the start address of the %s client address range:"), $label_IPvX) . " ";
+ $dhcpstartip = chop(fgets($fp));
+ if ($dhcpstartip === "") {
+ fclose($fp);
+ exit(0);
+ }
+ $is_ipaddr = ($version === 6) ? is_ipaddrv6($dhcpstartip) : is_ipaddrv4($dhcpstartip);
+ $is_inrange = is_inrange($dhcpstartip, $subnet_start, $subnet_end);
+ if (!$is_inrange)
+ echo gettext("This IP address must be in the interface's subnet") . "\n";
+ } while (!$is_ipaddr || !$is_inrange);
- do {
- echo sprintf(gettext("Enter the end address of the %s client address range:"), $label_IPvX) . " ";
- $dhcpendip = chop(fgets($fp));
- if ($dhcpendip === "") {
- fclose($fp);
- exit(0);
- }
- $is_ipaddr = ($version === 6) ? is_ipaddrv6($dhcpendip) : is_ipaddrv4($dhcpendip);
- $is_inrange = is_inrange($dhcpendip, $subnet_start, $subnet_end);
- if (!$is_inrange)
- echo gettext("This IP address must be in the interface's subnet") . "\n";
- } while (!$is_ipaddr || !$is_inrange);
+ do {
+ echo sprintf(gettext("Enter the end address of the %s client address range:"), $label_IPvX) . " ";
+ $dhcpendip = chop(fgets($fp));
+ if ($dhcpendip === "") {
+ fclose($fp);
+ exit(0);
+ }
+ $is_ipaddr = ($version === 6) ? is_ipaddrv6($dhcpendip) : is_ipaddrv4($dhcpendip);
+ $is_inrange = is_inrange($dhcpendip, $subnet_start, $subnet_end);
+ if (!$is_inrange)
+ echo gettext("This IP address must be in the interface's subnet") . "\n";
+ $not_inorder = ($version === 6) ? (inet_pton($dhcpendip) < inet_pton($dhcpstartip)) : ip_less_than($dhcpendip, $dhcpstartip);
+ if ($not_inorder) {
+ echo gettext("The end address of the DHCP range must be >= the start address") . "\n";
+ }
+ } while (!$is_ipaddr || !$is_inrange);
+ } while ($not_inorder);
$restart_dhcpd = true;
$config[$dhcpd][$interface]['enable'] = true;
$config[$dhcpd][$interface]['range']['from'] = $dhcpstartip;
OpenPOWER on IntegriCloud