差異處
這裏顯示兩個版本的差異處。
兩邊的前次修訂版前次修改 | |||
microsoft:netsh_ip [2012/11/05 10:50] – jal | microsoft:netsh_ip [2012/11/16 09:09] (目前版本) – jal | ||
---|---|---|---|
行 1: | 行 1: | ||
+ | ====== Windows 使用指令修改 IP ====== | ||
+ | 本篇使用的為從 Windows 2000 起即內建之指令,適用於 Windows Server 2000, Windows XP, Windows Server 2003, Windows Vista, Windows 7, 包含 IPv4 及 IPv6 之指令修改 IP 及指定靜態路由的方式 | ||
+ | ===== 說明 ===== | ||
+ | 以下 " | ||
+ | |||
+ | ===== IPv4 Fixed ===== | ||
+ | * IPv4 固定 IP 設定 | ||
+ | * IP: 192.168.1.1, | ||
+ | * <file bat ipv4.bat> | ||
+ | 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 " | ||
+ | netsh interface ip set dns " | ||
+ | echo 已將IP地址設為:%IP%,按任一鍵後繼續…… | ||
+ | pause | ||
+ | </ | ||
+ | |||
+ | ===== IPv4 DHCP ===== | ||
+ | * 將 IP 及 DNS 轉為 DHCP 自動取得 | ||
+ | * <file bat ipv4_dhcp.bat> | ||
+ | echo | ||
+ | netsh interface IP Set Address " | ||
+ | netsh interface IP Set dns " | ||
+ | echo 已將IP地址由靜態切換成動態,按任一鍵結束,…… | ||
+ | pause | ||
+ | </ | ||
+ | |||
+ | ===== IPv4 Static Route ===== | ||
+ | * 指定二筆靜態路由,不指定介面卡 | ||
+ | * <file bat ipv4_static_route.bat> | ||
+ | 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 | ||
+ | </ | ||
+ | |||
+ | ===== IPv6 fixed ===== | ||
+ | * IPv6 固定 IP 設定 | ||
+ | * 本指令僅適用於 Windows XP Service Pack 2 以上 | ||
+ | * Windows XP 要啟用 IPv6 需於命令提示字元輸入 netsh interface ipv6 install 進行啟用,以上的版本不需要 | ||
+ | * 由於 Windows 系列僅接受 64 之遮罩長度(Sub Netmask) | ||
+ | * IP: 2001: | ||
+ | * <file bat ipv6_XP.bat> | ||
+ | echo | ||
+ | netsh interface ipv6 set address " | ||
+ | netsh interface ipv6 set route ::/0 " | ||
+ | netsh interface ipv6 set dns " | ||
+ | echo 已將IPv6地址設為:2001: | ||
+ | pause | ||
+ | </ | ||
+ | * <file bat ipv6_win7.bat> | ||
+ | echo | ||
+ | netsh interface ipv6 add address " | ||
+ | netsh interface ipv6 add route ::/0 " | ||
+ | netsh interface ipv6 set dnsservers " | ||
+ | echo 已將IPv6地址設為:2001: | ||
+ | pause | ||
+ | </ |