通过批处理快速设置IP、子网掩码、网关以及DNS

 时间:2026-02-14 08:45:12

1、首先了解设置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、新建文本文档,并打开。

通过批处理快速设置IP、子网掩码、网关以及DNS

3、此处以设置网络名为“本地连接”、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

通过批处理快速设置IP、子网掩码、网关以及DNS

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

通过批处理快速设置IP、子网掩码、网关以及DNS

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

通过批处理快速设置IP、子网掩码、网关以及DNS

通过批处理快速设置IP、子网掩码、网关以及DNS

6、如果想删除ip和dns应该怎么办呢?删除ip和dns也就是设置动态ip和dns,它的命令行为:

netsh interface ip set address name="网络名" source=dhcp

netsh interface ip set dns name="网络名" source=dhcp

7、假如想要为网络“本地连接”设置动态的ip和dns,可以这样写:

netsh interface ip set address name="本地连接" source=dhcp

netsh interface ip set dns name="本地连接" source=dhcp

通过批处理快速设置IP、子网掩码、网关以及DNS

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

通过批处理快速设置IP、子网掩码、网关以及DNS

通过批处理快速设置IP、子网掩码、网关以及DNS

  • 二个二级路由怎么互通
  • win7系统中快速查看本机共享文件夹的方法?
  • 批处理中@ECHO OFF是什么意思?
  • 怎样在win10系统中查看开启了哪些端口
  • Easy UEFI如何编辑启动项
  • 热门搜索
    carrot怎么读 优信二手车怎么样 拔毒膏怎么用 产假请假条怎么写 柘怎么读 骨五笔怎么打 齐家网装修怎么样 嘴唇干燥紧绷怎么回事 小猫怎么养 面筋怎么做