1Net::DNS::ZoneFile(3) User Contributed Perl DocumentationNet::DNS::ZoneFile(3)
2
3
4

NAME

6       Net::DNS::ZoneFile - DNS zone file
7

SYNOPSIS

9           use Net::DNS::ZoneFile;
10
11           $zonefile = Net::DNS::ZoneFile->new( 'named.example' );
12
13           while ( $rr = $zonefile->read ) {
14               $rr->print;
15           }
16
17           @zone = $zonefile->read;
18

DESCRIPTION

20       Each Net::DNS::ZoneFile object instance represents a zone file together
21       with any subordinate files introduced by the $INCLUDE directive.  Zone
22       file syntax is defined by RFC1035.
23
24       A program may have multiple zone file objects, each maintaining its own
25       independent parser state information.
26
27       The parser supports both the $TTL directive defined by RFC2308 and the
28       BIND $GENERATE syntax extension.
29
30       All RRs in a zone file must have the same class, which may be specified
31       for the first RR encountered and is then propagated automatically to
32       all subsequent records.
33

METHODS

35   new
36           $zonefile = Net::DNS::ZoneFile->new( 'filename', ['example.com'] );
37
38           $handle   = IO::File->new( 'filename', '<:encoding(ISO8859-7)' );
39           $zonefile = Net::DNS::ZoneFile->new( $handle, ['example.com'] );
40
41       The new() constructor returns a Net::DNS::ZoneFile object which
42       represents the zone file specified in the argument list.
43
44       The specified file or file handle is open for reading and closed when
45       exhausted or all references to the ZoneFile object cease to exist.
46
47       The optional second argument specifies $ORIGIN for the zone file.
48
49       Zone files are presumed to be UTF-8 encoded where that is supported.
50
51       Alternative character encodings may be specified indirectly by creating
52       a file handle with the desired encoding layer, which is then passed as
53       an argument to new(). The specified encoding is propagated to files
54       introduced by $INCLUDE directives.
55
56   read
57           $rr = $zonefile->read;
58           @rr = $zonefile->read;
59
60       When invoked in scalar context, read() returns a Net::DNS::RR object
61       representing the next resource record encountered in the zone file, or
62       undefined if end of data has been reached.
63
64       When invoked in list context, read() returns the list of Net::DNS::RR
65       objects in the order that they appear in the zone file.
66
67       Comments and blank lines are silently disregarded.
68
69       $INCLUDE, $ORIGIN, $TTL and $GENERATE directives are processed
70       transparently.
71
72   name
73           $filename = $zonefile->name;
74
75       Returns the name of the current zone file.  Embedded $INCLUDE
76       directives will cause this to differ from the filename argument
77       supplied when the object was created.
78
79   line
80           $line = $zonefile->line;
81
82       Returns the number of the last line read from the current zone file.
83
84   origin
85           $origin = $zonefile->origin;
86
87       Returns the fully qualified name of the current origin within the zone
88       file.
89
90   ttl
91           $ttl = $zonefile->ttl;
92
93       Returns the default TTL as specified by the $TTL directive.
94

COMPATIBILITY WITH Net::DNS::ZoneFile 1.04

96       Applications which depended on the defunct Net::DNS::ZoneFile 1.04 CPAN
97       distribution will continue to operate with minimal change using the
98       compatibility interface described below.  New application code should
99       use the object-oriented interface.
100
101           use Net::DNS::ZoneFile;
102
103           $listref = Net::DNS::ZoneFile->read( $filename );
104           $listref = Net::DNS::ZoneFile->read( $filename, $include_dir );
105
106           $listref = Net::DNS::ZoneFile->readfh( $filehandle );
107           $listref = Net::DNS::ZoneFile->readfh( $filehandle, $include_dir );
108
109           $listref = Net::DNS::ZoneFile->parse(  $string );
110           $listref = Net::DNS::ZoneFile->parse( \$string );
111           $listref = Net::DNS::ZoneFile->parse(  $string, $include_dir );
112           $listref = Net::DNS::ZoneFile->parse( \$string, $include_dir );
113
114           $_->print for @$listref;
115
116       The optional second argument specifies the default path for filenames.
117       The current working directory is used by default.
118
119       Although not available in the original implementation, the RR list can
120       be obtained directly by calling any of these methods in list context.
121
122           @rr = Net::DNS::ZoneFile->read( $filename, $include_dir );
123
124       The partial result is returned if an error is encountered by the
125       parser.
126
127   read
128           $listref = Net::DNS::ZoneFile->read( $filename );
129           $listref = Net::DNS::ZoneFile->read( $filename, $include_dir );
130
131       read() parses the contents of the specified file and returns a
132       reference to the list of Net::DNS::RR objects.  The return value is
133       undefined if an error is encountered by the parser.
134
135   readfh
136           $listref = Net::DNS::ZoneFile->readfh( $filehandle );
137           $listref = Net::DNS::ZoneFile->readfh( $filehandle, $include_dir );
138
139       readfh() parses data from the specified file handle and returns a
140       reference to the list of Net::DNS::RR objects.  The return value is
141       undefined if an error is encountered by the parser.
142
143   parse
144           $listref = Net::DNS::ZoneFile->parse(  $string );
145           $listref = Net::DNS::ZoneFile->parse( \$string );
146           $listref = Net::DNS::ZoneFile->parse(  $string, $include_dir );
147           $listref = Net::DNS::ZoneFile->parse( \$string, $include_dir );
148
149       parse() interprets the text in the argument string and returns a
150       reference to the list of Net::DNS::RR objects.  The return value is
151       undefined if an error is encountered by the parser.
152

ACKNOWLEDGEMENTS

154       This package is designed as an improved and compatible replacement for
155       Net::DNS::ZoneFile 1.04 which was created by Luis Munoz in 2002 as a
156       separate CPAN module.
157
158       The present implementation is the result of an agreement to merge our
159       two different approaches into one package integrated into Net::DNS.
160       The contribution of Luis Munoz is gratefully acknowledged.
161
162       Thanks are also due to Willem Toorop for his constructive criticism of
163       the initial version and invaluable assistance during testing.
164
166       Copyright (c)2011-2012 Dick Franks.
167
168       All rights reserved.
169

LICENSE

171       Permission to use, copy, modify, and distribute this software and its
172       documentation for any purpose and without fee is hereby granted,
173       provided that the above copyright notice appear in all copies and that
174       both that copyright notice and this permission notice appear in
175       supporting documentation, and that the name of the author not be used
176       in advertising or publicity pertaining to distribution of the software
177       without specific prior written permission.
178
179       THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
180       OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
181       MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
182       IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
183       CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
184       TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
185       SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
186

SEE ALSO

188       perl, Net::DNS, Net::DNS::RR, RFC1035 Section 5.1, RFC2308, BIND 9
189       Administrator Reference Manual
190
191
192
193perl v5.34.0                      2021-07-22             Net::DNS::ZoneFile(3)
Impressum