diff options
author | lukehamburg <luke.hamburg@gmail.com> | 2017-03-29 09:00:27 -0400 |
---|---|---|
committer | jim-p <jimp@pfsense.org> | 2017-04-04 08:36:36 -0400 |
commit | 370c8a1e9b59a6572c455661e3b3ccf9376f1716 (patch) | |
tree | d2c6d2c96b9f55208615b575cc1843ee83c5e6f2 | |
parent | 6df0114b5bcba0fb8aaed3546fb054b0b9162998 (diff) | |
download | pfsense-370c8a1e9b59a6572c455661e3b3ccf9376f1716.zip pfsense-370c8a1e9b59a6572c455661e3b3ccf9376f1716.tar.gz |
Adds ability to ignore DHCP offers from multiple servers
- Forum thread: https://forum.pfsense.org/index.php?topic=124046.msg705100#msg705100
- related dhclient source:
https://github.com/pfsense/FreeBSD-src/blob/devel/sbin/dhclient/clparse.c#L945
**changed files:**
/usr/local/www/interfaces.php
/etc/inc/interfaces.inc
-rw-r--r-- | src/etc/inc/interfaces.inc | 21 | ||||
-rw-r--r-- | src/usr/local/www/interfaces.php | 7 |
2 files changed, 25 insertions, 3 deletions
diff --git a/src/etc/inc/interfaces.inc b/src/etc/inc/interfaces.inc index 67c2a04..0b80663 100644 --- a/src/etc/inc/interfaces.inc +++ b/src/etc/inc/interfaces.inc @@ -70,6 +70,27 @@ function interfaces_bring_up($interface) { } /* + * Validate comma-separated list of IPv4 addresses + */ +function validate_ipv4_list($value) { + $value = trim($value); + + if (empty($value)) { + return false; + } + + $list = explode(',', $value); + + foreach ($list as $ip) { + if (!is_ipaddrv4($ip)) { + return false; + } + } + + return true; +} + +/* * Return the interface array */ function get_interface_arr($flush = false) { diff --git a/src/usr/local/www/interfaces.php b/src/usr/local/www/interfaces.php index d6b8643..3894bef 100644 --- a/src/usr/local/www/interfaces.php +++ b/src/usr/local/www/interfaces.php @@ -792,8 +792,8 @@ if ($_POST['apply']) { if (($_POST['alias-subnet'] && !is_numeric($_POST['alias-subnet']))) { $input_errors[] = gettext("A valid alias subnet bit count must be specified."); } - if ($_POST['dhcprejectfrom'] && !is_ipaddrv4($_POST['dhcprejectfrom'])) { - $input_errors[] = gettext("A valid alias IP address must be specified to reject DHCP Leases from."); + if ($_POST['dhcprejectfrom'] && !validate_ipv4_list($_POST['dhcprejectfrom'])) { + $input_errors[] = gettext("An invalid IP address was detected in the 'Reject leases from' field."); } if (($_POST['gateway'] != "none") || ($_POST['gatewayv6'] != "none")) { $match = false; @@ -1998,7 +1998,8 @@ $section->addInput(new Form_Input( 'Reject leases from', 'text', $pconfig['dhcprejectfrom'] -))->setHelp('To make the DHCP client reject leases from an undesirable DHCP server, place the IP address of the DHCP server here. ' . +))->setHelp('To have the DHCP client reject offers from specific DHCP servers, enter their IP addresses here ' . + '(separate multiple entries with a comma). ' . 'This is useful for rejecting leases from cable modems that offer private IP addresses when they lose upstream sync.'); $group = new Form_Group('Protocol timing'); |