1.配置靜態IP和DNSspa
netsh interface ip set address name="以太網" source=static addr=192.168.9.145 mask=255.255.255.0 gateway=192.168.9.108 netsh interface ip set dns name="以太網" source=static addr=8.8.8.8 register=primary validate=no
管理員方式運行dos:code
2.配置動態IP和DNSblog
netsh interface ip set address name="以太網" source=dhcp netsh interface ip set dns name="以太網" source=dhcp
3.將命令寫成腳本文件(iP配置.bat)dns
echo 1表示修改爲靜態IP echo 2表示修改爲動態IP set /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.108 netsh interface ip set dns name="以太網" source=static addr=8.8.8.8 register=primary validate=no pause exit :: 設置動態IP :TWO netsh interface ip set address name="以太網" source=dhcp netsh interface ip set dns name="以太網" source=dhcp pause exit