本人在网络维护与调试中常常需要修改网卡的网络参数,有时候觉得手工修改麻烦,就把一些常用的写成命令脚本来运行。
1、IP设为自动获取。
netsh interface ip set address "本地连接" dhcp
netsh interface ip set dns "本地连接" dhcp
netsh interface ip set dns "本地连接" dhcp
2、IP设为某一固定IP
netsh interface ip set address "本地连接" static 192.168.70.9 255.255.255.0 192.168.70.1 1
netsh interface ip set dns "本地连接" static 192.168.70.1
netsh interface ip set dns "本地连接" static 192.168.70.1
3、IP不变,只修改子网掩码
@echo off
REM FOR /F "usebackq tokens=1* delims=:" %%i IN (`ipconfig ^|find "IP Address"`) DO set ip=%%j
REM FOR /F "usebackq tokens=1* delims=:" %%i IN (`ipconfig ^|find "IP Address"`) DO set ip=%%j
netsh interface ip set address "本地连接" static %ip% 255.255.255.0
上面的都是可运行的,一些参数要根据实际情况修改。
转载于:https://blog.51cto.com/cdzhxu/339049