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
committerPhil Davis <phil.davis@world.inf.org>2013-12-09 01:53:14 -0800
commit12f5a2d86107081678e73f642efa335c1e70d774 (patch)
treef2288efcac781a8759ef6dbf364887cb60f0f8ea /etc/rc.initial.setlanip
parent69116e9817c97a42f4e35addde9af5085468e43b (diff)
downloadpfsense-12f5a2d86107081678e73f642efa335c1e70d774.zip
pfsense-12f5a2d86107081678e73f642efa335c1e70d774.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 f5320fd..b6ddc9e 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($intip, $intbits) : gen_subnet($intip, $intbits);
$subnet_end = ($version === 6) ? gen_subnetv6_max($intip, $intbits) : 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