批处理解决换ip问题

mac2026-09-29  3

netsh interface ip set address "网卡名字" static ip地址 子网掩码 默认网关 netsh interface ip set dns "网卡名字" source=static addr=默认dns netsh interface ip add dns "网卡名字" addr= 备用dns

例如:

netsh interface ip set address "以太网" static 10.18.110.136 255.255.255.0 10.18.110.254 netsh interface ip set dns "以太网" source=static addr=10.19.240.240 netsh interface ip add dns "以太网" addr= 10.19.240.241  

自动获取ip地址和dns地址

netsh interface ip set address "以太网" source=dhcp netsh interface ip set dns "以太网" source=dhcp

 

PS:1.编码要保存为ANSI,否则网卡名字为中文名,会有乱码

         2.bat以管理员身份运行

 

最新回复(0)