IP地址DHCP与STATIC切换批处理脚本
@echo off set ::请根据您的参数修改以下数据 ::设置 IP地址 set ipaddress=192.168.10.43 ::设置 子掩码 set mask=255.255.254.0 ::设置 网关 set gateway=192.168.10.1 ::设置 首选DNS服务器 set dns1=220.189.127.106 ::设置 备用DNS服务器 set dns2=220.220.127.107 ::请根据您的参数修改以上数据 set /p type=请选择设置方式,1: 静态,2: 动态: if /i %type%==1 goto :STATIC_IP if /i %type%==2 goto :DHCP_IP :STATIC_IP echo 正在进行静态IP设置,请稍等... netsh interface ip set address name=%name% source=static addr=%ipaddress% mask=%mask% echo. IP地址 = %ipaddress% .完成设置 echo. 子掩码 = %mask% .完成设置 netsh interface ip set address name=%name% gateway=%gateway% gwmetric=1 >nul echo. 网关 = %gateway% .完成设置 netsh interface ip set dns name=%name% source=static addr=%dns1% register=PRIMARY >nul echo. 首选DNS = %dns1% .完成设置 netsh interface ip add dns name=%name% addr=%dns2% index=2 >nul echo. 备用DNS = %dns2% .完成设置 goto :SETEND :DHCP_IP echo 正在进行动态IP设置,请稍等... netsh interface ip set address name=%name% source=dhcp netsh interface ip set dns name=%name% source=dhcp register=PRIMARY netsh interface ip set wins name=%name% source=dhcp goto :SETEND :SETEND echo. ===============IP设置完成================ echo. ========================================= echo. == 以下测试网络是否正常 echo. == 若出现如下形式: echo. == "Reply from %gateway%: bytes=32 time<1ms TTL=64" echo. == 则网络正常,否则网络不正常! echo. ========================================= ping %gateway% -n 1 pause
相关推荐
diediexiaomi 2020-08-11
thlm0 2020-06-08
wq0 2020-05-25
服务器端攻城师 2020-04-14
tianchaoshangguo 2020-02-19
HHLee 2020-02-17
huangzonggui 2020-02-16
xuezhengyyy 2020-02-15
xcznb 2020-02-13
vanturman 2020-01-23
leodengzx 2020-01-06
xinlugang 2019-12-31
piaotiejun 2019-12-15
huangzonggui 2019-12-14
huangzonggui 2019-12-06
sapliang 2019-12-06
leodengzx 2019-12-07