c++winapidnswinsock2

How to retreive IP interface DNS suffixes using winsock2?


In Windows, for a interface, you can set DNS suffixes to add to queries.

Windows dialog Advanced TCP/IP Settings

How do one retrieve the settings dom1.com, dom2.com using winsock2?

If I call GetAdapterAddresses the IP_ADAPTER_ADDRESSES_LH gets filled. The DnsSuffix member gets filled with "DNS suffix for this connection" (dom1.com here). But dom2.com is not present in the data.

I would have thought the linked-list member FirstDnsSuffix should list both suffixes, but that is always NULL.

Anyone knows?


Solution

  • The DNS Suffix search list that you want is a global setting, which is why GetAdaptersAddresses() does not report it on a per-adapter basis. The list is stored in the Registry in the following key:

    HKLM\System\CurrentControlSet\Services\Tcpip\Parameters

    In the SearchList (REG_SZ) value.

    Alternatively, you can get the list from the DNSDomainSuffixSearchOrder property of the WMI Win32_NetworkAdapterConfiguration class.