How to Change DNS Servers Programmatically in Windows?

前端 未结 2 1512
一个人的身影
一个人的身影 2020-12-17 05:54

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 need

2条回答
  •  悲哀的现实
    2020-12-17 06:31

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

提交回复
热议问题