diff options
-rw-r--r-- | scripts/dns-forwarding/vyatta-dns-forwarding.pl | 46 | ||||
-rw-r--r-- | templates/service/dns/forwarding/dhcp/node.def | 2 |
2 files changed, 45 insertions, 3 deletions
diff --git a/scripts/dns-forwarding/vyatta-dns-forwarding.pl b/scripts/dns-forwarding/vyatta-dns-forwarding.pl index 902e91bc..08cea70a 100644 --- a/scripts/dns-forwarding/vyatta-dns-forwarding.pl +++ b/scripts/dns-forwarding/vyatta-dns-forwarding.pl @@ -162,6 +162,47 @@ sub check_system_nameserver { } +sub check_dhcp_any_interface { + + my $config = new VyattaConfig; + $config->setLevel("interfaces ethernet"); + my @eths = $config->listNodes("."); + foreach my $eth (@eths) { + $config->setLevel("interfaces ethernet $eth"); + my @addrs = $config->returnOrigValues("address"); + foreach my $addr (@addrs) { + if (defined $addr && $addr eq "dhcp") { + return 1; + } + } + my @vifs = $config->listNodes("vif"); + foreach my $vif (@vifs) { + $config->setLevel("interfaces ethernet $eth vif $vif"); + my @addrs = $config->returnOrigValues("address"); + foreach my $addr (@addrs) { + if (defined $addr && $addr eq "dhcp") { + return 1; + } + } + } + } + + $config->setLevel("interfaces bridge"); + my @bridges = $config->listNodes("."); + foreach my $bridge (@bridges) { + $config->setLevel("interfaces bridge $bridge"); + my @addrs = $config->returnOrigValues("address"); + foreach my $addr (@addrs) { + if (defined $addr && $addr eq "dhcp") { + return 1; + } + } + } + + return 0; + +} + sub is_dhcp_enabled { my $intf = shift; @@ -246,8 +287,9 @@ if (defined $update_dnsforwarding) { if (!(defined $use_system_nameservers) && (@use_dhcp_nameservers == 0) && (@use_nameservers == 0)) { my $nameserver_exists = check_nameserver(); - if ($nameserver_exists < 1){ - print "DNS forwarding warning: No DNS servers ('system' or 'dhcp received') to forward queries.\n"; + my $dhcp_enabled_any_interface = check_dhcp_any_interface(); + if ($nameserver_exists < 1 && $dhcp_enabled_any_interface == 0){ + print "DNS forwarding warning: No name-servers to forward DNS queries\n"; } } diff --git a/templates/service/dns/forwarding/dhcp/node.def b/templates/service/dns/forwarding/dhcp/node.def index f56a51c2..8ce8c83f 100644 --- a/templates/service/dns/forwarding/dhcp/node.def +++ b/templates/service/dns/forwarding/dhcp/node.def @@ -1,6 +1,6 @@ multi: type: txt -help: Set to forward DNS queries to nameservers received from DHCP server for specified interface +help: Set to use nameservers received from DHCP server for specified interface commit:expression: exec "/opt/vyatta/sbin/vyatta-dns-forwarding.pl --dhcp-interface $VAR(@)" allowed: local -a array ; |