1. 设置为静态IP
@echo off
SET ip=10.0.83.48
SET mask=255.255.255.0
SET gateway=10.0.83.126
SET dns=202.101.224.68
SET interface="以太网"
netsh interface ip set address %interface% static %ip% %mask% %gateway% 1
netsh interface ip set dns %interface% static %dns% register=PRIMARY validate=no
echo == 网卡属性已设置 ==
echo IP 地址   : %ip%
echo 子网掩码  : %mask%
echo 网关      : %gateway%
echo DNS       : %dns%
pause
  1. 设置为DHCP动态获取
@echo off
SET interface="以太网"
netsh interface ip set address %interface% dhcp
netsh interface ip set dns %interface% dhcp
echo == 网卡属性已设置 ==
echo IP 地址   : DHCP 自动获取
echo 子网掩码  : DHCP 自动获取
echo 网关      : DHCP 自动获取
echo DNS       : DHCP 自动获取
pause
Last modification:September 14, 2020
If you think my article is useful to you, please feel free to appreciate