diff options
-rwxr-xr-x | src/conf-mode/vyos-config-dns-forwarding.py | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/conf-mode/vyos-config-dns-forwarding.py b/src/conf-mode/vyos-config-dns-forwarding.py index 7a8aed75d..537e47d85 100755 --- a/src/conf-mode/vyos-config-dns-forwarding.py +++ b/src/conf-mode/vyos-config-dns-forwarding.py @@ -37,8 +37,8 @@ def get_resolvers(file): if 'nameserver' in line: resolvers.append(line.split()[1]) return resolvers - except IOError as error: - return error.strerror + except IOError: + return [] def get_config(): dns = {} @@ -57,11 +57,12 @@ def get_config(): interfaces = conf.return_values('dhcp') for interface in interfaces: resolvers = get_resolvers("/etc/resolv.conf.dhclient-new-{0}".format(interface)) - dhcp = { - "interface": interface, - "resolvers": resolvers - } - dns['dhcp'].append(dhcp) + if len(resolvers) > 0: + dhcp = { + "interface": interface, + "resolvers": resolvers + } + dns['dhcp'].append(dhcp) if conf.exists('domain'): dns.setdefault('domain', []) |