summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--scripts/dns-forwarding/vyatta-dns-forwarding.pl44
1 files changed, 44 insertions, 0 deletions
diff --git a/scripts/dns-forwarding/vyatta-dns-forwarding.pl b/scripts/dns-forwarding/vyatta-dns-forwarding.pl
index cfa4ee9b..1e2a422f 100644
--- a/scripts/dns-forwarding/vyatta-dns-forwarding.pl
+++ b/scripts/dns-forwarding/vyatta-dns-forwarding.pl
@@ -51,12 +51,14 @@ sub dnsforwarding_get_constants {
my $date = `date`;
chomp $date;
$output = "#\n# autogenerated by vyatta-dns-forwarding.pl on $date\n#\n";
+ $output .= "domain-needed\nbogus-priv\n";
return $output;
}
sub dnsforwarding_get_values {
my $output = '';
my $config = new VyattaConfig;
+ my $use_dnsmasq_conf = 0;
$config->setLevel("service dns forwarding");
@@ -72,6 +74,48 @@ sub dnsforwarding_get_values {
$output .= "cache-size=$cache_size\n";
}
+ my @use_nameservers = $config->returnValues("name-server");
+ if (@use_nameservers != 0){
+ $use_dnsmasq_conf = 1;
+ foreach my $cli_nameserver (@use_nameservers) {
+ $output .= "server=$cli_nameserver\n";
+ }
+ }
+
+ my $use_system_nameservers = $config->exists("system");
+ if (defined($use_system_nameservers)) {
+ $use_dnsmasq_conf = 1;
+ my $sys_config = new VyattaConfig;
+ $sys_config->setLevel("system");
+ my @system_nameservers = $sys_config->returnValues("name-server");
+ if (@system_nameservers > 0) {
+ foreach my $system_nameserver (@system_nameservers) {
+ $output .= "server=$system_nameserver\n";
+ }
+ }
+ }
+
+ my @use_dhcp_nameservers = $config->returnValues("dhcp");
+ if (@use_dhcp_nameservers != 0) {
+ $use_dnsmasq_conf = 1;
+ foreach my $interface (@use_dhcp_nameservers) {
+ my $dhcp_nameserver_count=`grep nameserver /etc/resolv.conf.dhclient-new-$interface | wc -l`;
+ if ($dhcp_nameserver_count > 0) {
+ my @dhcp_nameservers = `grep nameserver /etc/resolv.conf.dhclient-new-$interface`;
+ for my $each_nameserver (@dhcp_nameservers) {
+ my @nameserver = split(/ /, $each_nameserver, 2);
+ my $ns = $nameserver[1];
+ chomp $ns;
+ $output .= "server=$ns\n";
+ }
+ }
+ }
+ }
+
+ if ($use_dnsmasq_conf == 1) {
+ $output .= "resolv-file=/etc/dnsmasq.conf\n";
+ }
+
return $output;
}