I use dnspython to query a DNS server to resolve a domain name to its IP(s).
When I try to resolve "google.co.uk" I get only one IP. However, using another resolver tool I get another IP. Both IPs are correct and I tested them by placing the IPs in the browser, both open "google.co.uk".
Clearly there are more than IP asssigned for the domain name I am testing. Is there any way I can use in dnspython to retrieve all IPs for a given domain name?
Here is my simple script:
import dns.resolver
def resolve(domain):
resolveList = []
resolver = dns.resolver.Resolver(); #create a new instance named Resolver
answer = resolver.query(domain,"A");
y=0
for rData in answer:
resolveList.append(rData)
++y
return resolveList
domainName = "google.co.uk"
queryResult = resolve(domainName);
for result in queryResult:
print queryResult[0]
In the general case, no, there is no way to know when you have exhaustively enumerated all IP addresses in active use for a particular host name. Google is a good example; depending on your location in the world and their current load, they will return some, but not all, of their addresses, for load-balancing and similar purposes.