I was wondering if I needed to change the following code with my own data and numbers, for example my own DNS data, or if it would be fine leaving it?

use strict; use Net::DNS::Nameserver; # ip to bind dns server to my $BINDIP = "127.0.0.1"; my $BINDPORT = 53; my %spoof = ( 'microsoft.com' => '72.14.179.47', ); my @ns = qw/4.2.2.2 4.2.2.3/; my $hostsfile = "/etc/hosts"; open(HOSTS, "<$hostsfile") || die "Can't read $hostsfile: $!"; while (<HOSTS>) { if (/^\s*(\d+\.\d+\.\d+\.\d+)\s+([^#\s]+)/) { $spoof{lc($2)} = $1; } } close(HOSTS); my $resolver = new Net::DNS::Resolver( nameservers => \@ns, recurse => 1, ); sub uniq {     my %seen;     grep !$seen{$_}++, @_; } sub reply_handler { my ($qname, $qclass, $qtype, $peerhost,$query,$conn) = @_; my ($rcode, @ans, @auth, @add); my $err = "NOERROR"; print "Received query from $peerhost to ". $conn->{sockhost}. "\n" +; $query->print; if ($spoof{lc($qname)}) { my ($ttl, $rdata) = (3600, $spoof{lc($qname)}); my $rr = new Net::DNS::RR("$qname $ttl $qclass $qtype $rdata") +; push @ans, $rr; } else { my $ret = $resolver->search($qname); if ($ret) { foreach my $rr ($ret->answer) { next unless $rr->type eq "A";      push @ans, @{$ret->{answer}};      } } else { $err = "NXDOMAIN"; } } @ans = uniq(@ans); return ($err, \@ans, \@auth, \@add, { aa => 1 }); } my $ns = new Net::DNS::Nameserver( LocalPort => $BINDPORT, LocalAddr => $BINDIP, ReplyHandler => \&reply_handler, Verbose => 1 ) || die "couldn't create nameserver object\n"; $ns->main_loop;

In reply to Perl networking DNS by b0b.5m1th.f4

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.