Server IP : 103.119.228.120 / Your IP : 18.119.127.13 Web Server : Apache System : Linux v8.techscape8.com 3.10.0-1160.119.1.el7.tuxcare.els2.x86_64 #1 SMP Mon Jul 15 12:09:18 UTC 2024 x86_64 User : nobody ( 99) PHP Version : 5.6.40 Disable Function : shell_exec,symlink,system,exec,proc_get_status,proc_nice,proc_terminate,define_syslog_variables,syslog,openlog,closelog,escapeshellcmd,passthru,ocinum cols,ini_alter,leak,listen,chgrp,apache_note,apache_setenv,debugger_on,debugger_off,ftp_exec,dl,dll,myshellexec,proc_open,socket_bind,proc_close,escapeshellarg,parse_ini_filepopen,fpassthru,exec,passthru,escapeshellarg,escapeshellcmd,proc_close,proc_open,ini_alter,popen,show_source,proc_nice,proc_terminate,proc_get_status,proc_close,pfsockopen,leak,apache_child_terminate,posix_kill,posix_mkfifo,posix_setpgid,posix_setsid,posix_setuid,dl,symlink,shell_exec,system,dl,passthru,escapeshellarg,escapeshellcmd,myshellexec,c99_buff_prepare,c99_sess_put,fpassthru,getdisfunc,fx29exec,fx29exec2,is_windows,disp_freespace,fx29sh_getupdate,fx29_buff_prepare,fx29_sess_put,fx29shexit,fx29fsearch,fx29ftpbrutecheck,fx29sh_tools,fx29sh_about,milw0rm,imagez,sh_name,myshellexec,checkproxyhost,dosyayicek,c99_buff_prepare,c99_sess_put,c99getsource,c99sh_getupdate,c99fsearch,c99shexit,view_perms,posix_getpwuid,posix_getgrgid,posix_kill,parse_perms,parsesort,view_perms_color,set_encoder_input,ls_setcheckboxall,ls_reverse_all,rsg_read,rsg_glob,selfURL,dispsecinfo,unix2DosTime,addFile,system,get_users,view_size,DirFiles,DirFilesWide,DirPrintHTMLHeaders,GetFilesTotal,GetTitles,GetTimeTotal,GetMatchesCount,GetFileMatchesCount,GetResultFiles,fs_copy_dir,fs_copy_obj,fs_move_dir,fs_move_obj,fs_rmdir,SearchText,getmicrotime MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /usr/local/share/man/man3/ |
Upload File : |
.\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Net::DNS::Nameserver 3" .TH Net::DNS::Nameserver 3 "2016-05-27" "perl v5.16.3" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Net::DNS::Nameserver \- DNS server class .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use Net::DNS::Nameserver; \& \& $nameserver = new Net::DNS::Nameserver( \& LocalAddr => [\*(Aq::1\*(Aq , \*(Aq127.0.0.1\*(Aq ], \& LocalPort => "5353", \& ReplyHandler => \e&reply_handler, \& Verbose => 1, \& Truncate => 0 \& ); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" Instances of the \f(CW\*(C`Net::DNS::Nameserver\*(C'\fR class represent \s-1DNS\s0 server objects. See \*(L"\s-1EXAMPLE\*(R"\s0 for an example. .SH "METHODS" .IX Header "METHODS" .SS "new" .IX Subsection "new" .Vb 6 \& my $ns = new Net::DNS::Nameserver( \& LocalAddr => "10.1.2.3", \& LocalPort => "5353", \& ReplyHandler => \e&reply_handler, \& Verbose => 1 \& ); \& \& \& \& my $ns = new Net::DNS::Nameserver( \& LocalAddr => [\*(Aq::1\*(Aq , \*(Aq127.0.0.1\*(Aq ], \& LocalPort => "5353", \& ReplyHandler => \e&reply_handler, \& Verbose => 1, \& Truncate => 0 \& ); .Ve .PP Returns a Net::DNS::Nameserver object, or undef if the object could not be created. .PP Attributes are: .PP .Vb 10 \& LocalAddr IP address on which to listen. Defaults to INADDR_ANY. \& LocalPort Port on which to listen. Defaults to 53. \& ReplyHandler Reference to reply\-handling \& subroutine Required. \& NotifyHandler Reference to reply\-handling \& subroutine for queries with \& opcode NOTIFY (RFC1996) \& Verbose Print info about received \& queries. Defaults to 0 (off). \& Truncate Truncates UDP packets that \& are too big for the reply Defaults to 1 (on) \& IdleTimeout TCP clients are disconnected \& if they are idle longer than \& this duration. Defaults to 120 (secs) .Ve .PP The LocalAddr attribute may alternatively be specified as a list of \s-1IP\s0 addresses to listen to. .PP If IO::Socket::INET6 and Socket6 are available on the system you can also list IPv6 addresses and the default is '0' (listen on all interfaces on IPv6 and IPv4); .PP The ReplyHandler subroutine is passed the query name, query class, query type and optionally an argument containing the peerhost, the incoming query, and the name of the incoming socket (sockethost). It must either return the response code and references to the answer, authority, and additional sections of the response, or undef to leave the query unanswered. Common response codes are: .PP .Vb 6 \& NOERROR No error \& FORMERR Format error \& SERVFAIL Server failure \& NXDOMAIN Non\-existent domain (name doesn\*(Aqt exist) \& NOTIMP Not implemented \& REFUSED Query refused .Ve .PP For advanced usage it may also contain a headermask containing an hashref with the settings for the \f(CW\*(C`aa\*(C'\fR, \f(CW\*(C`ra\*(C'\fR, and \f(CW\*(C`ad\*(C'\fR header bits. The argument is of the form \&\f(CW\*(C`{ ad => 1, aa => 0, ra => 1 }\*(C'\fR. .PP See \s-1RFC 1035\s0 and the \s-1IANA\s0 dns-parameters file for more information: .PP .Vb 2 \& ftp://ftp.rfc\-editor.org/in\-notes/rfc1035.txt \& http://www.isi.edu/in\-notes/iana/assignments/dns\-parameters .Ve .PP The nameserver will listen for both \s-1UDP\s0 and \s-1TCP\s0 connections. On Unix-like systems, the program will probably have to run as root to listen on the default port, 53. A non-privileged user should be able to listen on ports 1024 and higher. .PP Packet Truncation is new functionality available in \s-1VERSION \s0> 830. Only \s-1UDP\s0 replies are truncated. The size limit is determined by the advertised \s-1EDNS0\s0 size in the query, otherwise 512 is used. .PP If you want to do packet truncation yourself you should set Truncate to 0 and truncate the reply packet in the code of the ReplyHandler. .PP See \*(L"\s-1EXAMPLE\*(R"\s0 for an example. .SS "main_loop" .IX Subsection "main_loop" .Vb 1 \& $ns\->main_loop; .Ve .PP Start accepting queries. Calling main_loop never returns. .SS "loop_once" .IX Subsection "loop_once" .Vb 1 \& $ns\->loop_once( [TIMEOUT_IN_SECONDS] ); .Ve .PP Start accepting queries, but returns. If called without a parameter, the call will not return until a request has been received (and replied to). If called with a number, that number specifies how many seconds (even fractional) to maximum wait before returning. If called with 0 it will return immediately unless there's something to do. .PP Handling a request and replying obviously depends on the speed of ReplyHandler. Assuming ReplyHandler is super fast, loop_once should spend just a fraction of a second, if called with a timeout value of 0 seconds. One exception is when an \s-1AXFR\s0 has requested a huge amount of data that the \s-1OS\s0 is not ready to receive in full. In that case, it will keep running through a loop (while servicing new requests) until the reply has been sent. .PP In case loop_once accepted a \s-1TCP\s0 connection it will immediatly check if there is data to be read from the socket. If not it will return and you will have to call \fIloop_once()\fR again to check if there is any data waiting on the socket to be processed. In most cases you will have to count on calling \*(L"loop_once\*(R" twice. .PP A code fragment like: .PP .Vb 4 \& $ns\->loop_once(10); \& while( $ns\->get_open_tcp() ){ \& $ns\->loop_once(0); \& } .Ve .PP Would wait for 10 seconds for the initial connection and would then process all \s-1TCP\s0 sockets until none is left. .SS "get_open_tcp" .IX Subsection "get_open_tcp" In scalar context returns the number of \s-1TCP\s0 connections for which state is maintained. In array context it returns IO::Socket objects, these could be useful for troubleshooting but be careful using them. .SH "EXAMPLE" .IX Header "EXAMPLE" The following example will listen on port 5353 and respond to all queries for A records with the \s-1IP\s0 address 10.1.2.3. All other queries will be answered with \s-1NXDOMAIN. \s0 Authority and additional sections are left empty. The \f(CW$peerhost\fR variable catches the \s-1IP\s0 address of the peer host, so that additional filtering on its basis may be applied. .PP .Vb 1 \& #!/usr/bin/perl \& \& use strict; \& use warnings; \& use Net::DNS::Nameserver; \& \& sub reply_handler { \& my ($qname, $qclass, $qtype, $peerhost,$query,$conn) = @_; \& my ($rcode, @ans, @auth, @add); \& \& print "Received query from $peerhost to ". $conn\->{sockhost}. "\en"; \& $query\->print; \& \& if ($qtype eq "A" && $qname eq "foo.example.com" ) { \& my ($ttl, $rdata) = (3600, "10.1.2.3"); \& my $rr = new Net::DNS::RR("$qname $ttl $qclass $qtype $rdata"); \& push @ans, $rr; \& $rcode = "NOERROR"; \& }elsif( $qname eq "foo.example.com" ) { \& $rcode = "NOERROR"; \& \& }else{ \& $rcode = "NXDOMAIN"; \& } \& \& # mark the answer as authoritive (by setting the \*(Aqaa\*(Aq flag \& return ($rcode, \e@ans, \e@auth, \e@add, { aa => 1 }); \& } \& \& my $ns = new Net::DNS::Nameserver( \& LocalPort => 5353, \& ReplyHandler => \e&reply_handler, \& Verbose => 1 \& ) || die "couldn\*(Aqt create nameserver object\en"; \& \& $ns\->main_loop; .Ve .SH "BUGS" .IX Header "BUGS" Limitations in perl 5.8.6 makes it impossible to guarantee that replies to \s-1UDP\s0 queries from Net::DNS::Nameserver are sent from the IP-address they were received on. This is a problem for machines with multiple IP-addresses and causes violation of \s-1RFC2181\s0 section 4. Thus a \s-1UDP\s0 socket created listening to \s-1INADDR_ANY \s0(all available IP-addresses) will reply not necessarily with the source address being the one to which the request was sent, but rather with the address that the operating system chooses. This is also often called \*(L"the closest address\*(R". This should really only be a problem on a server which has more than one IP-address (besides localhost \- any experience with IPv6 complications here, would be nice). If this is a problem for you, a work-around would be to not listen to \s-1INADDR_ANY\s0 but to specify each address that you want this module to listen on. A separate set of sockets will then be created for each IP-address. .SH "COPYRIGHT" .IX Header "COPYRIGHT" Copyright (c)2000 Michael Fuhr. .PP Portions Copyright (c)2002\-2004 Chris Reinhardt. .PP Portions Copyright (c)2005 Robert Martin-Legene. .PP Portions Copyright (c)2005\-2009 O.M, Kolkman, \s-1RIPE NCC.\s0 .PP All rights reserved. .SH "LICENSE" .IX Header "LICENSE" Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation, and that the name of the author not be used in advertising or publicity pertaining to distribution of the software without specific prior written permission. .PP \&\s-1THE SOFTWARE IS PROVIDED \*(L"AS IS\*(R", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\s0 .SH "SEE ALSO" .IX Header "SEE ALSO" perl, Net::DNS, Net::DNS::Resolver, Net::DNS::Packet, Net::DNS::Update, Net::DNS::Header, Net::DNS::Question, Net::DNS::RR, \s-1RFC 1035\s0