vkGunasekaran
vkGunasekaran

Reputation: 6814

mapping domain name server ip list using any one of the name server ip

I'm able to get the nameserver ip by using this code:

$result = exec("host -t NS google.com", $outputLines);
foreach ($outputLines as $outputLine)
{
    $buffer = explode(" ", $outputLine);
    $nsList[] = $buffer[3];
}
$ipList = array_map("gethostbyname", $nsList);
print_r($ipList);

Now $ipList holds the IP list. Is there any way to get all these IP by inputting any one of the IP in $ipList.

It is like reverse process, I want to get all the IP which $ipList variable holds by inputting any one of the IP present in the $ipList variable.

Upvotes: 1

Views: 341

Answers (2)

Shane Fright
Shane Fright

Reputation: 385

If i understand correctly what you are asking which is that you want to be able to find all of the IP addresses of the nameservers in a group of nameservers (ie, NS1, NS2, NS3...) given a single nameservers IP address?

This isnt... quite easily possible, however it IS possible to do although you would have to go a LONG way around the problem to do it. You would have to hook into external services to try and get the DNS name being used by the nameserver residing on an IP address, and then try and find a group of domains that are being used by the nameserver, and then analyze the nameservers being used by those domains (crossing your fingers that you get them all) and then essentially run your existing script against them.

Maybe im wrong but i think you may be approaching whatever problem you have the wrong way, i used to work in domain management and would run into these kinds of problems all the time and unfortunately it ends being alot of DNS data aggregation and analysis work in order to solve these kinds of problems easily.

Upvotes: 1

Treffynnon
Treffynnon

Reputation: 21563

So you want to be able to find all the values in an array that match a certain IP address. This can be done with array_keys() (man page) and its optional search_value parameter.

$ip_we_are_searching_for = '192.168.0.1';
$matching_keys = array_keys($ip, $ip_we_are_searching_for);
var_dump($matching_keys);

Upvotes: 0

Related Questions