批处理-配置网卡

家住魔仙堡 提交于 2019-12-26 12:26:26

固定IP

@echo off
REM 声明采用UTF-8编码
chcp 65001

REM netsh interface ip show interfaces
REM ipconfig/all

set Nic=以太网
REM set /p Nic=输入网卡名称:
set Addr=192.168.1.1 
set Mask=255.255.255.0 
set Gway=192.168.1.0 
REM set Dns1=10.15.0.1 
REM set Dns2=10.100.1.2 
REM set Wins1=10.15.0.1 
REM set Wins2=10.100.1.2 
echo ------------------------------------------------------ 
echo 正在进行IP设置,请稍等 
echo. IP地址 = %Addr% 
echo. 子网掩码 = %Mask% 
echo. 默认网关 = %Gway% 
netsh interface ipv4 set address name=%Nic% source=static addr=%Addr% mask=%Mask% gateway=%Gway% gwmetric=0 
rem echo. 首选DNS = %Dns1% 
rem netsh interface ip set dns name=%Nic% source=static addr=%Dns1% register=PRIMARY >nul 
rem echo. 备用DNS = %Dns2% 
rem netsh interface ip add dns name=%Nic% addr=%Dns2% index=2 >nul 
rem echo. 首选WINS = %Wins1% 
rem netsh interface ip set wins name=%Nic% source=static addr=%Wins1% register=PRIMARY >nul 
rem echo. 备用WINS = %Wins2% 
rem netsh interface ip add wins name=%Nic% addr=%Wins2% index=2 >nul 
echo ------------------------------------------------------ 
echo IP设置完成! 

pause

自动获取IP

@echo off
REM 声明采用UTF-8编码
chcp 65001

netsh interface ipv4 set address name="以太网" source=dhcp
netsh interface ipv4 set dnsservers name="以太网" source=dhcp

pause
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!