1. 切换成自动获取IP
@echo off
netsh interface ip set address name="local" source=dhcp
netsh interface ip set dns name="local" source=dhcp
2. 切换成固定IP
@echo off
netsh interface ip set address local static 192.168.1.184 255.255.255.0 192.168.1.254
netsh interface ip set dns local 192.168.1.254
netsh interface ip add dns local 202.12.196.115 index=2
netsh interface ip add dns local 202.12.10.20 index=3
PS:
"local" 是本地网卡名称,也可能是 "本地连接"。
dns设置中,第一个是set,表示设置,后面两个则是添加,自己替换成当地的dns server。