Search code examples
c#.netnetwork-programmingwmi

How do i set the dns search suffix for a network adapter in .net?


I've written a command line utility that detects which network interface is connected, and sets the staitc ip address and dns servers for it (by calling netsh). However, I can't seem to figure out how to set the dns search suffixes. netsh doesnt appear capable of doing that. How do I do that otherwise (WMI perhaps)?


Solution

  • I think you have to set the value(s) you want in the DNSDomainSuffixSearchOrder property of the Win32_NetworkAdapterConfiguration WMI object.

    Here's and example of setting values in WMI, if you need it: Modifying Objects & Running Methods