@echo off set ::Please modify the following data according to your parameters ::set IP address set ipaddress=192.168.10.43 ::set submask set mask=255.255.254.0 ::set gateway set gateway=192.168.10.1 ::set preferred DNS server set dns1=220.189.127.106 ::Set up alternate DNS server set dns2=220.220.127.107 ::Please modify the above data according to your parameters set /p type=Please select the setting method, 1: static, 2: dynamic: if /i %type%==1 goto :STATIC_IP if /i %type%==2 goto :DHCP_IP :STATIC_IP echo Static IP setup is in progress, please wait... netsh interface ip set address name=%name% source=static addr=%ipaddress% mask=%mask% echo. IP address = %ipaddress% . complete setup echo.submask=%mask%.complete setup netsh interface ip set address name=%name% gateway=%gateway% gwmetric=1 >nul echo.gateway=%gateway%.complete setup netsh interface ip set dns name=%name% source=static addr=%dns1% register=PRIMARY >nul echo. Preferred DNS = %dns1% . Complete setup netsh interface ip add dns name=%name% addr=%dns2% index=2 >nul echo. Alternate DNS = %dns2% . Complete setup goto :SETEND :DHCP_IP echo Dynamic IP setup in progress, please wait... netsh interface ip set address name=%name% source=dhcp netsh interface ip set dns name=%name% source=dhcp register=PRIMARY netsh interface ip set wins name=%name% source=dhcp goto :SETEND :SETEND echo. ===============IP setting completed================ echo. ========================================= echo. == The following test network is normal echo. == If the following form appears: echo. == "Reply from %gateway%: bytes=32 time<1ms TTL=64" echo. == then the network is normal, otherwise the network is not normal! echo. ========================================= ping %gateway% -n 1 pause