How to add a new host with Net_DNS

From: Date: Fri, 08 Oct 2004 08:11:10 +0000
Subject: How to add a new host with Net_DNS
Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-33700@lists.php.net to get a copy of this message
Hi, am trying to add a new host to a zone file using Net_DNS but I get this error: NOTZONE, which means am trying to do an update to an existing entry, what is the correct way to add a new host. Kind regards Thulani require_once("Net/DNS.php"); function DNS_ADD_NEW ($domain, $newrec, $nameserver, $key, $key_name) { $r = new Net_DNS_Resolver(); $r->nameservers = array($nameserver); $packet = new Net_DNS_Packet(); $packet->header = new Net_DNS_Header(); $packet->header->id = $r->nextid(); $packet->header->qr = 0; $packet->header->opcode = "UPDATE"; $packet->question[0] = new Net_DNS_Question($domain, "SOA", "IN"); $packet->answer = array(); $ADDrr = new Net_DNS_RR($newrec); $packet->authority[0] = $ADDrr; $tsig = new Net_DNS_RR("$key_name TSIG $key"); $packet->additional = array($tsig); $packet->header->qdcount = count($packet->question); $packet->header->ancount = count($packet->answer); $packet->header->nscount = count($packet->authority); $packet->header->arcount = count($packet->additional); $ans = $r->send_tcp($packet, $packet->data()); if ($ans->header->rcode != "NOERROR") { echo "Error: " . $ans->header->rcode . "\n"; echo "<BR><a href=''>Home</a>"; } else { echo "<BR>Resource Record Added: " . $ADDrr->string(); echo "<BR><a href=''>Home</a>"; } }

« previous php.pear.dev (#33700) next »