summaryrefslogtreecommitdiffstats
path: root/src/usr/local/www/wizards
diff options
context:
space:
mode:
authorjim-p <jimp@pfsense.org>2016-10-13 10:20:14 -0400
committerjim-p <jimp@pfsense.org>2016-10-13 10:21:30 -0400
commitd02ee1387fdb159bfb7cb9495003f66545d97989 (patch)
treeb8a1b23cf29cfe0f78eb0854bd46270fcf887fb0 /src/usr/local/www/wizards
parent77179b262c4fc65c9187676841e9b8e25e188f9d (diff)
downloadpfsense-d02ee1387fdb159bfb7cb9495003f66545d97989.zip
pfsense-d02ee1387fdb159bfb7cb9495003f66545d97989.tar.gz
In the setup wizard, do not change the DHCP range if it is already set inside the new subnet. Otherwise it will overwrite a range set manually from the DHCP settings or the console when the wizard is run later. Fixes #4820
Diffstat (limited to 'src/usr/local/www/wizards')
-rw-r--r--src/usr/local/www/wizards/setup_wizard.xml55
1 files changed, 31 insertions, 24 deletions
diff --git a/src/usr/local/www/wizards/setup_wizard.xml b/src/usr/local/www/wizards/setup_wizard.xml
index a9df30c..9a42871 100644
--- a/src/usr/local/www/wizards/setup_wizard.xml
+++ b/src/usr/local/www/wizards/setup_wizard.xml
@@ -619,32 +619,39 @@
die;
}
- $ipaddresses_before = ip_range_size_v4($lowestip, $_POST['lanipaddress']);
- $ipaddresses_after = ip_range_size_v4($_POST['lanipaddress'], $highestip);
+ /*
+ If the existing DHCP range on LAN is not in the new subnet or
+ is invalid, then replace the range with a newly crafted one.
+ */
+ if (!ip_in_subnet($config['dhcpd']['lan']['range']['from'], "{$_POST['lanipaddress']}/{$_POST['subnetmask']}") ||
+ !ip_in_subnet($config['dhcpd']['lan']['range']['to'], "{$_POST['lanipaddress']}/{$_POST['subnetmask']}")) {
- if ($ipaddresses_after >= $ipaddresses_before) {
- // The LAN IP is in the 1st half of the subnet, so put DHCP in the 2nd half.
- if ($ipaddresses_after > 30) {
- // There is reasonable space in the subnet, use a smaller chunk of the space for DHCP
- // This case will work out like the old defaults if the user has specified the ".1" address.
- // The range will be something like ".10" to ".245"
- $config['dhcpd']['lan']['range']['from'] = ip_after($_POST['lanipaddress'], 9);
- $config['dhcpd']['lan']['range']['to'] = ip_before($highestip, 10);
- } else {
- // There is not much space in the subnet, so allocate everything above the LAN IP to DHCP.
- $config['dhcpd']['lan']['range']['from'] = ip_after($_POST['lanipaddress']);
- $config['dhcpd']['lan']['range']['to'] = ip_before($highestip);
- }
- } else {
- // The LAN IP is in the 2nd half of the subnet, so put DHCP in the 1st half.
- if ($ipaddresses_before > 30) {
- // There is reasonable space in the subnet, use a smaller chunk of the space for DHCP
- $config['dhcpd']['lan']['range']['from'] = ip_after($lowestip, 10);
- $config['dhcpd']['lan']['range']['to'] = ip_before($_POST['lanipaddress'], 9);
+ $ipaddresses_before = ip_range_size_v4($lowestip, $_POST['lanipaddress']);
+ $ipaddresses_after = ip_range_size_v4($_POST['lanipaddress'], $highestip);
+ if ($ipaddresses_after >= $ipaddresses_before) {
+ // The LAN IP is in the 1st half of the subnet, so put DHCP in the 2nd half.
+ if ($ipaddresses_after > 30) {
+ // There is reasonable space in the subnet, use a smaller chunk of the space for DHCP
+ // This case will work out like the old defaults if the user has specified the ".1" address.
+ // The range will be something like ".10" to ".245"
+ $config['dhcpd']['lan']['range']['from'] = ip_after($_POST['lanipaddress'], 9);
+ $config['dhcpd']['lan']['range']['to'] = ip_before($highestip, 10);
+ } else {
+ // There is not much space in the subnet, so allocate everything above the LAN IP to DHCP.
+ $config['dhcpd']['lan']['range']['from'] = ip_after($_POST['lanipaddress']);
+ $config['dhcpd']['lan']['range']['to'] = ip_before($highestip);
+ }
} else {
- // There is not much space in the subnet, so allocate everything below the LAN IP to DHCP.
- $config['dhcpd']['lan']['range']['from'] = ip_after($lowestip);
- $config['dhcpd']['lan']['range']['to'] = ip_before($_POST['lanipaddress']);
+ // The LAN IP is in the 2nd half of the subnet, so put DHCP in the 1st half.
+ if ($ipaddresses_before > 30) {
+ // There is reasonable space in the subnet, use a smaller chunk of the space for DHCP
+ $config['dhcpd']['lan']['range']['from'] = ip_after($lowestip, 10);
+ $config['dhcpd']['lan']['range']['to'] = ip_before($_POST['lanipaddress'], 9);
+ } else {
+ // There is not much space in the subnet, so allocate everything below the LAN IP to DHCP.
+ $config['dhcpd']['lan']['range']['from'] = ip_after($lowestip);
+ $config['dhcpd']['lan']['range']['to'] = ip_before($_POST['lanipaddress']);
+ }
}
}
]]>
OpenPOWER on IntegriCloud