I needed to make a lot of records tonight so I just whipped this up. It's a little different from the Net::DNS module in that you don't have to know how to properly form a record. It does it for you.
#!/usr/bin/perl print "\n\n########################################\n"; print "# #\n"; print "# This script will create a basic #\n"; print "# DNS Record for use with BIND8++ #\n"; print "# #\n"; print "############################################\n\n\n"; $control = 1; while ($control > 0) { print "What is the domain you would like to create? (e.g., yah +oo.com)\n"; $domain = <STDIN>; chomp($domain); print "You typed: $domain. Is this correct? <y|n>\t"; $temp = <STDIN>; chomp($temp); if ($temp ne "y") { next; } $control = 0; } $control = 1; while ($control > 0) { print "What is the IP address for this domain? (e.g., 127.0.0. +1)\n"; $domIP = <STDIN>; chomp($domIP); print "You typed: $domIP. Is this correct? <y|n>\t"; $temp = <STDIN>; chomp($temp); if ($temp ne "y") { next; } $control = 0; } print "\nWe will begin processing $domain at $domIP.\n"; sleep(1); $control = 1; while ($control > 0) { print "\nPlease give the canonical name of the primary nameser +ver (e.g., ns1.nameserver.com)\n"; $primeNS = <STDIN>; chomp($primeNS); print "You typed: $primeNS. Is this correct? <y|n>\t"; $temp = <STDIN>; chomp($temp); if ($temp ne "y") { next; } $control = 0; } $control = 1; while ($control > 0) { print "\nPlease give the canonical name of the secondary names +erver.\n"; $secNS = <STDIN>; chomp($secNS); print "You typed: $secNS. Is this correct? <y|n>\t"; $temp = <STDIN>; chomp($temp); if ($temp ne "y") { next; } $control = 0; } $control = 1; while ($control > 0) { print "\nWhat is the contact email? (webmaster\@$domain)\n"; $contMail = <STDIN>; chomp($contMail); print "You typed: $contMail. Is this correct? <y|n>\t"; $temp = <STDIN>; chomp($temp); if ($temp ne "y") { next; } $control = 0; $contMail =~ s/[@]/./; } print "Would you like to have a serial number generated for you? <y|n> +\t"; $temp2 = <STDIN>; chomp($temp2); if ($temp2 ne "y") { $control = 1; while ($control > 0) { print "\nPlease enter your serial number.\n"; $serial = <STDIN>; chomp($serial); print "You typed: $serial. Is this correct? <y|n>\t" +; $temp = <STDIN>; chomp($temp); if ($temp ne "y") { next; } $control = 0; } } else { &genSerial; } print "The following values will be used for your dns records. You ma +y adjust them to your taste.\n\n\t10800\tRefresh\n\t3600\tRetry\n\t60 +4800\tExpire\n\t86400\tTTL\n\n"; $fileName = "db.$domain"; &printOut($domain, $domIP, $primeNS, $secNS, $contMail, $serial, $file +Name); print "\nCongratulations! Your DNS record was created in file $fileNa +me for $domain.\n"; sub genSerial { print "Generating serial number."; @breakMeUp = localtime(time); print "."; $year = (1900 + $breakMeUp[5]); print "."; $month = ($breakMeUp[4] + 1); print "."; $day = $breakMeUp[3]; print "."; $serial = "$year"."$month"."$day"."01"; print "$serial\n"; return $serial; } sub printOut($domain, $domIP, $primeNS, $secNS, $contMail, $serial, $f +ileName) { open(DNSFILE, ">$fileName"); select(DNSFILE); print <<til_the_end; $domain. IN SOA $primeNS. $contMail. ($seri +al ; Serial Number 10800; + Refresh 3600; + Retry 604800 +; Expire 86400) +; TTL $domain. IN NS $primeNS. $domain. IN NS $secNS. www.$domain. IN A $domIP ftp.$domain. IN A $domIP $domain. IN A $domIP mail.$domain. IN MX 10 www.$domain. til_the_end close(DNSFILE); }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Basic DNS Record Creation
by merlyn (Sage) on Feb 06, 2001 at 11:33 UTC | |
by CiceroLove (Monk) on Feb 06, 2001 at 21:49 UTC |
Back to
Cool Uses for Perl