如何在C++中修改dns服务器?
我想将所有活动适配器的主 DNS 服务器更改为某个 IP(例如 8.8.8.8)。
我尝试修改注册表,对于HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters
下的所有接口,将NameServer
更改为我想要的。
然而它不起作用。 ipconfig /all
显示 dns 已更改,但系统似乎并未应用该更改。如果我打开TCP/IPv4
的属性,dns已经改变了,然后我点击OK
,到现在dns已经投入使用了。
有人可以告诉我如何解决这个问题吗?除了注册之外,您还可以通过其他方式进行操作。
更新:大约 6~8 分钟后,我所做的最终将应用。
I want to change the primary dns server to some ip(e.g. 8.8.8.8), for all active adapters.
I tried to modify the registry, for all interfaces under HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters
, the NameServer
is changed to what i want.
However it doesn't work. ipconfig /all
shows that the dns is changed, however the system seems didn't apply that. If I open the attribute of TCP/IPv4
, the dns is already changed, then i click OK
, until now the dns is put into use.
Could someone tell me how to solve this? you may go some other ways, besides registry.
Update: what i did will finally apply, after about 6~8 mins.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只是为了如果有人需要这个,最后我使用 ipconfig /registerdns 来刷新注册表中的 dns 配置。
Just for if someone need this, finally I used
ipconfig /registerdns
to refresh dns config in registry.