如何在Windows中以编程方式更改DNS服务器? [英] How to Change DNS Servers Programmatically in Windows?

查看:120
本文介绍了如何在Windows中以编程方式更改DNS服务器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想以编程方式更改DNS服务器。我不想建立DNS服务器,只想自动更改主要和辅助dns服务器。这项工作需要在Python中完成。

I want to change DNS servers programmatically. I don't want to build a DNS server, I just want to change the primary and secondary dns servers automatically. This work needs to be done in Python.

推荐答案

您可以使用os.system调用命令行工具为您完成此工作

You can call a command line tool to do it for you with os.system.

import os
os.system('netsh interface ip set dns "Local Area Connection" static 192.168.0.200')

这篇关于如何在Windows中以编程方式更改DNS服务器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆