--- services.inc 2020-04-03 01:09:42.381635000 -0500 +++ services.inc.dhcrelay-fix 2020-04-03 01:09:48.595046000 -0500 @@ -1779,22 +1779,36 @@ } $srvifaces = array_unique($srvifaces); + /* If relays are on subnets that also serves clients, we need to move them to their own array */ + $srvrelayifs = array(); + $srvrelayifs = array_intersect($dhcrelayifs, $srvifaces); + $srvifaces = array_diff($srvifaces, $srvrelayifs); + $dhcrelayifs = array_diff($dhcrelayifs, $srvrelayifs); + /* The server interface(s) should not be in this list */ $dhcrelayifs = array_diff($dhcrelayifs, $srvifaces); /* fire up dhcrelay */ - if (empty($dhcrelayifs)) { + if (empty($dhcrelayifs) && empty($srvrelayifs)) { log_error(gettext("No suitable downstream interfaces found for running dhcrelay!")); return; /* XXX */ } - if (empty($srvifaces)) { + if (empty($srvifaces) && empty($srvrelayifs)) { log_error(gettext("No suitable upstream interfaces found for running dhcrelay!")); return; /* XXX */ } $cmd = "/usr/local/sbin/dhcrelay"; - $cmd .= " -id " . implode(" -id ", $dhcrelayifs); - $cmd .= " -iu " . implode(" -iu ", $srvifaces); + + if (!empty($dhcrelayifs)) { + $cmd .= " -id " . implode(" -id ", $dhcrelayifs); + } + if (!empty($srvifaces)) { + $cmd .= " -iu " . implode(" -iu ", $srvifaces); + } + if (!empty($srvrelayifs)) { + $cmd .= " -i " . implode(" -i ", $srvrelayifs); + } if (isset($dhcrelaycfg['agentoption'])) { $cmd .= " -a -m replace";