GetHostByAddress .NET aliases only display 8 entries

I need to get every CNAME record from one IP address coming from our DNS server.
When I search:

[System.Net.Dns]::GetHostByAddress("81.95.243.81").Aliases 

It returns only the same 8 aliases:

 botexshop.dk bisamba.dk nordsoenoceanarium.dk www.brandingcommunity.com botexhome.dk botexudstyr.dk botexjylland.dk marineacademy.dk 

but I know that the IP address has more than 69 CNAME records (see here Toolbox | DNSstuff | Reverse DNS lookup for 81.95.243.81 )

Why GetHostByAddress only return the same 8 aliases? And how do I get all CNAME?

+2
source share
1 answer

System.Net.Dns is missing in many ways. I saw some people get to writing full-size DNS parsers to get what they need.

I know this does not fully answer your question, but this function seems to do its job, however it is rather fragile and relies on nslookup, so YMMV:

 function get-dnsaliases($ip) { $ip_rev = $ip -split '\.' [array]::reverse($ip_rev) $ip_rev = $ip_rev -join '.' $ptr_regex = "^`t" + [regex]::escape("$ip_rev.in-addr.arpa, type = PTR, class = IN") $responses = nslookup -d $ip $foundanswer = $null $aliases = @() foreach ($response in $responses) { if($foundanswer) { if($response -match "^`tname = (?<alias>.+)$") { $aliases += $Matches.alias } } elseif($response -match $ptr_regex) { $foundanswer = $true } } return $aliases } 
0
source

Source: https://habr.com/ru/post/1341871/


All Articles