如何在C++中修改dns服务器?

发布于 2025-01-03 17:05:57 字数 418 浏览 1 评论 0原文

我想将所有活动适配器的主 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

眉目亦如画i 2025-01-10 17:05:57

只是为了如果有人需要这个,最后我使用 ipconfig /registerdns 来刷新注册表中的 dns 配置。

Just for if someone need this, finally I used ipconfig /registerdns to refresh dns config in registry.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文