Net_DNS2 Options

nameserversarray, defaults to unset

An array of IP addresses to use as name servers. If this is unset, Net_DNS2 will default to using the /etc/resolv.conf file.

use_tcpboolean, defaults to false.

Tells Net_DNS2 to use TCP instead of UDP for queries. UDP is faster, but is limited in size. Net_DNS2 will automatically use TCP for zone transfers (AFXR) and when a response was truncated.

In the event of a truncated response, Net_DNS2 will switch to TCP, and resend the request.

dns_portint, defaults to 53.

The UDP/TCP port to use when making DNS requests.

local_hoststring, defaults to unset.

The local IP address to bind to when making outbound requests.

local_portint, defaults to unset.

The local port number to bind to when making outbound requests. local_host can be set without this setting, and the system will auto-allocate the port from the ephemeral ports.

timeoutint, defaults to 5 seconds

Timeout value to use for socket connections (in seconds)

ns_randomboolean, defaults to false

Tells Net_DNS2 to randomize the name servers list each time it’s used.

domainstring, defaults to unset

The default domain to use for unqualified host names.

cache_typestring, defaults to ‘none’

Defines the type of cache to use; either ‘none’ to disable the cache, ‘shared’ to use the shmop extension, or ‘file’ to use a flat file.

cache_filestring, defaults to ‘/tmp/net_dns2.cache’

The file to use for the cache. This is used for both the shared memory and file based cached. Net_DNS2 will need to write to this file, so it must have proper permissions.

cache_sizeint, defaults to 10000

The number of bytes Net_DNS2 is allowed to use as a cache- the bigger the better.

cache_serializer – string, defaults to ‘serialize’ (since v1.2.0)

Defines the serialization method to use when storing the cache content. Can be either ‘serialize’ to use the PHP serialize function, or ‘json’ to store the data as a JSON object.

JSON is much faster, but loses the object definition; all content becomes a stdClass object- but all the data is still accessible.

strict_query_modeboolean, defaults to false

strict_query_mode means that if the hostname that was looked up isn’t actually in the answer section of the response, Net_DNS2 will return an empty answer section, instead of an answer section that could contain CNAME records.

recurseboolean, defaults to true

if we should set the recursion desired bit to 1 or 0.

dnssecboolean, defaults to false

request DNSSEC values, by setting the DO flag to 1; this actually makes the resolver add a OPT RR to the additional section, and sets the DO flag in this RR to 1.

dnssec_ad_flagboolean, defaults to false

set the DNSSEC AD (Authentic Data) bit on/off.

dnssec_cd_flagboolean, defaults to false

set the DNSSEC CD (Checking Disabled) bit on/off

dnssec_payload_sizeinteger, defaults to 1280

the EDNS(0) UDP payload size to use when making DNSSEC requests; see RFC 2671 section 6.2.3 for more details

Example Usage

//
// pass the options directly to the constructor
//
$r = new Net_DNS2_Resolver(array(

        'nameservers'   => array('192.168.0.1', '192.168.0.2'),
        'use_tcp'       => true,
        'cache_type'    => 'shared',
        'cache_size'    => 100000
)