Skip to content

Instantly share code, notes, and snippets.

@ilyaevseev
Created December 3, 2022 21:00
Show Gist options
  • Select an option

  • Save ilyaevseev/8168ead94a41c8e42a568f0936c7b83a to your computer and use it in GitHub Desktop.

Select an option

Save ilyaevseev/8168ead94a41c8e42a568f0936c7b83a to your computer and use it in GitHub Desktop.

Revisions

  1. ilyaevseev created this gist Dec 3, 2022.
    21 changes: 21 additions & 0 deletions check-nservers
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    #!/usr/bin/perl

    use strict;
    use warnings;
    use Storable qw/freeze/;

    $Storable::canonical = 1; # https://www.perlmonks.org/?node_id=127254

    die "Usage: $0 domain-name\n" unless @ARGV == 1;
    my $domain = shift @ARGV;

    open F, "whois $domain |" or die "Cannot run whois: $!\n";
    my @nservers = sort map { s/[\.\r\n]+$//; my @a = split; lc $a[$#a] } grep { /nserver:/i or /name server:/i } <F>;
    print $_,"\n" foreach "=== WHOIS ===",@nservers;

    foreach my $s (@nservers) {
    open F, "host -t ns $domain $s |" or die "Cannot query $s: $!\n";
    my @ns = sort map { s/[\.\r\n]+$//; my @a = split; lc $a[$#a] } grep { /name server/ } <F>;
    next if freeze(\@ns) eq freeze(\@nservers);
    print $_,"\n" foreach "=== $s ===",@ns;
    }