Quote: http://sean.iou.idv.tw/index.php?pl=122&ct1=3

Windows 2K/XP 修改IP,不用開啟網路撥號連線,用Netsh

每次當您要修改一個IP位址時,是不是都要開啟網路和撥號連線,再按網路設備~然後內容內容的一堆視窗…
遇到系統資源低一點的狀況,真的會慢到瘋掉 >_<
其實更改IP,是不需要這麼麻煩的
使用windows 內建的網路工具netsh便可輕鬆解決!
Netsh – Creates a shell for network information
微軟官方有一堆文件,有興趣練習英文閱讀的人可以去看看。
How to Use the NETSH Command to Change from Static IP Address to DHCP in Windows 2000( http://support.microsoft.com/?kbid=257748)
Using Netsh ( http://www.microsoft.com/technet/treeview/default.asp?url=/technet/prodtechnol/
winxppro/proddocs/netsh.asp)
Managing Windows2000 Networking Components with Netsh
( http://www.microsoft.com/technet/community/columns/cableguy/cg1101.mspx)

在這根大家介紹幾個簡單的指令
1.Show IP
1.1Cmd Mode
直接在cmd下面輸入
netsh interface ip show address
亦可簡寫為
netsh int ip sh ad
看看,指令是不是和Cisco的nos指令很像!非常懷疑是抄襲Cisco的。

1.2Netsh Mode
您也可以進入netsh的命令模式下
netsh #進入到 netsh mode
netsh>int #進入到 interface 子選項。
interface>ip #進入到 ip 子選項。
interface ip>show
show address – 顯示 IP 位址。
show config – 顯示 IP 位址及其他資訊。
show dns – 顯示 DNS 伺服器位址。
show icmp – 顯示 ICMP 統計
show interface – 顯示 IP 介面統計
show ipaddress – 顯示 IP 位址
show ipnet – 顯示 IP net-to-media 對應
show ipstats – 顯示 IP 統計
show joins – 顯示加入的多點傳送群組
show offload – 顯示 offload 資訊。
show tcpconn – 顯示 TCP 連線
show tcpstats – 顯示 TCP 統計
show udpconn – 顯示 UDP 連線
show udpstats – 顯示 UDP 統計
show wins – 顯示 WINS 伺服器位址。

2.Set IP
下列是所有可用的指令。
這個內容中的指令:
set address – 在指定的介面設定 IP 位址或預設閘道。
set dns – 設定 DNS 伺服器模式及位址。
set wins – 設定 WINS 伺服器模式及位址。

2.1.設定IP位址
2.1.1.DHCP設定
若您希望由DHCP取得IP位址可輸入
interface ip>set ad “區域連線” DHCP
或簡寫成
interface ip>set ad “區域連線” D

2.1.2.靜態IP設定
2.1.2.1.設定IP位址與子網路遮罩
netsh #進入到 netsh mode
netsh>int #進入到 interface 子選項。
interface>ip #進入到 ip 子選項。
interface ip>set address name = “區域連線” source = static addr = 10.2.2.100 mask = 255.255.255.0
可簡寫成
interface ip>set ad “區域連線” s 10.2.2.100 255.255.255.0

2.1.2.2.設定IP路由
interface ip>set address name = “區域連線” gateway = 10.2.2.254 gwmetric = 1
可簡寫成
interface ip>set ad “區域連線” ga=10.2.2.254 gw = 1

2.1.2.3同時設定IP位址和路由
interface ip>set address name = “區域連線” source = static addr = 10.2.2.100 mask = 255.255.255.0 gateway = 10.2.2.254 gwmetric = 1
可簡寫成
interface ip>set ad “區域連線” s 10.2.2.100 255.255.255.0 10.2.2.254 1

設定完後,記得用sh ad去看一下設定的對不對。

2.3設定DNS來源
若是由DHCP取得,請輸入
interface ip>set dns “區域連線” source=dhcp
若是使用靜態設定,請輸入
interface ip>set dns name = “區域連線” source = static addr = 10.2.5.2
新增第二組DNS,請輸入
interface ip>add dns name = “區域連線” addr = 10.2.5.3

2.4設定WINS來源
若是由DHCP取得,請輸入
interface ip>set wins “區域連線” source=dhcp
若是使用靜態設定,請輸入
interface ip>set wins name = “區域連線” source = static addr = 10.2.5.10
新增第二組WINS,請輸入
interface ip>add wins name = “區域連線” addr = 10.2.5.17

3.將網路狀態設定匯出/匯入
3.1匯出
netsh -c interface dump >c:
etset.txt
當然,interface可以簡寫成int,dump更可簡化成d,所以就變成了
netsh -c int d >c:
etset.txt
3.2匯入
netsh -f c:
etset.txt 既可
這個指令我覺得蠻好用的,適用在幫客戶裝機時,我們先將網路狀態設定儲存起來。將來若
發生客戶不小心變更了設定等,任何網路設定上的問題,可以執行一個批次檔,呼叫netsh
把設定取回。不然有時候,網路設定跑掉了,想用VNC連線修改都不行。

原文打包: netsh.zip

Related posts 相關文章
AWS 說 IPv4 要收費,而 Cloudflare 要你來用免費的
More...
Linux 使用 nmcli 指令新增刪除修改網卡 IP
More...
找一個網站背後的真實 IP
More...
Windows 上 SNMP 抓不到值的問題
More...

作者

留言

撰寫回覆或留言

發佈留言必須填寫的電子郵件地址不會公開。