What is a DNS server?

What is the best way to query the authoritative DNS server for a domain in PHP?

  • I want to verify that recently changed DNS settings are correct and want to avoid getting incorrect cached values from other DNS servers.

  • Answer:

    One approach might be executing something from the command line and parsing the output to see if it's what is expected. Something like this would be a good start: $results = `/usr/bin/dig @http://ns.example.com sub.example.com`; You might need to poke around in the man pages for dig to get exactly what you need, or another utility might work best, but this should get you pretty close.

John David Anderson at Quora Visit the source

Was this solution helpful to you?

Other answers

If you want to query the full "chain" (first the root nameservers, than the TLD nameservers etc), without using any caching, than use dig +trace http://sub.example.com The "trace" option will do exactly that.

Frank Louwers

You might be better off to use one of the existing tools on the net. Try the service of the Swedish ccTLD registry http://dnscheck.iis.se/?time=undefined&id=undefined&test=standard&view=basic&setLanguage=en

Ulrich Wisser

If you want to see what your name servers will return when queried for a specific domain you should query the name servers directly. If you are using Linux or OS X I recommend using dig:Example:digĀ  {yourdomain.com} @{yournaemserver}If you are using a Windowns based system you can use nslookupExample:nslookup {http://yourdomain.com.} {yournaemserver}Include the dot at the end of your domain or nslookup will append your local resolver's domain name to the end of your domain.

JR Frazier

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.