0

I'm working on creating a new type of email protocol, and in order to do that I had to set up an SRV DNS record for my domain.

In promoting this protocol, I'll need to be able to discover if a given host uses my system (and if not fall back to an older protocol).

So, is there a way to pull a DNS record (such as SRV) using PHP without using a PECL extension or running it through the linux command line (I already know I can ob_start() and system("host -t SRV hostname") but I'm looking for a better way, if it exists.)

Navarr
  • 3,703
  • 7
  • 33
  • 57
  • This was asked before here http://stackoverflow.com/questions/313880/srv-record-lookup-with-php – Mark May 25 '10 at 20:25

2 Answers2

1

Use dns_get_record

array dns_get_record  (  string $hostname  [,  int $type = DNS_ANY  [,  array &$authns  [,  array &$addtl  ]]] )

Fetch DNS Resource Records associated with the given hostname.

nc3b
  • 15,562
  • 5
  • 51
  • 63
  • Thats only for getting an IP address, not returning DNS records. – Navarr May 25 '10 at 18:57
  • Thanks, I noticed that function when I went to the function page for gethostbyname, lol. Its a new function. You've been a great help. – Navarr May 25 '10 at 19:00
0

Have you considered PEAR::Net_DNS?
http://pear.php.net/package/Net_DNS

As far as I can tell it uses socket connections (tcp/udp) and decodes the resolver data itself. The available methods look pretty extensive.

mario
  • 144,265
  • 20
  • 237
  • 291
  • When I said without PECL I also meant without PEAR. I'm on shared hosting so its kind of a pain to set either up. – Navarr May 27 '10 at 10:32
  • You can download PEAR classes individually. There's no need for server-wide installation through pecl or pear. It's actually quite common to use extracted PEAR classes project-locally. This one in particular is dependency-free. – mario May 27 '10 at 11:22