0

I am trying to develop a python script using dnspython to do forward lookups by hostname only instead of FQDN. This obviously has a dependency on DHCP Option 15(connection specific DNS Suffix). When I do:

from dns import resolver

servs = resolver.Resolver()
print(servs.nameservers)

I see a DNS resolver that is not a part of the list of DNS servers in ipconfig /all. This DNS server sometimes causes issues because sometimes this is the first DNS server that dnspython uses for lookups. How can I find out where this DNS server is coming from and how can I get rid of it?

UPDATE

I just ran Get-DnsClientServerAddress in power shell and that rouge DNS server does not show up as a known DNS server for any of my interfaces

adamz88
  • 319
  • 3
  • 12
  • DNS servers are not necessarily coming from DHCP. They can be hardcoded in your OS as well. You need, in Windows, to look into the properties of your connection to find them. You can as well have some applications, like a VPN, that will change them so differences can come from there as well. – Patrick Mevzek Feb 20 '20 at 15:31
  • @PatrickMevzek, I already checked all of those things. Also, please see update – adamz88 Feb 20 '20 at 15:46
  • Based on DNSPython source code, it searches in the following registry keys: `SYSTEM\CurrentControlSet\Services\Tcpip\Parameters`, `SYSTEM\CurrentControlSet\Services\VxD\MSTCP`. – Patrick Mevzek Feb 20 '20 at 15:53
  • Also, for the time being a trivial workaround: just specify yourself in your Python code which nameservers you want to use, bypassing OS configured ones. – Patrick Mevzek Feb 20 '20 at 15:54

0 Answers0