Windows 批处理 bat 设置固定ip 多个ip与自动ip切换
发表于:2022-11-14 |
批处理1:设置固定ip以及设置多个固定ip;

@echo off
cls
color 0A
Echo *******************************************************************************
Echo IP address and DNS server address are being modified, please wait patiently…
Echo *******************************************************************************
cmd /c netsh interface ip set address name="WLAN" source=static addr=192.168.1.115 mask=255.255.255.0 gateway=192.168.1.1 gwmetric=1
cmd /c netsh interface ip add address "WLAN" 192.168.12.5 255.255.255.0 192.168.12.1
cmd /c netsh interface ip set dns name="WLAN" source=static addr=114.114.114.114  validate=no
cmd /c netsh interface ip add dns name="WLAN" addr=8.8.8.8 index=2 validate=no
ipconfig /all
Echo *******************************************************************************
Echo OK!! Successful revision! Please press any key to continue…
Thank you for your use! Cloud Xiaofei Production
Echo *******************************************************************************
Pause

name为网络链接名称。

第一个cmd行:设置第一个IP。addr为ip,mask为子网掩码,gateway为网关;

第二个cmd行:添加第二个IP,可以不添加。依次为IP、子网掩码、网关;

第三个cmd行:设置第一个DNS,常用DNS:http://blog.itpub.net/26736162/viewspace-2706880/;

第四个cmd行:设置备用DNS。index=2代表备用。


批处理2:设置IP为自动获取,dns自动获取:


@echo off
cls
color 0A
Echo *******************************************************************************
Echo) IP address and DNS server address are being modified, please wait patiently…
Echo *******************************************************************************


netsh interface ip set address name="WLAN" dhcp

netsh interface ip set dns name="WLAN" dhcp 
ipconfig /flushdns
ipconfig /all
Echo *******************************************************************************
Echo OK!! Successful revision! Please press any key to continue…
Thank you for your use! Cloud Xiaofei Production
Echo *******************************************************************************
Pause
上一篇:
常用DNS地址
下一篇:
ubuntu 内网搭建服务器的一些配置,完美解决https、http、curl、wget、yum 无法访问的问题