如何在.net中为网络适配器设置dns搜索后缀?

时间:2021-05-15 03:21:28

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)?

我编写了一个命令行实用程序,用于检测连接的网络接口,并为其设置staitc ip地址和dns服务器(通过调用netsh)。但是,我似乎无法弄清楚如何设置DNS搜索后缀。 netsh似乎无法做到这一点。我怎么办呢(或许是WMI)?

1 个解决方案

#1


2  

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

我认为您必须在Win32_NetworkAdapterConfiguration WMI对象的DNSDomainSuffixSearchOrder属性中设置所需的值。

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

如果需要,可以在WMI中设置值的示例和示例:修改对象和运行方法

#1


2  

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

我认为您必须在Win32_NetworkAdapterConfiguration WMI对象的DNSDomainSuffixSearchOrder属性中设置所需的值。

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

如果需要,可以在WMI中设置值的示例和示例:修改对象和运行方法