通过批处理快速设置IP、子网掩码、网关以及DNS
来源:网络收集 点击: 时间:2024-02-29首先了解设置ip、dns命令行的用法:设置静态ip地址、子网掩码、默认网关格式:
netsh interface ip set address "网络名" static ip地址 子网掩码 默认网关
设置静态dns格式:
netsh interface ip set dns "网络名" static dns服务器地址 primary
添加辅助dns格式:
netsh interface ip add dns "网络名" dns服务器地址
2/8新建文本文档,并打开。

此处以设置网络名为“本地连接”、ip为192.168.1.100、子网掩码为255.255.255.0、网关为192.168.1.1、主dns为114.114.114.114、辅dns为8.8.8.8为例。根据netsh命令行的用法可以如此设置:
netsh interface ip set address "本地连接" static 192.168.1.100 255.255.255.0 192.168.1.1
netsh interface ip set dns "本地连接" static 114.114.114.114 primary
netsh interface ip add dns "本地连接" 8.8.8.8

将以上命令行写在记事本里,保存为名为“设置ipdns”,后缀名为“bat”的文件。

双击“设置ipdns.bat”,系统就会执行命令,自动改好了ip和dns。


如果想删除ip和dns应该怎么办呢?删除ip和dns也就是设置动态ip和dns,它的命令行为:
netsh interface ip set address name="网络名" source=dhcp
netsh interface ip set dns name="网络名" source=dhcp
7/8假如想要为网络“本地连接”设置动态的ip和dns,可以这样写:
netsh interface ip set address name="本地连接" source=dhcp
netsh interface ip set dns name="本地连接" source=dhcp

同理,保存为“设置动态ipdns.bat”文件,单击运行系统就自动改成了动态的ip和dns。


版权声明:
1、本文系转载,版权归原作者所有,旨在传递信息,不代表看本站的观点和立场。
2、本站仅提供信息发布平台,不承担相关法律责任。
3、若侵犯您的版权或隐私,请联系本站管理员删除。
4、文章链接:http://www.1haoku.cn/art_177118.html