I'm using dnspython to conduct DNS queries. Since my machine is joined to my company's domain, the corporate domain is part of my search domains. However, I NEVER
want that domain to be appended when I am doing forward lookups on hostnames.
An approach that I've taken to remove unwanted nameservers by value is the following:
import dns.resolver
my_resolver = dns.resolver.Resolver()
my_resolver.nameservers.remove('172.20.10.1')
Unfortunately, I cannot take the same approach( or I don't know how) with for my_resolver.search
because its elements are <class 'dns.name.Name'>
instances and not strings.
Since my corporate domain seems to be the last element in my_resolver.search
I remove it like so: del my_resolver.search[-1]
. But I want to remove it by value, how can I do so, preferably without iterating through my_resolver.search
.