summaryrefslogtreecommitdiff
path: root/scripts/dns-forwarding
diff options
context:
space:
mode:
authorRobert Bays <rbays@cartagena.vyatta.com>2008-09-03 18:22:19 -0400
committerRobert Bays <rbays@cartagena.vyatta.com>2008-09-03 18:22:19 -0400
commit0740e78bcdea29ca5fb34ab3fb05edbcf3aaf3e6 (patch)
tree327755924533310e81bc2d24b5035c920d465e31 /scripts/dns-forwarding
parent11eca774916110faaf375470c9a4d73c498d8cae (diff)
parenta43151a69c1482c1c10806e83271f94fb691199d (diff)
downloadvyatta-cfg-quagga-0740e78bcdea29ca5fb34ab3fb05edbcf3aaf3e6.tar.gz
vyatta-cfg-quagga-0740e78bcdea29ca5fb34ab3fb05edbcf3aaf3e6.zip
Merge branch 'islavista' of http://git.vyatta.com/vyatta-cfg-system into islavista
Conflicts: scripts/install-system
Diffstat (limited to 'scripts/dns-forwarding')
-rw-r--r--scripts/dns-forwarding/vyatta-dns-forwarding.pl68
1 files changed, 46 insertions, 22 deletions
diff --git a/scripts/dns-forwarding/vyatta-dns-forwarding.pl b/scripts/dns-forwarding/vyatta-dns-forwarding.pl
index c2ef968a..08cea70a 100644
--- a/scripts/dns-forwarding/vyatta-dns-forwarding.pl
+++ b/scripts/dns-forwarding/vyatta-dns-forwarding.pl
@@ -37,12 +37,10 @@ my $dnsforwarding_conf = '/etc/dnsmasq.conf';
sub dnsforwarding_restart {
system("$dnsforwarding_init restart >&/dev/null");
- print "Setting up DNS forwarding.\n";
}
sub dnsforwarding_stop {
system("$dnsforwarding_init stop >&/dev/null");
- print "Stopping DNS forwarding.\n";
}
sub dnsforwarding_get_constants {
@@ -164,11 +162,45 @@ sub check_system_nameserver {
}
-sub check_dhcp_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;
- my $intf = shift;
- my $cmd = `grep nameserver /etc/resolv.conf.dhclient-new-$intf|wc -l`;
- return $cmd;
}
sub is_dhcp_enabled {
@@ -205,14 +237,13 @@ sub check_dhcp_interface {
my $interface = shift;
if (!is_dhcp_enabled($interface)) {
- print "$interface is not using DHCP to get an IP address\n";
+ print "DNS forwarding error: $interface is not using DHCP to get an IP address\n";
return 0;
}
if (-e "/var/run/vyatta/dhclient/dhclient_release_$interface") {
# dhcp released for the interface
- print "DHCP lease for $interface has been released.\n";
- print "Renew lease for $interface before setting this parameter.\n";
+ print "DNS forwarding error: DHCP lease for $interface has been released by user\n";
return 0;
}
@@ -224,26 +255,18 @@ sub check_dhcp_interface {
# main
#
-my ($update_dnsforwarding, $stop_dnsforwarding, $system_nameserver, $dhcp_interface, $dhcp_interface_nameserver, $dhclient_script);
+my ($update_dnsforwarding, $stop_dnsforwarding, $system_nameserver, $dhcp_interface, $dhclient_script);
GetOptions("update-dnsforwarding!" => \$update_dnsforwarding,
"stop-dnsforwarding!" => \$stop_dnsforwarding,
"system-nameserver!" => \$system_nameserver,
- "dhcp-interface-nameserver=s" => \$dhcp_interface_nameserver,
"dhclient-script!" => \$dhclient_script,
"dhcp-interface=s" => \$dhcp_interface);
if (defined $system_nameserver) {
my $system_nameserver_exists = check_system_nameserver();
if ($system_nameserver_exists < 1){
- print "Warning: No DNS servers set in system to forward queries.\n";
- }
-}
-
-if (defined $dhcp_interface_nameserver) {
- my $dhcp_interface_nameserver_exists = check_dhcp_nameserver($dhcp_interface_nameserver);
- if ($dhcp_interface_nameserver_exists < 1){
- print "Warning: No DNS servers received from DHCP server for $dhcp_interface_nameserver.\n";
+ print "DNS forwarding warning: No DNS servers set in system to forward queries\n";
}
}
@@ -264,10 +287,11 @@ 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 "Warning: No DNS servers ('system set' 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";
}
- }
+ }
my $called_from_dhclient_script = 0;
if (defined $dhclient_script){