August 25, 2015

Dig/DNS Record Fetching With PHP

I’ve started a new job recently as a Linux Systems Administrator for Webanywhere Ltd. A major part of my new role is automation, so there may be a fair few posts regarding automation of Linux server tasks coming soon.

I’m currently transferring thousands of domains between two different providers and to aid things I’ve had to create a script to get certain DNS records via the ‘dig’ command, I know PHP fairly well so it was easier to write a script in that to speed up the process. In it’s current form it will show the IP for the record type chosen, it’s pretty easy to modify to do other things, drop me a comment below if you need anything specific and you’re stuck.


*UPDATE* 09/09/15

I’ve since fleshed this out massively and it can be found at Github @, it will continue to be updated with extra options in the future.

There’s also a demo at if you wish to try it.

1 Comment

  • Hi,

    My i need help using the dig function, i am starting out a domain registar service, and i needto check if a domain is already registered, i have been provided with the following dig function, but i am having problems putting it together in php, here is the code: dig +noall +answer +authority NS . How to i put this together

Leave a Reply

Your email address will not be published. Required fields are marked *