1Net::DNS::Update(3)   User Contributed Perl Documentation  Net::DNS::Update(3)
2
3
4

NAME

6       Net::DNS::Update - DNS dynamic update packet
7

SYNOPSIS

9           use Net::DNS;
10
11           $update = new Net::DNS::Update( 'example.com', 'IN' );
12
13           $update->push( prereq => nxrrset('foo.example.com. AAAA') );
14           $update->push( update => rr_add('foo.example.com. 86400 AAAA 2001::DB8::1') );
15

DESCRIPTION

17       Net::DNS::Update is a subclass of Net::DNS::Packet, to be used for
18       making DNS dynamic updates.
19
20       Programmers should refer to RFC2136 for dynamic update semantics.
21

METHODS

23   new
24           $update = new Net::DNS::Update;
25           $update = new Net::DNS::Update( 'example.com' );
26           $update = new Net::DNS::Update( 'example.com', 'HS' );
27
28       Returns a Net::DNS::Update object suitable for performing a DNS dynamic
29       update.      Specifically, it creates a packet with the header opcode
30       set to UPDATE and the zone record type to SOA (per RFC 2136, Section
31       2.3).
32
33       Programs must use the push() method to add RRs to the prerequisite and
34       update sections before performing the update.
35
36       Arguments are the zone name and the class.  The zone and class may be
37       undefined or omitted and default to the default domain from the
38       resolver configuration and IN respectively.
39
40   push
41           $ancount = $update->push( prereq => $rr );
42           $nscount = $update->push( update => $rr );
43           $arcount = $update->push( additional => $rr );
44
45           $nscount = $update->push( update => $rr1, $rr2, $rr3 );
46           $nscount = $update->push( update => @rr );
47
48       Adds RRs to the specified section of the update packet.
49
50       Returns the number of resource records in the specified section.
51
52       Section names may be abbreviated to the first three characters.
53
54   unique_push
55           $ancount = $update->unique_push( prereq => $rr );
56           $nscount = $update->unique_push( update => $rr );
57           $arcount = $update->unique_push( additional => $rr );
58
59           $nscount = $update->unique_push( update => $rr1, $rr2, $rr3 );
60           $nscount = $update->unique_push( update => @rr );
61
62       Adds RRs to the specified section of the update packet provided that
63       the RRs are not already present in the same section.
64
65       Returns the number of resource records in the specified section.
66
67       Section names may be abbreviated to the first three characters.
68

EXAMPLES

70       The first example below shows a complete program.  Subsequent examples
71       show only the creation of the update packet.
72
73       Although the examples are presented using the string form of RRs, the
74       corresponding ( name => value ) form may also be used.
75
76   Add a new host
77           #!/usr/bin/perl
78
79           use Net::DNS;
80
81           # Create the update packet.
82           my $update = new Net::DNS::Update('example.com');
83
84           # Prerequisite is that no address records exist for the name.
85           $update->push( pre => nxrrset('foo.example.com. A') );
86           $update->push( pre => nxrrset('foo.example.com. AAAA') );
87
88           # Add two address records for the name.
89           $update->push( update => rr_add('foo.example.com. 86400 A 192.0.2.1') );
90           $update->push( update => rr_add('foo.example.com. 86400 AAAA 2001:DB8::1') );
91
92           # Send the update to the zone's primary master.
93           my $resolver = new Net::DNS::Resolver;
94           $resolver->nameservers('primary-master.example.com');
95
96           my $reply = $resolver->send($update);
97
98           # Did it work?
99           if ($reply) {
100                   if ( $reply->header->rcode eq 'NOERROR' ) {
101                           print "Update succeeded\n";
102                   } else {
103                           print 'Update failed: ', $reply->header->rcode, "\n";
104                   }
105           } else {
106                   print 'Update failed: ', $resolver->errorstring, "\n";
107           }
108
109   Add an MX record for a name that already exists
110           my $update = new Net::DNS::Update('example.com');
111           $update->push( prereq => yxdomain('example.com') );
112           $update->push( update => rr_add('example.com MX 10 mailhost.example.com') );
113
114   Add a TXT record for a name that does not exist
115           my $update = new Net::DNS::Update('example.com');
116           $update->push( prereq => nxdomain('info.example.com') );
117           $update->push( update => rr_add('info.example.com TXT "yabba dabba doo"') );
118
119   Delete all A records for a name
120           my $update = new Net::DNS::Update('example.com');
121           $update->push( prereq => yxrrset('foo.example.com A') );
122           $update->push( update => rr_del('foo.example.com A') );
123
124   Delete all RRs for a name
125           my $update = new Net::DNS::Update('example.com');
126           $update->push( prereq => yxdomain('byebye.example.com') );
127           $update->push( update => rr_del('byebye.example.com') );
128
129   Perform a DNS update signed using a BIND private key file
130           my $update = new Net::DNS::Update('example.com');
131           $update->push( update => rr_add('foo.example.com AAAA 2001:DB8::1') );
132           $update->sign_tsig( "$dir/Khmac-sha512.example.com.+165+01018.private" );
133           my $reply = $resolver->send( $update );
134           $reply->verify( $update ) || die $reply->verifyerr;
135
136   Signing the DNS update using a BIND public key file
137           $update->sign_tsig( "$dir/Khmac-sha512.example.com.+165+01018.key" );
138
139   Signing the DNS update using a customised TSIG record
140           $update->sign_tsig( "$dir/Khmac-sha512.example.com.+165+01018.private",
141                               fudge => 60
142                               );
143
144   Another way to sign a DNS update
145           my $key_name = 'tsig-key';
146           my $key      = 'awwLOtRfpGE+rRKF2+DEiw==';
147
148           my $tsig = new Net::DNS::RR("$key_name TSIG $key");
149           $tsig->fudge(60);
150
151           my $update = new Net::DNS::Update('example.com');
152           $update->push( update     => rr_add('foo.example.com AAAA 2001:DB8::1') );
153           $update->push( additional => $tsig );
154
156       Copyright (c)1997-2000 Michael Fuhr.
157
158       Portions Copyright (c)2002,2003 Chris Reinhardt.
159
160       Portions Copyright (c)2015 Dick Franks.
161
162       All rights reserved.
163

LICENSE

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

SEE ALSO

182       perl, Net::DNS, Net::DNS::Packet, Net::DNS::Header, Net::DNS::RR,
183       Net::DNS::Resolver, RFC 2136, RFC 2845
184
185
186
187perl v5.30.0                      2019-07-26               Net::DNS::Update(3)
Impressum