Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
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); }

In reply to Basic DNS Record Creation by CiceroLove

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2021-07-31 05:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?