1Net::DNS::Update(3) User Contributed Perl Documentation Net::DNS::Update(3)
2
3
4
6 Net::DNS::Update - Create a DNS update packet
7
9 use Net::DNS::Update;
10
11 $update = Net::DNS::Update->new;
12 $update = Net::DNS::Update->new('example.com', 'IN');
13
14 $update->push(prerequisite => nxrrset('foo.example.com. A'));
15 $update->push(update => rr_add('foo.example.com. 86400 A 192.168.1.2'));
16
18 "Net::DNS::Update" is a subclass of "Net::DNS::Packet", to be used for
19 making DNS dynamic updates. Programmers should refer to RFC 2136 for
20 the semantics of dynamic updates.
21
23 new
24 $update = Net::DNS::Update->new;
25 $update = Net::DNS::Update->new('example.com');
26 $update = Net::DNS::Update->new('example.com', 'HS');
27
28 Returns a "Net::DNS::Update" object used to perform a DNS dynamic
29 update operation. Specifically, it creates a packet with the header
30 opcode set to UPDATE and zone qtype to SOA (per RFC 2136, 2.3).
31
32 Programs must use the "push" method to add RRs to the prerequisite,
33 update, and additional sections before performing the update.
34
35 Arguments are the zone name and the class. If the zone is omitted, the
36 default domain will be taken from the resolver configuration. If the
37 class is omitted, it defaults to IN.
38
39 Future versions of "Net::DNS" may provide a simpler interface for
40 making dynamic updates.
41
43 The first example below shows a complete program; subsequent examples
44 show only the creation of the update packet.
45
46 Add a new host
47 #!/usr/bin/perl -w
48
49 use strict;
50 use Net::DNS;
51
52 # Create the update packet.
53 my $update = Net::DNS::Update->new('example.com');
54
55 # Prerequisite is that no A records exist for the name.
56 $update->push(prerequisite => nxrrset('foo.example.com. A'));
57
58 # Add two A records for the name.
59 $update->push(update => rr_add('foo.example.com. 86400 A 192.168.1.2'));
60 $update->push(update => rr_add('foo.example.com. 86400 A 172.16.3.4'));
61
62 # Send the update to the zone's primary master.
63 my $res = Net::DNS::Resolver->new;
64 $res->nameservers('primary-master.example.com');
65
66 my $reply = $res->send($update);
67
68 # Did it work?
69 if ($reply) {
70 my $rcode = $reply->header->rcode;
71 print 'Update ', $rcode eq 'NOERROR' ? "succeeded\n" : "failed: $rcode\n";
72 } else {
73 print 'Update failed: ', $res->errorstring, "\n";
74 }
75
76 Add an MX record for a name that already exists
77 my $update = Net::DNS::Update->new('example.com');
78 $update->push(prerequisite => yxdomain('example.com'));
79 $update->push(update => rr_add('example.com MX 10 mailhost.example.com'));
80
81 Add a TXT record for a name that doesn't exist
82 my $update = Net::DNS::Update->new('example.com');
83 $update->push(prerequisite => nxdomain('info.example.com'));
84 $update->push(update => rr_add('info.example.com TXT "yabba dabba doo"'));
85
86 Delete all A records for a name
87 my $update = Net::DNS::Update->new('example.com');
88 $update->push(prerequisite => yxrrset('foo.example.com A'));
89 $update->push(update => rr_del('foo.example.com A'));
90
91 Delete all RRs for a name
92 my $update = Net::DNS::Update->new('example.com');
93 $update->push(prerequisite => yxdomain('byebye.example.com'));
94 $update->push(update => rr_del('byebye.example.com'));
95
96 Perform a signed update
97 my $key_name = 'tsig-key';
98 my $key_data = 'awwLOtRfpGE+rRKF2+DEiw==';
99
100 my $update = Net::DNS::Update->new('example.com');
101 $update->push(update => rr_add('foo.example.com A 10.1.2.3'));
102 $update->push(update => rr_add('bar.example.com A 10.4.5.6'));
103 $update->sign_tsig($key_name, $key_data);
104
105 Another way to perform a signed update
106 my $key_name = 'tsig-key';
107 my $key_data = 'awwLOtRfpGE+rRKF2+DEiw==';
108
109 my $update = Net::DNS::Update->new('example.com');
110 $update->push(update => rr_add('foo.example.com A 10.1.2.3'));
111 $update->push(update => rr_add('bar.example.com A 10.4.5.6'));
112 $update->push(additional => Net::DNS::RR->new("$key_name TSIG $key_data"));
113
114 Perform a signed update with a customized TSIG record
115 my $key_name = 'tsig-key';
116 my $key_data = 'awwLOtRfpGE+rRKF2+DEiw==';
117
118 my $tsig = Net::DNS::RR->new("$key_name TSIG $key_data");
119 $tsig->fudge(60);
120
121 my $update = Net::DNS::Update->new('example.com');
122 $update->push(update => rr_add('foo.example.com A 10.1.2.3'));
123 $update->push(update => rr_add('bar.example.com A 10.4.5.6'));
124 $update->push(additional => $tsig);
125
127 WARNING: This code is still under development. Please use with
128 caution on production nameservers.
129
131 Copyright (c)1997-2002 Michael Fuhr.
132
133 Portions Copyright (c)2002-2004 Chris Reinhardt.
134
135 All rights reserved.
136
137 This program is free software; you may redistribute it and/or modify it
138 under the same terms as Perl itself.
139
141 perl, Net::DNS, Net::DNS::Resolver, Net::DNS::Header, Net::DNS::Packet,
142 Net::DNS::Question, Net::DNS::RR, RFC 2136, RFC 2845
143
144
145
146perl v5.16.3 2012-12-28 Net::DNS::Update(3)