You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Whenever I try to resolve a hostname by providing multiple nameservers, the resolution is successful in one order of nameservers, but not successful in another order of nameservers.
To Reproduce
In the script below
importdns.resolverdefresolve_hostname(hostname, dns_servers):
try:
# Resolve A record (IPv4 address)iresolver=dns.resolver.Resolver()
resolver.nameservers=dns_serversresult=resolver.resolve(hostname, 'A')
foripvalinresult:
print(f'IP Address: {ipval.to_text()}')
exceptdns.resolver.NoAnswer:
print(f'No answer found for {hostname}')
exceptdns.resolver.NXDOMAIN:
print(f'Hostname {hostname} does not exist')
exceptdns.exception.Timeout:
print(f'Request to resolve {hostname} timed out')
exceptdns.exception.DNSExceptionase:
print(f'An error occurred: {e}')
if__name__=="__main__":
hostname_to_resolve='my.host.name'print("Forward Order")
resolve_hostname(hostname_to_resolve, ["10.3.3.2", "10.3.4.5"])
print("=============================================")
print("Reverse Order")
resolve_hostname(hostname_to_resolve, ["10.3.4.5", "10.0.3.2"])
If "my.host.name" was present in "10.3.3.2" nameserver only, then the code below gives the resolved IP
The list of nameservers in the stub resolver configuration is for redundancy; it is not a search list. Resolution stops as soon as any nameserver answers the question positively or negatively. So, for example if you are querying for "my.host.name" type AAAA and the first nameserver has rcode NXDOMAIN, or has a NOERROR rcode but there is no AAAA, then those negative responses are still answers and resolution stops. Resolution would only proceed past the first nameserver if the first nameserver didn't reply, replied with something that didn't parse, or had an rcode other than NOERROR, NXDOMAIN, or YXDOMAIN.
Whenever I try to resolve a hostname by providing multiple nameservers, the resolution is successful in one order of nameservers, but not successful in another order of nameservers.
To Reproduce
In the script below
If "my.host.name" was present in "10.3.3.2" nameserver only, then the code below gives the resolved IP
but the code below where nameservers are passed in reverse order can not give the result
On digging down further,
The line above in the resolver.py is giving done=True even if the answer is empty. This is not allowing us to check the hostname in other nameservers.
Context
The text was updated successfully, but these errors were encountered: