Created
September 1, 2014 22:39
-
-
Save lantins/ec5d9fdbf095a2810d88 to your computer and use it in GitHub Desktop.
Get DNS servers from root servers using dig (hack)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function get_ns_from_root($hostname) { | |
$regex_hostname = preg_quote($hostname); | |
$dig_cmd = "dig +trace {$hostname} | egrep '^{$regex_hostname}\..*IN.*NS' | awk '{ print $5 }'"; | |
exec($dig_cmd, $nameservers); | |
return $nameservers; | |
} | |
$hostname = 'buycity.info'; | |
$nameservers = get_ns_from_root($hostname)l | |
print_r($nameservers); | |
# Output: | |
# | |
# Array | |
# ( | |
# [0] => ns4.hosteceran.com. | |
# [1] => ns2.hosteceran.com. | |
# [3] => ns3.hosteceran.com. | |
# [2] => ns1.hosteceran.com. | |
# ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment