diff options
author | Mohit Mehta <mohit.mehta@vyatta.com> | 2008-08-07 06:15:13 +0000 |
---|---|---|
committer | Mohit Mehta <mohit.mehta@vyatta.com> | 2008-08-07 06:15:13 +0000 |
commit | 5b8a423bda33dee2e19faea3bb4ddcd078554d0c (patch) | |
tree | d48e2e130094fec74a28460e50b88aa807802433 /scripts/dns-forwarding | |
parent | e32fd4accf3776dfd7312cba2d56a7e0e4a064b8 (diff) | |
download | vyatta-cfg-system-5b8a423bda33dee2e19faea3bb4ddcd078554d0c.tar.gz vyatta-cfg-system-5b8a423bda33dee2e19faea3bb4ddcd078554d0c.zip |
configure dnsmasq to use dns-servers as specified in CLI
Diffstat (limited to 'scripts/dns-forwarding')
-rw-r--r-- | scripts/dns-forwarding/vyatta-dns-forwarding.pl | 44 |
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; } |