本篇使用的為從 Windows 2000 起即內建之指令,適用於 Windows Server 2000, Windows XP, Windows Server 2003, Windows Vista, Windows 7, 包含 IPv4 及 IPv6 之指令修改 IP 及指定靜態路由的方式
以下 “區域連線” 請自行改為你要變動的名稱,他有可能是 “區域連線 2” 或是 “區域連線 1” 之類的。
set IP=192.168.1.1 set MASK=255.255.255.0 set GW=192.168.1.254 set DNS=8.8.8.8 echo netsh interface ip set address "區域連線" static %IP% %MASK% %GW% netsh interface ip set dns "區域連線" static %DNS% echo 已將IP地址設為:%IP%,按任一鍵後繼續…… pause
echo netsh interface IP Set Address "區域連線" DHCP netsh interface IP Set dns "區域連線" DHCP echo 已將IP地址由靜態切換成動態,按任一鍵結束,…… pause
echo route add 10.0.0.0 mask 255.0.0.0 192.168.1.2 route add 172.31.0.0 mask 255.255.255.0 192.168.1.4 pause
echo netsh interface ipv6 set address "區域連線" 2001:288:1011:97:31fb::2111 netsh interface ipv6 set route ::/0 "區域連線" 2001:288:1011:97:31fb::1 netsh interface ipv6 set dns "區域連線" 2001:4860:4860::8888 echo 已將IPv6地址設為:2001:288:1011:97::1xxx,按任一鍵後繼續…… pause
echo netsh interface ipv6 add address "區域連線" 2001:288:1011:97:31fb::2111 netsh interface ipv6 add route ::/0 "區域連線" 2001:288:1011:97:31fb::1 netsh interface ipv6 set dnsservers "區域連線" static 2001:4860:4860::8888 primary echo 已將IPv6地址設為:2001:288:1011:97::1xxx,按任一鍵後繼續…… pause