diff options
author | Christian Poessinger <christian@poessinger.com> | 2018-08-29 22:28:29 +0200 |
---|---|---|
committer | Christian Poessinger <christian@poessinger.com> | 2018-08-29 22:28:29 +0200 |
commit | f5311c1732009f927ea1b47966e4a296d62b2ce8 (patch) | |
tree | b3c08ca1f2d0d74ee9b6f2e90038c32fcbd2bd43 /src | |
parent | 37aeb227c346ee52d4fbed91c79cb59774ceb5ae (diff) | |
download | vyos-1x-f5311c1732009f927ea1b47966e4a296d62b2ce8.tar.gz vyos-1x-f5311c1732009f927ea1b47966e4a296d62b2ce8.zip |
dhcp_server.py: check if AF_INET address is configure before using it in verify()
Diffstat (limited to 'src')
-rwxr-xr-x | src/conf_mode/dhcp_server.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/conf_mode/dhcp_server.py b/src/conf_mode/dhcp_server.py index 8ca72164a..556545e6d 100755 --- a/src/conf_mode/dhcp_server.py +++ b/src/conf_mode/dhcp_server.py @@ -703,10 +703,13 @@ def verify(dhcp): # There must be one subnet connected to a real interface # for interface in netifaces.interfaces(): - # Retrieve IP address of network interface - ip = netifaces.ifaddresses(interface)[netifaces.AF_INET][0]['addr'] - if ipaddress.ip_address(ip) in ipaddress.ip_network(subnet['network']): - listen_ok = True + # Test if IPv4 addresses are configured at all + if netifaces.AF_INET in netifaces.ifaddresses(interface).keys(): + # An interface can have multiple addresses, but ISC DHCP only supports the first :( + ip = netifaces.ifaddresses(interface)[netifaces.AF_INET][0]['addr'] + if ipaddress.ip_address(ip) in ipaddress.ip_network(subnet['network']): + # Bingo! At least one subnet connected to an interface on this machine + listen_ok = True # # Subnets must be non overlapping |