How does a Client Verify if the DNS server is Alive or down
Wah Peng
wah_peng at yahoo.com.sg
Tue Oct 20 06:50:00 UTC 2015
Hello,
Network issue should be detected by other ways.
But DNS health check can be done by sending a normal DNS query to the
server and try get a valid response.
This is the script what I use to check the health of my DNS server. :D
#!/usr/bin/perl
use strict;
use Net::DNS;
use POSIX 'strftime';
use MIME::Lite;
use MIME::Words qw(encode_mimewords);
my $debug = 0;
my $test_rr = 'alive.example.net';
my $test_val = '8.8.8.8';
my @nameservers = qw(1.1.1.1 2.2.2.2);
for my $ns (@nameservers) {
test_query($ns);
}
sub test_query {
my $ns = shift;
my $res = Net::DNS::Resolver->new(nameservers => [$ns]);
$res->tcp_timeout(10);
$res->udp_timeout(10);
my $answer = $res->query($test_rr);
if (defined $answer) {
my @rr = $answer->answer;
if ($rr[0]->address ne $test_val) {
sendmail( "DNS not matched: $ns" );
print "$ns wrong\n";
}
if ($debug) {
print "$ns expected value for $test_rr: $test_val\n";
print "$ns got value for $test_rr: ", $rr[0]->address,"\n";
}
} else {
sendmail( "Can't query to: $ns" );
print "$ns wrong\n";
}
}
sub sendmail {
# your email function to send the alerts
}
Regards.
On 2015/10/20 星期二 14:26, Harshith Mulky wrote:
> How can a Client verify if the DNS Server is Running(named service is
> Running) or Down?
> Does it periodically send any messages to the server. What Kind of
> messages are required by the client to be sent towards server to
> determine if the DNS IP is reachable or not?
More information about the bind-users
mailing list