From f5311c1732009f927ea1b47966e4a296d62b2ce8 Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Wed, 29 Aug 2018 22:28:29 +0200 Subject: dhcp_server.py: check if AF_INET address is configure before using it in verify() --- src/conf_mode/dhcp_server.py | 11 +++++++---- 1 file 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 -- cgit v1.2.3