Class | Dnsruby::Update |
In: |
lib/Dnsruby/update.rb
|
Parent: | Message |
The first example below shows a complete program; subsequent examples show only the creation of the update packet.
require 'Dnsruby' # Create the update packet. update = Dnsruby::Update.new('example.com') # Prerequisite is that no A records exist for the name. update.absent('foo.example.com.', 'A') # Add two A records for the name. update.add('foo.example.com.', 'A', 86400, '192.168.1.2') update.add('foo.example.com.', 'A', 86400, '172.16.3.4') # Send the update to the zone's primary master. res = Dnsruby::Resolver.new({:nameserver => 'primary-master.example.com'}) begin reply = res.send_message(update) print "Update succeeded\n" rescue Exception => e print 'Update failed: #{e}\n' end
update = Dnsruby::Update.new('example.com') update.present('example.com') update.add('example.com', Dnsruby::Types.MX, 10, 'mailhost.example.com')
update = Dnsruby::Update.new('example.com') update.absent('info.example.com') update.add('info.example.com', Types.TXT, 86400, "yabba dabba doo"')
update = Dnsruby::Update.new('example.com') update.present('foo.example.com', 'A') update.delete('foo.example.com', 'A')
update = Dnsruby::Update.new('example.com') update.present('byebye.example.com') update.delete('byebye.example.com')
key_name = 'tsig-key' key = 'awwLOtRfpGE+rRKF2+DEiw==' update = Dnsruby::Update.new('example.com') update.add('foo.example.com', 'A', 86400, 10.1.2.3')) update.add('bar.example.com', 'A', 86400, 10.4.5.6')) res.tsig=(key_name,key)
Returns a Dnsruby::Update object suitable for performing a DNS dynamic update. Specifically, it creates a message with the header opcode set to UPDATE and the zone record type to SOA (per RFC 2136, Section 2.3).
Programs must use the push method to add RRs to the prerequisite, update, and additional sections before performing the update.
Arguments are the zone name and the class. If the zone is omitted, the default domain will be taken from the resolver configuration. If the class is omitted, it defaults to IN.
packet = Dnsruby::Update.new packet = Dnsruby::Update.new('example.com') packet = Dnsruby::Update.new('example.com', 'HS')
Ways to create the prerequisite records (exists, notexists, inuse, etc. - RFC2136, section 2.4) Can be called with one arg :
update.absent(name) (5) Name is not in use. No RR of any type is owned by a specified NAME. Note that this prerequisite IS satisfied by empty nonterminals.
Or with two :
update.absent(name, type) (3) RRset does not exist. No RRs with a specified NAME and TYPE (in the zone and class denoted by the Zone Section) can exist.
Ways to create the update records (add, delete, RFC2136, section 2.5)
" 2.5.1 - Add To An RRset RRs are added to the Update Section whose NAME, TYPE, TTL, RDLENGTH and RDATA are those being added, and CLASS is the same as the zone class. Any duplicate RRs will be silently ignored by the primary master." update.add(rr) update.add([rr1, rr2]) update.add(name, type, ttl, rdata)
Ways to create the prerequisite records (exists, notexists, inuse, etc. - RFC2136, section 2.4)
(1) RRset exists (value independent). At least one RR with a specified NAME and TYPE (in the zone and class specified by the Zone Section) must exist. update.present(name, type) (2) RRset exists (value dependent). A set of RRs with a specified NAME and TYPE exists and has the same members with the same RDATAs as the RRset specified here in this Section. update.present(name, type, rdata) (4) Name is in use. At least one RR with a specified NAME (in the zone and class specified by the Zone Section) must exist. Note that this prerequisite is NOT satisfied by empty nonterminals. update.present(name)