Windows 批處理設定IP地址

來源:互聯網
上載者:User

標籤:

電腦經常在實驗室機房和宿舍之間來回跑,實驗室機房用的是固定IP,宿舍使用的是Dr.com的用戶端,需要用動態IP,改來改去好麻煩的說,對於我這樣的一個懶人,當然要尋求捷徑了,批處理就是很好的選擇,下面附上批處理的代碼:

首先是設定靜態IP地址

@echo offtitle 靜態IP設定set name=本地串連(串連的名字)set IP=xxx.xxx.xxx.xxx(要設定的IP地址)
set mask=255.255.255.0(子網路遮罩)set gw=xxx.xxx.xxx.xxx(網關)set dns=xxx.xxx.xxx.xxx(DNS)set dns2=xxx.xxx.xxx.xxx(備用DNS)netsh int ip set addr name="%name%" source=static addr=%IP% mask=%mask% gateway=%gw% gwmetric=1netsh int ip set dns name="%name%" source=static addr=%dns% register=primarynetsh int ip add dns name="%name%" addr=%dns2%netsh interface ip set wins name="%name%" source=static addr=noneecho 靜態IP設定完成pause

使用的時候將xxxx改為自己的地址,將括弧中的內容Delete即可

動態IP地址設定(即將所有的地址都設定為自動擷取)

@echo offtitle 動態自動擷取IP設定set name=本地串連(串連的名字)netsh int ip set addr name="%name%" dhcpnetsh int ip set dns name="%name%" dhcpecho 動態自動擷取IP設定完成pause

 

將所有代碼儲存為*.bat,雙擊即可使用,但是需要讓360等安全軟體將其設為信任。否則彈窗//

Windows 批處理設定IP地址

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.