Search code examples
phpdnsnslookup

Resolve hostname in PHP using different name server


How I can resolve hostname to IP address using PHP, but using different nameserver (eg. OpenDNS or Google Public DNS).

It not seem that dns_get_record() or gethostbyname() are able to use a different nameserver than one currently set up on the system (in TCP/IP settings or in /etc/resolv.conf).

The only way I've found is using PEAR class Net/DNS, but it gives me lots of warnings under PHP 5.4


Solution

  • Try net_dns2 (it's also in PEAR).