summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2020-12-07 06:18:11 +0100
committerGitHub <noreply@github.com>2020-12-07 06:18:11 +0100
commit722e886ac2bf644dd904f0a5049f6bcac7951ccb (patch)
treebb20e202d09c8ee0d9b58244c214d28b9e973c7a /src
parent6b7aa5ae54b52875b82a42b41ffea939d2eba180 (diff)
parenteecec6b5caeaef14a03ddbb1d09f9c599273b998 (diff)
downloadvyos-1x-722e886ac2bf644dd904f0a5049f6bcac7951ccb.tar.gz
vyos-1x-722e886ac2bf644dd904f0a5049f6bcac7951ccb.zip
Merge pull request #636 from c-po/t2562-dhcp
dhcp: T2562: add "listen-address" CLI node for better DHCP relay support
Diffstat (limited to 'src')
-rwxr-xr-xsrc/conf_mode/dhcp_server.py16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/conf_mode/dhcp_server.py b/src/conf_mode/dhcp_server.py
index 9be586cdf..1ab2d8d16 100755
--- a/src/conf_mode/dhcp_server.py
+++ b/src/conf_mode/dhcp_server.py
@@ -26,6 +26,7 @@ from vyos.template import render
from vyos.util import call
from vyos.util import dict_search
from vyos.validate import is_subnet_connected
+from vyos.validate import is_addr_assigned
from vyos.xml import defaults
from vyos import ConfigError
from vyos import airbag
@@ -246,10 +247,19 @@ def verify(dhcp):
if net.overlaps(net2):
raise ConfigError('Conflicting subnet ranges: "{net}" overlaps "{net2}"!')
+ for address in (dict_search('listen_address', dhcp) or []):
+ if is_addr_assigned(address):
+ listen_ok = True
+ # no need to probe further networks, we have one that is valid
+ continue
+ else:
+ raise ConfigError(f'listen-address "{address}" not configured on any interface')
+
+
if not listen_ok:
- raise ConfigError('DHCP server configuration error! None of the configured\n' \
- 'subnets have an appropriate primary IP address on any\n'
- 'broadcast interface.')
+ raise ConfigError('None of the configured subnets have an appropriate primary IP address on any\n'
+ 'broadcast interface configured, nor was there an explicit listen-address\n'
+ 'configured for serving DHCP relay packets!')
return None