1.配置静态IP和DNS
netsh interface ip set address name="以太网" source=static addr=192.168.9.145 mask=255.255.255.0 gateway=192.168.9.108netsh interface ip set dns name="以太网" source=static addr=8.8.8.8 register=primary validate=no
管理员方式运行dos:
2.配置动态IP和DNS
netsh interface ip set address name="以太网" source=dhcpnetsh interface ip set dns name="以太网" source=dhcp
3.将命令写成脚本文件(iP配置.bat)
echo 1表示修改成静态IPecho 2表示修改成动态IPset /p KEY= [您的选择是:] :: /p表示将KEY设置为输入行if %KEY% == 1 goto ONE if %KEY% == 2 goto TWO :: 设置静态IP:ONE netsh interface ip set address name="以太网" source=static addr=192.168.9.145 mask=255.255.255.0 gateway=192.168.9.108netsh interface ip set dns name="以太网" source=static addr=8.8.8.8 register=primary validate=nopauseexit:: 设置动态IP:TWOnetsh interface ip set address name="以太网" source=dhcpnetsh interface ip set dns name="以太网" source=dhcppauseexit