2

Does anyone know how to get a list of DNS search suffixes on a client - both ones that have been manually added and ones assigned by DHCP. I'd prefer to have a cross-platform solution, but a Windows only solution will work. I couldn't find anything in pywin32 or other modules...

1
  • 2
    Please elaborate your problem and code of anything you already tried. Jan 23, 2014 at 20:29

1 Answer 1

2

After a bit of investigation, it doesn't look like there is a cross-platform way since the OS stores this information differently. On Windows, I ended up querying the information via the registry:

def getLocalDomainSuffix():
    domainSuffixSet = set()
    netKey = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, 'SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters')
    for keyName in ("DhcpDomain", "SearchList"):    
        value, type = _winreg.QueryValueEx(netKey, keyName)
        if value:
            for item in value.split(','):
                domainSuffixSet.add(item)
    return domainSuffixSet

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.