win10配置的静态/动态IP和 DNS的方法

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.108
netsh 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=dhcp
netsh interface ip set dns name="以太网" source=dhcp

 

3.将命令写成脚本文件(iP配置.bat)

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

 

posted on 2018-10-12 09:53  小明在线  阅读(3049)  评论(0编辑  收藏  举报

导航