diff options
author | jim-p <jimp@pfsense.org> | 2016-10-13 10:20:14 -0400 |
---|---|---|
committer | jim-p <jimp@pfsense.org> | 2016-10-13 10:21:44 -0400 |
commit | 00fc1317cb7d6f1e98975aa5c1f08794e0d43cb1 (patch) | |
tree | e767db89b5dbb68cce0c3411bf79f882737cf6b8 /src/usr/local/www/wizards | |
parent | 2329b5a8dab6847db24d892a4c00b0f11cabba64 (diff) | |
download | pfsense-00fc1317cb7d6f1e98975aa5c1f08794e0d43cb1.zip pfsense-00fc1317cb7d6f1e98975aa5c1f08794e0d43cb1.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.xml | 55 |
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 5add85c..f257f15 100644 --- a/src/usr/local/www/wizards/setup_wizard.xml +++ b/src/usr/local/www/wizards/setup_wizard.xml @@ -653,32 +653,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']); + } } } ]]> |