win 7下切換IP腳本

轉自:http://www.xp74.com/article/news/62.htm


 

xp系統下載教你Win7/Vista/XP下兩個切換IP地址的批處理腳本

從辦公到家庭環境,或者從會議室到辦公工位上的IP切換相信已經把你搞的煩死了,那麼用下面的2個小腳本吧,呵呵,藥到病除。

這個腳本適合Windows XP、Vista、Windows7、Win2003-2008等系統。

軟媒特別在此提醒的是,用記事本保存成文件,用 .bat 或者 .cmd 結尾即可,系統會識別成批處理文件,具體的名字你自己定就行了。

下面是兩個批處理的具體腳本,大家根據自己的情況改下,例如有些朋友會習慣用 192.168.1.xxx 這種IP。

一、切換成自動獲取IP

/////// 把下面幾行用記事本保存成 AutoIP.bat 或 ZidongIP.cmd 等文件,不含本行,以後雙擊這個bat或者cmd文件執行即可 ///////

  @echo off

  netsh interface ip set address name="local" source=dhcp

  netsh interface ip set dns name="local" source=dhcp

/////// 把上面幾行用記事本保存成 AutoIP.bat 或 ZidongIP.cmd 等文件,不含本行,以後雙擊這個bat或者cmd文件執行即可 ///////

二、切換成固定IP

/////// 把下面幾行用記事本保存成 myIP.bat 或 myIP.cmd 等文件,不含本行,以後雙擊這個bat或者cmd文件執行即可 ///////

  @echo off

  netsh interface ip set address local static 192.168.0.84 255.255.255.0 192.168.0.254

  netsh interface ip set dns local 192.168.0.254

  netsh interface ip add dns local 202.106.196.115 index=2

  netsh interface ip add dns local 202.106.0.20 index=3

/////// 把上面幾行用記事本保存成 myIP.bat 或 myIP.cmd 等文件,不含本行,以後雙擊這個bat或者cmd文件執行即可 ///////

  注意:"local" 是你的本地網卡名稱,也可能是 "本地連接",需要自己替換下。如果是2個固定IP間的來回切換,把第2個腳本自己改改吧 :)

  dns設置中,第一個是set,表示設置,後面兩個則是添加,自己替換成當地的dns server。

從上面能看出來,netsh 命令還是很強的吧,運行下幫助就能看到更多用法了——

 

 

我的應用實例:

 

   @echo off

  netsh interface ip set address 網卡-1 static 10.63.57.14 255.255.255.0 10.63.57.251

  netsh interface ip set dns local 10.65.1.1

  netsh interface ip add dns local 8.8.8.8 index=2

  netsh interface ip add dns local 0.0.0.0 index=3

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章