DNS Check in Perl
Latest small project in perl was an easy DNS check that turned into a bigger battle when moving it to a linux box. Everything has been solved and I’m pretty excited.
I used some big, public name servers to run the checks and make sure hostnames were pointing to where they should be. I decided against using Net::DNS and backticked the host script because I’m lazy and my boss told me to. If anything is wrong, I send an email using Net::SMTP. I originally wanted to use MIME::Lite but had some issues.
.
.
.
my @name_servers = (”8.8.8.8″, “156.154.70.1″, “4.2.2.1″, “8.8.4.4″,”208.67.222.222″);
foreach my $server (@name_servers) {
while ( my ($key, $value) = each %dns_check) {
my $found_addr = `host $key $server` or die “problem! $!\n”;
if ($found_addr =~ m/(\d.*)/) {
if ($1 ne $value) {
#send email if address pulled doesn’t match what it should be