命令:netsh interface ip
1.查看幫助信息
C:/>netsh interface ip /?
下列指令有效:
此上下文中的命令:
? - 顯示命令列表。
add - 向表中添加一個配置項目。
delete - 從表中刪除一個配置項目。
dump - 顯示一個配置腳本。
help - 顯示命令列表。
reset - 復位 TCP/IP 及相關的組件到干凈的狀態。
set - 設置配置信息。
show - 顯示信息。
2.導出當前配置腳本
C:/>netsh interface ip dump >interface.txt
3.配置IP信息
3.1 添加IP配置信息(add address)
(1)查看幫助信息
netsh interface ip>add address /?
用法: add address [name=]<string> [[addr=]IP address [mask=]IP subnet mask]
[[gateway=]IP address [gwmetric=]integer]
(2)添加IP、mask、gateway信息
netsh interface ip>add address name="本地連接" addr=192.168.1.123 mask=255.255.2
55.0 gateway=192.168.1.254 gwmetric=1
3.2修改IP配置信息(set address)
(1)查看幫助信息
netsh interface ip>set address /?
用法: set address [name=]<string>
[[source=]dhcp |
[source=] static [addr=]IP address [mask=]IP subnet mask]
[[gateway=]<IP address>|none [gwmetric=]integer]
(2)靜態設置IP
完整命令:
①netsh interface ip>set address name="本地連接" source=static addr=211.67.17.120
mask=255.255.255.0 gateway=211.67.17.254 gwmetric=1
當然,name=、source=、addr=、mask=、gateway=、gwmetric= 可以省略,寫成如下形式(必須按照順序)
②netsh interface ip>set address "本地連接" static 211.67.17.120 255.255.255.0 211
.67.17.254 1
也可以寫成如下形式:
③netsh interface ip>set address "本地連接" static 211.67.17.120 255.255.255.0
④netsh interface ip>set address name="本地連接" source=static addr=211.67.17.123
mask=255.255.255.0
⑤netsh interface ip>set address "本地連接" static gateway=211.67.17.254 gwmetric=1
其中,③④是等價的,⑤必須寫上gateway=、 gwmetric=之類的
建議:最好將“name=、source=、addr=、mask=、gateway=、gwmetric=”等都寫上,這樣一目了然,不容易出錯。
(3)動態設置IP
netsh interface ip>set address name="本地連接" source=dhcp
3.3刪除IP配置信息(delete address)
(1)查看幫助信息
netsh interface ip>delete address /?
用法: delete address [name=]<string> [[addr=]IP address] [[gateway=]IP address|ALL]
(2) 刪除網關信息
netsh interface ip>delete address name="本地連接" gateway=192.168.1.254
注:沒有使用 DHCP 的界面必須有一個或多個靜態 IP 地址。
4.配置DNS信息
4.1添加DNS(add dns)
(1)查看幫助信息
netsh interface ip>add dns
用法: add dns [name=]<string> [addr=]<IP address> [[index=]<integer>]
(2)添加DNS
①netsh interface ip>add dns name="本地連接" addr=202.114.0.242
②netsh interface ip>add dns name="本地連接" addr=202.114.0.242 index=1
若還未設置DNS,①②功能是一樣的,都是將202.114.0.242設為首選DNS服務器
③設置輔助DNS服務器
netsh interface ip>add dns name="本地連接" addr=202.112.30.131 index=2
注:默認情況下,新添加的DNS 服務器被添加在列表的結尾
4.2設置DNS(set dns)
(1)查看幫助信息
netsh interface ip>set dns /?
用法: set dns [name=]<string> [source=]dhcp|static [addr=]<IP address>|none
[[register=]none|primary|both]
(2)設置DNS
netsh interface ip>set dns name="本地連接" source=static addr=202.114.0.242 register=primary
4.3刪除DNS(delete dns)
(1) 查看幫助信息
netsh interface ip>delete dns /?
用法: delete dns [name=]<string> [[addr=]<IP address>|ALL ]
(2)刪除DNS
①刪除指定DNS
netsh interface ip>delete dns name="本地連接" addr=202.114.0.242
注:若刪除首選DNS,則原先輔助DNS變為當前首選DNS
②刪除所有DNS:netsh interface ip>delete dns name="本地連接" addr=all
綁定到某IP: httpcfg set iplisten -i 192.168.0.1 查看綁定IP: httpcfg query iplisten 刪除綁定IP: httpcfg delete iplisten -i 192.168.0.1
可是windows server 2012沒有httpcfg該怎么辦呢,還真被我想到辦法了,廢話不多說直接入正題,因為我想睡覺了:
先是CMD下輸入下列命令,然后回車
netsh http show iplisten
果然ECS遷移之前的IP存在這個偵聽列表中。那么簡單了,用下面這個命令刪除
netsh http delete iplisten ipaddress=遷移前的IP