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 = Net::DNS::Update->new( 'example.com', 'IN' );
12
13           $update->push( prereq => nxrrset('host.example.com. AAAA') );
14           $update->push( update => rr_add('host.example.com. 86400 AAAA 2001::DB8::F00') );
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 = Net::DNS::Update->new;
25           $update = Net::DNS::Update->new( 'example.com' );
26           $update = Net::DNS::Update->new( 'example.com', 'IN' );
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 = Net::DNS::Update->new('example.com');
83
84           # Prerequisite is that no address records exist for the name.
85           $update->push( pre => nxrrset('host.example.com. A') );
86           $update->push( pre => nxrrset('host.example.com. AAAA') );
87
88           # Add two address records for the name.
89           $update->push( update => rr_add('host.example.com. 86400 A 192.0.2.1') );
90           $update->push( update => rr_add('host.example.com. 86400 AAAA 2001:DB8::1') );
91
92           # Send the update to the zone's primary nameserver.
93           my $resolver = Net::DNS::Resolver->new();
94           $resolver->nameservers('DNSprimary.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 = Net::DNS::Update->new('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 = Net::DNS::Update->new('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 = Net::DNS::Update->new('example.com');
121           $update->push( prereq => yxrrset('host.example.com A') );
122           $update->push( update => rr_del('host.example.com A') );
123
124   Delete all RRs for a name
125           my $update = Net::DNS::Update->new('example.com');
126           $update->push( prereq => yxdomain('byebye.example.com') );
127           $update->push( update => rr_del('byebye.example.com') );
128
129   Perform DNS update signed using a key generated by BIND tsig-keygen
130           my $update = Net::DNS::Update->new('example.com');
131           $update->push( update => rr_add('host.example.com AAAA 2001:DB8::1') );
132           $update->sign_tsig( $key_file );
133           my $reply = $resolver->send( $update );
134           $reply->verify( $update ) || die $reply->verifyerr;
135
136   Signing the DNS update using a customised TSIG record
137           $update->sign_tsig( $key_file, fudge => 60 );
138
139   Signing the DNS update using private key generated by BIND dnssec-keygen
140           $update->sign_tsig( "$dir/Khmac-sha512.example.com.+165+01018.private" );
141
142   Signing the DNS update using public key generated by BIND dnssec-keygen
143           $update->sign_tsig( "$dir/Khmac-sha512.example.com.+165+01018.key" );
144
145   Another way to sign a DNS update
146           use Net::DNS::RR::TSIG;
147
148           my $tsig = create Net::DNS::RR::TSIG( $key_file );
149           $tsig->fudge(60);
150
151           my $update = Net::DNS::Update->new('example.com');
152           $update->push( update     => rr_add('host.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 original copyright notices appear in all copies and
168       that both 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 RFC2136 <https://tools.ietf.org/html/rfc2136>
184       RFC8945 <https://tools.ietf.org/html/rfc8945>
185
186
187
188perl v5.36.1                      2023-06-01               Net::DNS::Update(3)
Impressum