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

NAME

6       Net::DNS::Update - Create a DNS update packet
7

SYNOPSIS

9       "use Net::DNS::Update;"
10

DESCRIPTION

12       "Net::DNS::Update" is a subclass of "Net::DNS::Packet", to be used for
13       making DNS dynamic updates.  Programmers should refer to RFC 2136 for
14       the semantics of dynamic updates.
15
16       WARNING:  This code is still under development.  Please use with
17       caution on production nameservers.
18

METHODS

20   new
21           $packet = Net::DNS::Update->new;
22           $packet = Net::DNS::Update->new('example.com');
23           $packet = Net::DNS::Update->new('example.com', 'HS');
24
25       Returns a "Net::DNS::Update" object suitable for performing a DNS
26       dynamic update.  Specifically, it creates a packet with the header
27       opcode set to UPDATE and the zone record type to SOA (per RFC 2136,
28       Section 2.3).
29
30       Programs must use the "push" method to add RRs to the prerequisite,
31       update, and additional sections before performing the update.
32
33       Arguments are the zone name and the class.  If the zone is omitted, the
34       default domain will be taken from the resolver configuration.  If the
35       class is omitted, it defaults to IN.
36
37       Future versions of "Net::DNS" may provide a simpler interface for
38       making dynamic updates.
39

EXAMPLES

41       The first example below shows a complete program; subsequent examples
42       show only the creation of the update packet.
43
44   Add a new host
45        #!/usr/bin/perl -w
46
47        use Net::DNS;
48        use strict;
49
50        # Create the update packet.
51        my $update = Net::DNS::Update->new('example.com');
52
53        # Prerequisite is that no A records exist for the name.
54        $update->push(pre => nxrrset('foo.example.com. A'));
55
56        # Add two A records for the name.
57        $update->push(update => rr_add('foo.example.com. 86400 A 192.168.1.2'));
58        $update->push(update => rr_add('foo.example.com. 86400 A 172.16.3.4'));
59
60        # Send the update to the zone's primary master.
61        my $res = Net::DNS::Resolver->new;
62        $res->nameservers('primary-master.example.com');
63
64        my $reply = $res->send($update);
65
66        # Did it work?
67        if ($reply) {
68            if ($reply->header->rcode eq 'NOERROR') {
69                print "Update succeeded\n";
70            } else {
71                print 'Update failed: ', $reply->header->rcode, "\n";
72            }
73        } else {
74            print 'Update failed: ', $res->errorstring, "\n";
75        }
76
77   Add an MX record for a name that already exists
78           my $update = Net::DNS::Update->new('example.com');
79           $update->push(pre    => yxdomain('example.com'));
80           $update->push(update => rr_add('example.com MX 10 mailhost.example.com'));
81
82   Add a TXT record for a name that doesn't exist
83           my $update = Net::DNS::Update->new('example.com');
84           $update->push(pre    => nxdomain('info.example.com'));
85           $update->push(update => rr_add('info.example.com TXT "yabba dabba doo"'));
86
87   Delete all A records for a name
88           my $update = Net::DNS::Update->new('example.com');
89           $update->push(pre    => yxrrset('foo.example.com A'));
90           $update->push(update => rr_del('foo.example.com A'));
91
92   Delete all RRs for a name
93           my $update = Net::DNS::Update->new('example.com');
94           $update->push(pre    => yxdomain('byebye.example.com'));
95           $update->push(update => rr_del('byebye.example.com'));
96
97   Perform a signed update
98           my $key_name = 'tsig-key';
99           my $key      = 'awwLOtRfpGE+rRKF2+DEiw==';
100
101           my $update = Net::DNS::Update->new('example.com');
102           $update->push(update => rr_add('foo.example.com A 10.1.2.3'));
103           $update->push(update => rr_add('bar.example.com A 10.4.5.6'));
104           $update->sign_tsig($key_name, $key);
105
106   Another way to perform a signed update
107           my $key_name = 'tsig-key';
108           my $key      = 'awwLOtRfpGE+rRKF2+DEiw==';
109
110           my $update = Net::DNS::Update->new('example.com');
111           $update->push(update     => rr_add('foo.example.com A 10.1.2.3'));
112           $update->push(update     => rr_add('bar.example.com A 10.4.5.6'));
113           $update->push(additional => Net::DNS::RR->new("$key_name TSIG $key"));
114
115   Perform a signed update with a customized TSIG record
116           my $key_name = 'tsig-key';
117           my $key      = 'awwLOtRfpGE+rRKF2+DEiw==';
118
119           my $tsig = Net::DNS::RR->new("$key_name TSIG $key");
120           $tsig->fudge(60);
121
122           my $update = Net::DNS::Update->new('example.com');
123           $update->push(update     => rr_add('foo.example.com A 10.1.2.3'));
124           $update->push(update     => rr_add('bar.example.com A 10.4.5.6'));
125           $update->push(additional => $tsig);
126

BUGS

128       This code is still under development.  Please use with caution on
129       production nameservers.
130
132       Copyright (c) 1997-2002 Michael Fuhr.
133
134       Portions Copyright (c) 2002-2004 Chris Reinhardt.
135
136       All rights reserved.  This program is free software; you may
137       redistribute it and/or modify it under the same terms as Perl itself.
138

SEE ALSO

140       perl(1), Net::DNS, Net::DNS::Resolver, Net::DNS::Header,
141       Net::DNS::Packet, Net::DNS::Question, Net::DNS::RR, RFC 2136, RFC 2845
142
143
144
145perl v5.10.1                      2009-01-26               Net::DNS::Update(3)
Impressum