#!/usr/bin/perl -nl # # $Id: check-mx.pl,v 1.2 2003/01/13 05:28:42 jmates Exp $ # # Copyright (c) 2002, Jeremy Mates. This script is free software; # you can redistribute it and/or modify it under the same terms as # Perl itself. # # Looks for potentially improperly terminated MX records in BIND zone # files. # # Usage: check-mx.pl zonefile [... zonefileN] # pull out MX target for consideration if (m/IN\s+MX\s+\d+\s+(.+?)\s*$/) { $mx = $1; # look for MX targets containing dots without a trailing dot if ($mx =~ m/\.[^\z]/ and $mx !~ m/\.$/) { print "$ARGV:$.:$_"; } } # reset line counter for proper multi-file operation close ARGV if eof; =head1 POD Validates zone files by looking for MX records that contain what look like other domain names without trailing dots, which often expand out to bogus names like host.example.edu.example.edu: $ cat zonefile IN MX 7 goodmx.example.edu. IN MX 7 badmx.example.edu IN MX 7 defaultzonemx $ ./check-mx.pl zonefile zonefile:2: IN MX 7 badmx.example.edu =cut