cvs: peardoc /en/package/networking net-dns.xml
| From: | Eric Kilfoil | Date: | Sun, 10 Apr 2005 23:03:16 +0000 |
| Subject: | cvs: peardoc /en/package/networking net-dns.xml | ||
| Groups: | php.pear.doc | ||
| Request: | Send a blank email to pear-doc+get-5919@lists.php.net to get a copy of this message | ||
ekilfoil Sun Apr 10 19:03:16 2005 EDT
Modified files:
/peardoc/en/package/networking net-dns.xml
Log:
Added information about dynamic dns updates
http://cvs.php.net/diff.php/peardoc/en/package/networking/net-dns.xml?r1=1.3&r2=1.4&ty=u Index: peardoc/en/package/networking/net-dns.xml diff -u peardoc/en/package/networking/net-dns.xml:1.3 peardoc/en/package/networking/net-dns.xml:1.4 --- peardoc/en/package/networking/net-dns.xml:1.3 Sun Apr 10 16:26:50 2005 +++ peardoc/en/package/networking/net-dns.xml Sun Apr 10 19:03:16 2005 @@ -1,4 +1,4 @@ -<!-- $Revision: 1.3 $ --> +<!-- $Revision: 1.4 $ --> <sect1 id="package.networking.net-dns"> <title>Net_DNS</title> <para> @@ -12,7 +12,6 @@ <refname>Class Summary <classname>Net_DNS</classname></refname> <refpurpose>DNS Packet manipulation class</refpurpose> </refnamediv> - <refsect1> <title>DNS Packet manipulation class</title> <para> @@ -40,345 +39,470 @@ Provides a resolver implementation to handle DNS queries </refpurpose> </refnamediv> - <refsect1> - <title>Net_DNS_Resolver</title> - <para> - The resolver class a high level interface for communicating with DNS - servers. It uses the UNIX system stub resolver configuration files (if - available) to configure the resolver. The resolver can also be configured - manually by overriding the system configuration. This is done by setting - the appropriate values in the Net_DNS_Resolver object. See <link - linkend="package.networking.net-dns.net-dns-resolver.query">Net_DNS_Resolver::query()</link> - for more information on the resolver configuration. - </para> - </refsect1> - </refentry> - <refentry id="package.networking.net-dns.net-dns-rr-intro"> + <refsect1> + <title>Net_DNS_Resolver</title> + <para> + The resolver class a high level interface for communicating with DNS + servers. It uses the UNIX system stub resolver configuration files (if + available) to configure the resolver. The resolver can also be configured + manually by overriding the system configuration. This is done by setting + the appropriate values in the Net_DNS_Resolver object. See <link + linkend="package.networking.net-dns.net-dns-resolver.query">Net_DNS_Resolver::query()</link> + for more information on the resolver configuration. + </para> + </refsect1> + </refentry> + &package.networking.net-dns.net-dns-resolver.query; + &package.networking.net-dns.net-dns-resolver.rawQuery; + &package.networking.net-dns.net-dns-resolver.axfr; + <refentry id="package.networking.net-dns.net-dns-rr-intro"> + <refnamediv> + <refname> + Class Summary <classname>Net_DNS_RR</classname> + </refname> + <refpurpose> + Provides resource record parsing and creation + </refpurpose> + </refnamediv> + <refsect1> + <title>Net_DNS_RR</title> + <para> + The Net_DNS_RR class provides methods of parsing + resource records returned by a nameserver, creation of + resource record objects to be sent to a nameserver, and + the ability to access each component of an RR as an + object property. + </para> + <para> + Each resource record object MUST contain the following properties: + <itemizedlist> + <listitem><para><parameter>name</parameter> - The DNS name of the RR</para></listitem> + <listitem><para><parameter>type</parameter> - The RR type</para></listitem> + <listitem><para><parameter>class</parameter> - The RR class (normally IN)</para></listitem> + <listitem><para><parameter>ttl</parameter> - The RR time to live</para></listitem> + <listitem><para><parameter>rdlength</parameter> - The amount of data (in bytes) of the rdata section</para></listitem> + <listitem><para><parameter>rdata</parameter> - The data (uncompressed) of the right hand side of the RR</para></listitem> + </itemizedlist> + </para> + <para> + If <parameter>type</parameter> is a supported RR type, + it will automatically be decompressed and/or decoded + into its appropriate property values. The values inside + of an RR object will vary based on the type of RR. + </para> + <para> + Supported RR types: + <itemizedlist> + <listitem> + <para> + A + <itemizedlist> + <listitem> + <para> + string <parameter>address</parameter> - IPv4 style address + </para> + </listitem> + </itemizedlist> + </para> + </listitem> + <listitem> + <para> + AAAA + <itemizedlist> + <listitem> + <para> + string <parameter>address</parameter> - IPv6 style address + </para> + </listitem> + </itemizedlist> + </para> + </listitem> + <listitem> + <para> + CNAME + <itemizedlist> + <listitem> + <para> + string <parameter>cname</parameter> - The canonical name of the queried host + </para> + </listitem> + </itemizedlist> + </para> + </listitem> + <listitem> + <para> + HINFO + <itemizedlist> + <listitem> + <para> + string <parameter>cpu</parameter> - The host CPU type + </para> + </listitem> + <listitem> + <para> + string <parameter>os</parameter> - Type host operating system + </para> + </listitem> + </itemizedlist> + </para> + </listitem> + <listitem> + <para> + MX + <itemizedlist> + <listitem> + <para> + integer <parameter>preference</parameter> - The MX preference (lower takes priority + </para> + </listitem> + <listitem> + <para> + string <parameter>exchange</parameter> - The name of the mail exchange host + </para> + </listitem> + </itemizedlist> + </para> + </listitem> + <listitem> + <para> + NAPTR + <itemizedlist> + <listitem> + <para> + unknown <parameter>order</parameter> - unknown + </para> + </listitem> + <listitem> + <para> + unknown <parameter>preference</parameter> - unknown + </para> + </listitem> + <listitem> + <para> + unknown <parameter>flags</parameter> - unknown + </para> + </listitem> + <listitem> + <para> + unknown <parameter>services</parameter> - unknown + </para> + </listitem> + <listitem> + <para> + unknown <parameter>regex</parameter> - unknown + </para> + </listitem> + <listitem> + <para> + unknown <parameter>replacement</parameter> - unknown + </para> + </listitem> + </itemizedlist> + </para> + </listitem> + <listitem> + <para> + NS + <itemizedlist> + <listitem> + <para> + string <parameter>nsdname</parameter> - The name of the NS record nameserver + </para> + </listitem> + </itemizedlist> + </para> + </listitem> + <listitem> + <para> + PTR + <itemizedlist> + <listitem> + <para> + string <parameter>ptrdname</parameter> - The name for the queried IP address + </para> + </listitem> + </itemizedlist> + </para> + </listitem> + <listitem> + <para> + SOA + <itemizedlist> + <listitem> + <para> + string <parameter>mname</parameter> - Master nameserver hostname as + specified in the SOA record - not neccessarily accurate + </para> + </listitem> + <listitem> + <para> + string <parameter>rname</parameter> - Email address of the person + responsible for the zone - not neccessarily accurate + </para> + </listitem> + <listitem> + <para> + string <parameter>serial</parameter> - The serial number (version + number) of the retrieved zone + </para> + </listitem> + <listitem> + <para> + string <parameter>refresh</parameter> - The length of time before + the zone should be refresed + </para> + </listitem> + <listitem> + <para> + string <parameter>retry</parameter> - The length of time between + retries for slave servers to refresh the zone + </para> + </listitem> + <listitem> + <para> + string <parameter>expire</parameter> - The length of time before + slave servers should consider the data invalid without refreshing + the zone data. + </para> + </listitem> + <listitem> + <para> + string <parameter>minimum</parameter> - The default TTL for RRs + inside of the zone that are not otherwise specified. + </para> + </listitem> + </itemizedlist> + </para> + </listitem> + <listitem> + <para> + SRV + <itemizedlist> + <listitem> + <para> + unknown <parameter>preference</parameter> - unknown + </para> + </listitem> + <listitem> + <para> + unknown <parameter>weight</parameter> - unknown + </para> + </listitem> + <listitem> + <para> + unknown <parameter>port</parameter> - unknown + </para> + </listitem> + <listitem> + <para> + unknown <parameter>target</parameter> - unknown + </para> + </listitem> + </itemizedlist> + </para> + </listitem> + <listitem> + <para> + TSIG + <itemizedlist> + <listitem> + <para> + integer <parameter>time_signed</parameter> - The time the signature + has was created + </para> + </listitem> + <listitem> + <para> + integer <parameter>fudge</parameter> - The time offset that is + acceptable between the client and the server + </para> + </listitem> + <listitem> + <para> + integer <parameter>mac_size</parameter> - The size of the following + signature data + </para> + </listitem> + <listitem> + <para> + string/binary <parameter>mac</parameter> - The data containing the + has sent by the client/server + </para> + </listitem> + <listitem> + <para> + integer <parameter>original_id</parameter> - The ID sent to or + received from the server identifying this query. + </para> + </listitem> + <listitem> + <para> + integer <parameter>error</parameter> - The value of the error + calculating or verifying the signature. + </para> + </listitem> + <listitem> + <para> + integer <parameter>other_len</parameter> - The amount of data (in + bytes) additional to the signature + </para> + </listitem> + <listitem> + <para> + string <parameter>other_data</parameter> - Additional data required + by the nameserver for the signature. + </para> + </listitem> + <listitem> + <para> + string <parameter>key</parameter> - The key shared by the client and + the server to validate authorization. + </para> + </listitem> + </itemizedlist> + </para> + </listitem> + <listitem> + <para> + TXT + <itemizedlist> + <listitem> + <para> + string <parameter>text</parameter> - The text defined in the record + </para> + </listitem> + </itemizedlist> + </para> + </listitem> + </itemizedlist> + </para> + </refsect1> + </refentry> + <refentry id="package.networking.net-dns.net-dns-updates-example"> <refnamediv> - <refname> - Class Summary <classname>Net_DNS_RR</classname> - </refname> - <refpurpose> - Provides resource record parsing and creation - </refpurpose> + <refname>Examples -- <classname>DNS Updates</classname></refname> + <refpurpose>RFC 2136 DNS Updates</refpurpose> </refnamediv> - <refsect1> - <title>Net_DNS_RR</title> - <para> - The Net_DNS_RR class provides methods of parsing - resource records returned by a nameserver, creation of - resource record objects to be sent to a nameserver, and - the ability to access each component of an RR as an - object property. - </para> - <para> - Each resource record object MUST contain the following properties: - <itemizedlist> - <listitem><para><parameter>name</parameter> - The DNS name of the RR</para></listitem> - <listitem><para><parameter>type</parameter> - The RR type</para></listitem> - <listitem><para><parameter>class</parameter> - The RR class (normally IN)</para></listitem> - <listitem><para><parameter>ttl</parameter> - The RR time to live</para></listitem> - <listitem><para><parameter>rdlength</parameter> - The amount of data (in bytes) of the rdata section</para></listitem> - <listitem><para><parameter>rdata</parameter> - The data (uncompressed) of the right hand side of the RR</para></listitem> - </itemizedlist> - </para> - <para> - If <parameter>type</parameter> is a supported RR type, - it will automatically be decompressed and/or decoded - into its appropriate property values. The values inside - of an RR object will vary based on the type of RR. - </para> - <para> - Supported RR types: - <itemizedlist> - <listitem> - <para> - A - <itemizedlist> - <listitem> - <para> - string <parameter>address</parameter> - IPv4 style address - </para> - </listitem> - </itemizedlist> - </para> - </listitem> - <listitem> - <para> - AAAA - <itemizedlist> - <listitem> - <para> - string <parameter>address</parameter> - IPv6 style address - </para> - </listitem> - </itemizedlist> - </para> - </listitem> - <listitem> - <para> - CNAME - <itemizedlist> - <listitem> - <para> - string <parameter>cname</parameter> - The canonical name of the queried host - </para> - </listitem> - </itemizedlist> - </para> - </listitem> - <listitem> - <para> - HINFO - <itemizedlist> - <listitem> - <para> - string <parameter>cpu</parameter> - The host CPU type - </para> - </listitem> - <listitem> - <para> - string <parameter>os</parameter> - Type host operating system - </para> - </listitem> - </itemizedlist> - </para> - </listitem> - <listitem> - <para> - MX - <itemizedlist> - <listitem> - <para> - integer <parameter>preference</parameter> - The MX preference (lower takes priority - </para> - </listitem> - <listitem> - <para> - string <parameter>exchange</parameter> - The name of the mail exchange host - </para> - </listitem> - </itemizedlist> - </para> - </listitem> - <listitem> - <para> - NAPTR - <itemizedlist> - <listitem> - <para> - unknown <parameter>order</parameter> - unknown - </para> - </listitem> - <listitem> - <para> - unknown <parameter>preference</parameter> - unknown - </para> - </listitem> - <listitem> - <para> - unknown <parameter>flags</parameter> - unknown - </para> - </listitem> - <listitem> - <para> - unknown <parameter>services</parameter> - unknown - </para> - </listitem> - <listitem> - <para> - unknown <parameter>regex</parameter> - unknown - </para> - </listitem> - <listitem> - <para> - unknown <parameter>replacement</parameter> - unknown - </para> - </listitem> - </itemizedlist> - </para> - </listitem> - <listitem> - <para> - NS - <itemizedlist> - <listitem> - <para> - string <parameter>nsdname</parameter> - The name of the NS record nameserver - </para> - </listitem> - </itemizedlist> - </para> - </listitem> - <listitem> - <para> - PTR - <itemizedlist> - <listitem> - <para> - string <parameter>ptrdname</parameter> - The name for the queried IP address - </para> - </listitem> - </itemizedlist> - </para> - </listitem> - <listitem> - <para> - SOA - <itemizedlist> - <listitem> - <para> - string <parameter>mname</parameter> - Master nameserver hostname as - specified in the SOA record - not neccessarily accurate - </para> - </listitem> - <listitem> - <para> - string <parameter>rname</parameter> - Email address of the person - responsible for the zone - not neccessarily accurate - </para> - </listitem> - <listitem> - <para> - string <parameter>serial</parameter> - The serial number (version - number) of the retrieved zone - </para> - </listitem> - <listitem> - <para> - string <parameter>refresh</parameter> - The length of time before - the zone should be refresed - </para> - </listitem> - <listitem> - <para> - string <parameter>retry</parameter> - The length of time between - retries for slave servers to refresh the zone - </para> - </listitem> - <listitem> - <para> - string <parameter>expire</parameter> - The length of time before - slave servers should consider the data invalid without refreshing - the zone data. - </para> - </listitem> - <listitem> - <para> - string <parameter>minimum</parameter> - The default TTL for RRs - inside of the zone that are not otherwise specified. - </para> - </listitem> - </itemizedlist> - </para> - </listitem> - <listitem> - <para> - SRV - <itemizedlist> - <listitem> - <para> - unknown <parameter>preference</parameter> - unknown - </para> - </listitem> - <listitem> - <para> - unknown <parameter>weight</parameter> - unknown - </para> - </listitem> - <listitem> - <para> - unknown <parameter>port</parameter> - unknown - </para> - </listitem> - <listitem> - <para> - unknown <parameter>target</parameter> - unknown - </para> - </listitem> - </itemizedlist> - </para> - </listitem> - <listitem> - <para> - TSIG - <itemizedlist> - <listitem> - <para> - integer <parameter>time_signed</parameter> - The time the signature - has was created - </para> - </listitem> - <listitem> - <para> - integer <parameter>fudge</parameter> - The time offset that is - acceptable between the client and the server - </para> - </listitem> - <listitem> - <para> - integer <parameter>mac_size</parameter> - The size of the following - signature data - </para> - </listitem> - <listitem> - <para> - string/binary <parameter>mac</parameter> - The data containing the - has sent by the client/server - </para> - </listitem> - <listitem> - <para> - integer <parameter>original_id</parameter> - The ID sent to or - received from the server identifying this query. - </para> - </listitem> - <listitem> - <para> - integer <parameter>error</parameter> - The value of the error - calculating or verifying the signature. - </para> - </listitem> - <listitem> - <para> - integer <parameter>other_len</parameter> - The amount of data (in - bytes) additional to the signature - </para> - </listitem> - <listitem> - <para> - string <parameter>other_data</parameter> - Additional data required - by the nameserver for the signature. - </para> - </listitem> - <listitem> - <para> - string <parameter>key</parameter> - The key shared by the client and - the server to validate authorization. - </para> - </listitem> - </itemizedlist> - </para> - </listitem> - <listitem> - <para> - TXT - <itemizedlist> - <listitem> - <para> - string <parameter>text</parameter> - The text defined in the record - </para> - </listitem> - </itemizedlist> - </para> - </listitem> - </itemizedlist> - </para> - </refsect1> - </refentry> - &package.networking.net-dns.net-dns-resolver.query; - &package.networking.net-dns.net-dns-resolver.rawQuery; - &package.networking.net-dns.net-dns-resolver.axfr; + <refsect1> + <title>RFC 2136 DNS Updates</title> + <para> + By constructing a specially formatted DNS packet and sending it to a + nameserver, a dynamic DNS update can be performed very easily. RFC 2136 + defines some variations of a DNS packet that are used by Net_DNS to + request an update. The nameserver must first be configured to accept + DNS updates, a key must be established between the client and server, + and most importantly, the PHP mhash extension must be included for + processing the MD5 digest of the key. + </para> + <para> + For a complete listing of all of the fields that are available for DNS + updates, please review RFC2136 (http://www.ietf.org/rfc/rfc2136.txt). + The following examples show the simplest forms of a DNS update. + </para> + <example> + <title>Sending a dynamic DNS update packet to a nameserver</title> + <programlisting role="php"> + <![CDATA[ +<?php +require_once 'Net/DNS.php'; + +$resolver = new Net_DNS_Resolver(); + +// We should only send the request to the master server +// accepting DNS updates for the zone. +$r->nameservers = array('192.168.0.254'); + +// We must manually construct the DNS packet for a DNS update +// First we must instantiate the packet object +$packet = new Net_DNS_Packet(); + +// Create the header for the update packet. Most of the defaults are +// acceptable, but we must set the header OPCODE to "UPDATE" +$packet->header = new Net_DNS_Header(); +$packet->header->id = $r->nextid(); +$packet->header->qr = 0; +$packet->header->opcode = "UPDATE"; + +// As specified in RFC2136, the question section becomes the "ZONE" section. +// This specifies the zone for which we are requesting a change. This +// reflects the zone configuration as specified in the nameserver +// configuration. +$packet->question[0] = new Net_DNS_Question('example.com', "SOA", "IN"); + +// The "ANSWER" section of the packet becomes the "PREREQUISITE" section of +// the packet. Section 2.4 of RFC2136 defines the possible values for this +// section. As show below, without any prerequisites the nameserver will +// attempt to perform the update unconditionally. +$packet->answer = array(); + +// The AUTHORITY section becomes the "UPDATE" section of the DNS packet. The +// UPDATE section is a collection of resource record updates that should be +// modified in one form or another. RRs can be deleted or added based on the +// values passed in the RR object. These values are specified in RFC2136 but +// are summarized here: +// +// Adding an RR +// A complete RR object with a non-zero TTL is considered an addition. +// +// Deleting an RR +// A complete RR object with a zero TTL is considered an deletion. An RR that +// matches (exactly) with all values except for the TTL will be removed. +// +// Deleting an RRset +// A complete RR object with a zero TTL and a type of ANY is considered a +// deletion of all RRs with the specified name and type. An RR that matches +// (exactly) with all values except for the TTL and the TYPE will be removed. +// +// Deleting all RRsets for a name +// A complete RR object with a zero TTL, a type of ANY, and a class of ANY is +// considered a deletion of all RRs with the specified name. Any RR that +// matches the name section of the query will be removed. +// +// The following specification will delete the RR that has a name of +// "example.com", class of "IN", type of "A", and an address of +// "192.0.34.166". +$rrDelete = new Net_DNS_RR("example.com. 0 IN A 192.0.34.166"); +// +// The following specification will add an RR that has a name of example.com, +// a TTL of 1 hour, a class of "IN", type of "A", and an address of +// "192.0.34.155"). Note that the only difference between this RR and the +// previous RR is the value of the TTL. +$rrAdd = new Net_DNS_RR("example.com. 3600 IN A 192.0.34.166"); +// +// The RR modifications are added to the authority (UPDATE) section of the DNS +// packet. +$packet->authority[0] = $rrDelete; +$packet->authority[1] = $rrAdd; +// +// The signature must be present in any packet sent to a nameserver that +// requires authentication. The TSIG RR is added to the additional section of +// the DNS packet. +$tsig = new Net_DNS_RR("keyname.as.specified.in.server. TSIG ThisIsMyKey"); +$packet->additional = array($tsig); +// Net_DNS does not automatically calculate the number of records stored in +// each section. This calculation must be done manually. +$packet->header->qdcount = count($packet->question); +$packet->header->ancount = count($packet->answer); +$packet->header->nscount = count($packet->authority); +$packet->header->arcount = count($packet->additional); +// +// After creating your packet, you must send it to the name server for +// processing. DNS updates must use the send_tcp() method: +$response = $r->send_tcp($packet, $packet->data()); +// +// The response from the server will vary. If the update was successfuly, the +// server will have a response code of "NOERROR". Any other error types will +// be reported in the response packet's header "rcode" variable. +if ($ans->header->rcode != "NOERROR") { + return($ans->header->rcode); +} + +?> +]]> + </programlisting> + </example> + </refsect1> + </refentry> </sect1> <!-- Generated by phpDocumentor v 1.2.3 http://www.phpdoc.org --> <!-- Keep this comment at the end of the file
http://cvs.php.net/diff.php/peardoc/en/package/networking/net-dns.xml?r1=1.3&r2=1.4&ty=u Index: peardoc/en/package/networking/net-dns.xml diff -u peardoc/en/package/networking/net-dns.xml:1.3 peardoc/en/package/networking/net-dns.xml:1.4 --- peardoc/en/package/networking/net-dns.xml:1.3 Sun Apr 10 16:26:50 2005 +++ peardoc/en/package/networking/net-dns.xml Sun Apr 10 19:03:16 2005 @@ -1,4 +1,4 @@ -<!-- $Revision: 1.3 $ --> +<!-- $Revision: 1.4 $ --> <sect1 id="package.networking.net-dns"> <title>Net_DNS</title> <para> @@ -12,7 +12,6 @@ <refname>Class Summary <classname>Net_DNS</classname></refname> <refpurpose>DNS Packet manipulation class</refpurpose> </refnamediv> - <refsect1> <title>DNS Packet manipulation class</title> <para> @@ -40,345 +39,470 @@ Provides a resolver implementation to handle DNS queries </refpurpose> </refnamediv> - <refsect1> - <title>Net_DNS_Resolver</title> - <para> - The resolver class a high level interface for communicating with DNS - servers. It uses the UNIX system stub resolver configuration files (if - available) to configure the resolver. The resolver can also be configured - manually by overriding the system configuration. This is done by setting - the appropriate values in the Net_DNS_Resolver object. See <link - linkend="package.networking.net-dns.net-dns-resolver.query">Net_DNS_Resolver::query()</link> - for more information on the resolver configuration. - </para> - </refsect1> - </refentry> - <refentry id="package.networking.net-dns.net-dns-rr-intro"> + <refsect1> + <title>Net_DNS_Resolver</title> + <para> + The resolver class a high level interface for communicating with DNS + servers. It uses the UNIX system stub resolver configuration files (if + available) to configure the resolver. The resolver can also be configured + manually by overriding the system configuration. This is done by setting + the appropriate values in the Net_DNS_Resolver object. See <link + linkend="package.networking.net-dns.net-dns-resolver.query">Net_DNS_Resolver::query()</link> + for more information on the resolver configuration. + </para> + </refsect1> + </refentry> + &package.networking.net-dns.net-dns-resolver.query; + &package.networking.net-dns.net-dns-resolver.rawQuery; + &package.networking.net-dns.net-dns-resolver.axfr; + <refentry id="package.networking.net-dns.net-dns-rr-intro"> + <refnamediv> + <refname> + Class Summary <classname>Net_DNS_RR</classname> + </refname> + <refpurpose> + Provides resource record parsing and creation + </refpurpose> + </refnamediv> + <refsect1> + <title>Net_DNS_RR</title> + <para> + The Net_DNS_RR class provides methods of parsing + resource records returned by a nameserver, creation of + resource record objects to be sent to a nameserver, and + the ability to access each component of an RR as an + object property. + </para> + <para> + Each resource record object MUST contain the following properties: + <itemizedlist> + <listitem><para><parameter>name</parameter> - The DNS name of the RR</para></listitem> + <listitem><para><parameter>type</parameter> - The RR type</para></listitem> + <listitem><para><parameter>class</parameter> - The RR class (normally IN)</para></listitem> + <listitem><para><parameter>ttl</parameter> - The RR time to live</para></listitem> + <listitem><para><parameter>rdlength</parameter> - The amount of data (in bytes) of the rdata section</para></listitem> + <listitem><para><parameter>rdata</parameter> - The data (uncompressed) of the right hand side of the RR</para></listitem> + </itemizedlist> + </para> + <para> + If <parameter>type</parameter> is a supported RR type, + it will automatically be decompressed and/or decoded + into its appropriate property values. The values inside + of an RR object will vary based on the type of RR. + </para> + <para> + Supported RR types: + <itemizedlist> + <listitem> + <para> + A + <itemizedlist> + <listitem> + <para> + string <parameter>address</parameter> - IPv4 style address + </para> + </listitem> + </itemizedlist> + </para> + </listitem> + <listitem> + <para> + AAAA + <itemizedlist> + <listitem> + <para> + string <parameter>address</parameter> - IPv6 style address + </para> + </listitem> + </itemizedlist> + </para> + </listitem> + <listitem> + <para> + CNAME + <itemizedlist> + <listitem> + <para> + string <parameter>cname</parameter> - The canonical name of the queried host + </para> + </listitem> + </itemizedlist> + </para> + </listitem> + <listitem> + <para> + HINFO + <itemizedlist> + <listitem> + <para> + string <parameter>cpu</parameter> - The host CPU type + </para> + </listitem> + <listitem> + <para> + string <parameter>os</parameter> - Type host operating system + </para> + </listitem> + </itemizedlist> + </para> + </listitem> + <listitem> + <para> + MX + <itemizedlist> + <listitem> + <para> + integer <parameter>preference</parameter> - The MX preference (lower takes priority + </para> + </listitem> + <listitem> + <para> + string <parameter>exchange</parameter> - The name of the mail exchange host + </para> + </listitem> + </itemizedlist> + </para> + </listitem> + <listitem> + <para> + NAPTR + <itemizedlist> + <listitem> + <para> + unknown <parameter>order</parameter> - unknown + </para> + </listitem> + <listitem> + <para> + unknown <parameter>preference</parameter> - unknown + </para> + </listitem> + <listitem> + <para> + unknown <parameter>flags</parameter> - unknown + </para> + </listitem> + <listitem> + <para> + unknown <parameter>services</parameter> - unknown + </para> + </listitem> + <listitem> + <para> + unknown <parameter>regex</parameter> - unknown + </para> + </listitem> + <listitem> + <para> + unknown <parameter>replacement</parameter> - unknown + </para> + </listitem> + </itemizedlist> + </para> + </listitem> + <listitem> + <para> + NS + <itemizedlist> + <listitem> + <para> + string <parameter>nsdname</parameter> - The name of the NS record nameserver + </para> + </listitem> + </itemizedlist> + </para> + </listitem> + <listitem> + <para> + PTR + <itemizedlist> + <listitem> + <para> + string <parameter>ptrdname</parameter> - The name for the queried IP address + </para> + </listitem> + </itemizedlist> + </para> + </listitem> + <listitem> + <para> + SOA + <itemizedlist> + <listitem> + <para> + string <parameter>mname</parameter> - Master nameserver hostname as + specified in the SOA record - not neccessarily accurate + </para> + </listitem> + <listitem> + <para> + string <parameter>rname</parameter> - Email address of the person + responsible for the zone - not neccessarily accurate + </para> + </listitem> + <listitem> + <para> + string <parameter>serial</parameter> - The serial number (version + number) of the retrieved zone + </para> + </listitem> + <listitem> + <para> + string <parameter>refresh</parameter> - The length of time before + the zone should be refresed + </para> + </listitem> + <listitem> + <para> + string <parameter>retry</parameter> - The length of time between + retries for slave servers to refresh the zone + </para> + </listitem> + <listitem> + <para> + string <parameter>expire</parameter> - The length of time before + slave servers should consider the data invalid without refreshing + the zone data. + </para> + </listitem> + <listitem> + <para> + string <parameter>minimum</parameter> - The default TTL for RRs + inside of the zone that are not otherwise specified. + </para> + </listitem> + </itemizedlist> + </para> + </listitem> + <listitem> + <para> + SRV + <itemizedlist> + <listitem> + <para> + unknown <parameter>preference</parameter> - unknown + </para> + </listitem> + <listitem> + <para> + unknown <parameter>weight</parameter> - unknown + </para> + </listitem> + <listitem> + <para> + unknown <parameter>port</parameter> - unknown + </para> + </listitem> + <listitem> + <para> + unknown <parameter>target</parameter> - unknown + </para> + </listitem> + </itemizedlist> + </para> + </listitem> + <listitem> + <para> + TSIG + <itemizedlist> + <listitem> + <para> + integer <parameter>time_signed</parameter> - The time the signature + has was created + </para> + </listitem> + <listitem> + <para> + integer <parameter>fudge</parameter> - The time offset that is + acceptable between the client and the server + </para> + </listitem> + <listitem> + <para> + integer <parameter>mac_size</parameter> - The size of the following + signature data + </para> + </listitem> + <listitem> + <para> + string/binary <parameter>mac</parameter> - The data containing the + has sent by the client/server + </para> + </listitem> + <listitem> + <para> + integer <parameter>original_id</parameter> - The ID sent to or + received from the server identifying this query. + </para> + </listitem> + <listitem> + <para> + integer <parameter>error</parameter> - The value of the error + calculating or verifying the signature. + </para> + </listitem> + <listitem> + <para> + integer <parameter>other_len</parameter> - The amount of data (in + bytes) additional to the signature + </para> + </listitem> + <listitem> + <para> + string <parameter>other_data</parameter> - Additional data required + by the nameserver for the signature. + </para> + </listitem> + <listitem> + <para> + string <parameter>key</parameter> - The key shared by the client and + the server to validate authorization. + </para> + </listitem> + </itemizedlist> + </para> + </listitem> + <listitem> + <para> + TXT + <itemizedlist> + <listitem> + <para> + string <parameter>text</parameter> - The text defined in the record + </para> + </listitem> + </itemizedlist> + </para> + </listitem> + </itemizedlist> + </para> + </refsect1> + </refentry> + <refentry id="package.networking.net-dns.net-dns-updates-example"> <refnamediv> - <refname> - Class Summary <classname>Net_DNS_RR</classname> - </refname> - <refpurpose> - Provides resource record parsing and creation - </refpurpose> + <refname>Examples -- <classname>DNS Updates</classname></refname> + <refpurpose>RFC 2136 DNS Updates</refpurpose> </refnamediv> - <refsect1> - <title>Net_DNS_RR</title> - <para> - The Net_DNS_RR class provides methods of parsing - resource records returned by a nameserver, creation of - resource record objects to be sent to a nameserver, and - the ability to access each component of an RR as an - object property. - </para> - <para> - Each resource record object MUST contain the following properties: - <itemizedlist> - <listitem><para><parameter>name</parameter> - The DNS name of the RR</para></listitem> - <listitem><para><parameter>type</parameter> - The RR type</para></listitem> - <listitem><para><parameter>class</parameter> - The RR class (normally IN)</para></listitem> - <listitem><para><parameter>ttl</parameter> - The RR time to live</para></listitem> - <listitem><para><parameter>rdlength</parameter> - The amount of data (in bytes) of the rdata section</para></listitem> - <listitem><para><parameter>rdata</parameter> - The data (uncompressed) of the right hand side of the RR</para></listitem> - </itemizedlist> - </para> - <para> - If <parameter>type</parameter> is a supported RR type, - it will automatically be decompressed and/or decoded - into its appropriate property values. The values inside - of an RR object will vary based on the type of RR. - </para> - <para> - Supported RR types: - <itemizedlist> - <listitem> - <para> - A - <itemizedlist> - <listitem> - <para> - string <parameter>address</parameter> - IPv4 style address - </para> - </listitem> - </itemizedlist> - </para> - </listitem> - <listitem> - <para> - AAAA - <itemizedlist> - <listitem> - <para> - string <parameter>address</parameter> - IPv6 style address - </para> - </listitem> - </itemizedlist> - </para> - </listitem> - <listitem> - <para> - CNAME - <itemizedlist> - <listitem> - <para> - string <parameter>cname</parameter> - The canonical name of the queried host - </para> - </listitem> - </itemizedlist> - </para> - </listitem> - <listitem> - <para> - HINFO - <itemizedlist> - <listitem> - <para> - string <parameter>cpu</parameter> - The host CPU type - </para> - </listitem> - <listitem> - <para> - string <parameter>os</parameter> - Type host operating system - </para> - </listitem> - </itemizedlist> - </para> - </listitem> - <listitem> - <para> - MX - <itemizedlist> - <listitem> - <para> - integer <parameter>preference</parameter> - The MX preference (lower takes priority - </para> - </listitem> - <listitem> - <para> - string <parameter>exchange</parameter> - The name of the mail exchange host - </para> - </listitem> - </itemizedlist> - </para> - </listitem> - <listitem> - <para> - NAPTR - <itemizedlist> - <listitem> - <para> - unknown <parameter>order</parameter> - unknown - </para> - </listitem> - <listitem> - <para> - unknown <parameter>preference</parameter> - unknown - </para> - </listitem> - <listitem> - <para> - unknown <parameter>flags</parameter> - unknown - </para> - </listitem> - <listitem> - <para> - unknown <parameter>services</parameter> - unknown - </para> - </listitem> - <listitem> - <para> - unknown <parameter>regex</parameter> - unknown - </para> - </listitem> - <listitem> - <para> - unknown <parameter>replacement</parameter> - unknown - </para> - </listitem> - </itemizedlist> - </para> - </listitem> - <listitem> - <para> - NS - <itemizedlist> - <listitem> - <para> - string <parameter>nsdname</parameter> - The name of the NS record nameserver - </para> - </listitem> - </itemizedlist> - </para> - </listitem> - <listitem> - <para> - PTR - <itemizedlist> - <listitem> - <para> - string <parameter>ptrdname</parameter> - The name for the queried IP address - </para> - </listitem> - </itemizedlist> - </para> - </listitem> - <listitem> - <para> - SOA - <itemizedlist> - <listitem> - <para> - string <parameter>mname</parameter> - Master nameserver hostname as - specified in the SOA record - not neccessarily accurate - </para> - </listitem> - <listitem> - <para> - string <parameter>rname</parameter> - Email address of the person - responsible for the zone - not neccessarily accurate - </para> - </listitem> - <listitem> - <para> - string <parameter>serial</parameter> - The serial number (version - number) of the retrieved zone - </para> - </listitem> - <listitem> - <para> - string <parameter>refresh</parameter> - The length of time before - the zone should be refresed - </para> - </listitem> - <listitem> - <para> - string <parameter>retry</parameter> - The length of time between - retries for slave servers to refresh the zone - </para> - </listitem> - <listitem> - <para> - string <parameter>expire</parameter> - The length of time before - slave servers should consider the data invalid without refreshing - the zone data. - </para> - </listitem> - <listitem> - <para> - string <parameter>minimum</parameter> - The default TTL for RRs - inside of the zone that are not otherwise specified. - </para> - </listitem> - </itemizedlist> - </para> - </listitem> - <listitem> - <para> - SRV - <itemizedlist> - <listitem> - <para> - unknown <parameter>preference</parameter> - unknown - </para> - </listitem> - <listitem> - <para> - unknown <parameter>weight</parameter> - unknown - </para> - </listitem> - <listitem> - <para> - unknown <parameter>port</parameter> - unknown - </para> - </listitem> - <listitem> - <para> - unknown <parameter>target</parameter> - unknown - </para> - </listitem> - </itemizedlist> - </para> - </listitem> - <listitem> - <para> - TSIG - <itemizedlist> - <listitem> - <para> - integer <parameter>time_signed</parameter> - The time the signature - has was created - </para> - </listitem> - <listitem> - <para> - integer <parameter>fudge</parameter> - The time offset that is - acceptable between the client and the server - </para> - </listitem> - <listitem> - <para> - integer <parameter>mac_size</parameter> - The size of the following - signature data - </para> - </listitem> - <listitem> - <para> - string/binary <parameter>mac</parameter> - The data containing the - has sent by the client/server - </para> - </listitem> - <listitem> - <para> - integer <parameter>original_id</parameter> - The ID sent to or - received from the server identifying this query. - </para> - </listitem> - <listitem> - <para> - integer <parameter>error</parameter> - The value of the error - calculating or verifying the signature. - </para> - </listitem> - <listitem> - <para> - integer <parameter>other_len</parameter> - The amount of data (in - bytes) additional to the signature - </para> - </listitem> - <listitem> - <para> - string <parameter>other_data</parameter> - Additional data required - by the nameserver for the signature. - </para> - </listitem> - <listitem> - <para> - string <parameter>key</parameter> - The key shared by the client and - the server to validate authorization. - </para> - </listitem> - </itemizedlist> - </para> - </listitem> - <listitem> - <para> - TXT - <itemizedlist> - <listitem> - <para> - string <parameter>text</parameter> - The text defined in the record - </para> - </listitem> - </itemizedlist> - </para> - </listitem> - </itemizedlist> - </para> - </refsect1> - </refentry> - &package.networking.net-dns.net-dns-resolver.query; - &package.networking.net-dns.net-dns-resolver.rawQuery; - &package.networking.net-dns.net-dns-resolver.axfr; + <refsect1> + <title>RFC 2136 DNS Updates</title> + <para> + By constructing a specially formatted DNS packet and sending it to a + nameserver, a dynamic DNS update can be performed very easily. RFC 2136 + defines some variations of a DNS packet that are used by Net_DNS to + request an update. The nameserver must first be configured to accept + DNS updates, a key must be established between the client and server, + and most importantly, the PHP mhash extension must be included for + processing the MD5 digest of the key. + </para> + <para> + For a complete listing of all of the fields that are available for DNS + updates, please review RFC2136 (http://www.ietf.org/rfc/rfc2136.txt). + The following examples show the simplest forms of a DNS update. + </para> + <example> + <title>Sending a dynamic DNS update packet to a nameserver</title> + <programlisting role="php"> + <![CDATA[ +<?php +require_once 'Net/DNS.php'; + +$resolver = new Net_DNS_Resolver(); + +// We should only send the request to the master server +// accepting DNS updates for the zone. +$r->nameservers = array('192.168.0.254'); + +// We must manually construct the DNS packet for a DNS update +// First we must instantiate the packet object +$packet = new Net_DNS_Packet(); + +// Create the header for the update packet. Most of the defaults are +// acceptable, but we must set the header OPCODE to "UPDATE" +$packet->header = new Net_DNS_Header(); +$packet->header->id = $r->nextid(); +$packet->header->qr = 0; +$packet->header->opcode = "UPDATE"; + +// As specified in RFC2136, the question section becomes the "ZONE" section. +// This specifies the zone for which we are requesting a change. This +// reflects the zone configuration as specified in the nameserver +// configuration. +$packet->question[0] = new Net_DNS_Question('example.com', "SOA", "IN"); + +// The "ANSWER" section of the packet becomes the "PREREQUISITE" section of +// the packet. Section 2.4 of RFC2136 defines the possible values for this +// section. As show below, without any prerequisites the nameserver will +// attempt to perform the update unconditionally. +$packet->answer = array(); + +// The AUTHORITY section becomes the "UPDATE" section of the DNS packet. The +// UPDATE section is a collection of resource record updates that should be +// modified in one form or another. RRs can be deleted or added based on the +// values passed in the RR object. These values are specified in RFC2136 but +// are summarized here: +// +// Adding an RR +// A complete RR object with a non-zero TTL is considered an addition. +// +// Deleting an RR +// A complete RR object with a zero TTL is considered an deletion. An RR that +// matches (exactly) with all values except for the TTL will be removed. +// +// Deleting an RRset +// A complete RR object with a zero TTL and a type of ANY is considered a +// deletion of all RRs with the specified name and type. An RR that matches +// (exactly) with all values except for the TTL and the TYPE will be removed. +// +// Deleting all RRsets for a name +// A complete RR object with a zero TTL, a type of ANY, and a class of ANY is +// considered a deletion of all RRs with the specified name. Any RR that +// matches the name section of the query will be removed. +// +// The following specification will delete the RR that has a name of +// "example.com", class of "IN", type of "A", and an address of +// "192.0.34.166". +$rrDelete = new Net_DNS_RR("example.com. 0 IN A 192.0.34.166"); +// +// The following specification will add an RR that has a name of example.com, +// a TTL of 1 hour, a class of "IN", type of "A", and an address of +// "192.0.34.155"). Note that the only difference between this RR and the +// previous RR is the value of the TTL. +$rrAdd = new Net_DNS_RR("example.com. 3600 IN A 192.0.34.166"); +// +// The RR modifications are added to the authority (UPDATE) section of the DNS +// packet. +$packet->authority[0] = $rrDelete; +$packet->authority[1] = $rrAdd; +// +// The signature must be present in any packet sent to a nameserver that +// requires authentication. The TSIG RR is added to the additional section of +// the DNS packet. +$tsig = new Net_DNS_RR("keyname.as.specified.in.server. TSIG ThisIsMyKey"); +$packet->additional = array($tsig); +// Net_DNS does not automatically calculate the number of records stored in +// each section. This calculation must be done manually. +$packet->header->qdcount = count($packet->question); +$packet->header->ancount = count($packet->answer); +$packet->header->nscount = count($packet->authority); +$packet->header->arcount = count($packet->additional); +// +// After creating your packet, you must send it to the name server for +// processing. DNS updates must use the send_tcp() method: +$response = $r->send_tcp($packet, $packet->data()); +// +// The response from the server will vary. If the update was successfuly, the +// server will have a response code of "NOERROR". Any other error types will +// be reported in the response packet's header "rcode" variable. +if ($ans->header->rcode != "NOERROR") { + return($ans->header->rcode); +} + +?> +]]> + </programlisting> + </example> + </refsect1> + </refentry> </sect1> <!-- Generated by phpDocumentor v 1.2.3 http://www.phpdoc.org --> <!-- Keep this comment at the end of the file