windows 設定指令碼IP

來源:互聯網
上載者:User

標籤:

    毫無疑問,在windows設定IP非常方便,因為有操作簡單,直觀的介面。通過圖形化使用者介面設定IP在一般情況下是足夠。但是,對於那些誰經常出差,由人產生的轉換工作,這樣的變化IP無疑耗時且不方便。假設一套IP在指令檔中的命令來運行,便迅速。

用命令列設定IP步驟(WIN7,針對IPV4設定):

1、設定一個靜態IP

netsh interface ipv4 set address name="本地串連" source=static addr=192.168.20.11 mask=255.255.255.0 gataway=192.168.20.1 gwmetric=30

黑色字型的網關設定部分可有可無。

2、設定多個IP,注意紅色部分指令的差別

netsh interface ipv4 set address name="本地串連" source=static addr=192.168.20.11 mask=255.255.255.0 gataway=192.168.20.1gwmetric=30
netsh interface ipv4 add address name="本地串連" addr=192.168.1.11 mask=255.255.255.0 gwmetric=30
這個命令設定了192.168.20.11,192.168.1.11兩個IP

3、設定自己主動擷取IP

netsh interface ipv4 set address name="本地串連" source=dhcp

4、設定網域名稱
netsh interface ipv4 set dns name="本地串連" source=static addr=202.106.0.20 register=PRIMARY

addr為網域名稱server地址,PRIMARY指主網域名稱


完整範例:

A、辦公室區域網路使用beijing-office.bat

netsh interface ipv4 set address name="本地串連" source=static addr=192.168.20.11 mask=255.255.255.0 gwmetric=30
netsh interface ipv4 add address name="本地串連" addr=192.168.1.11 mask=255.255.255.0 gwmetric=30
REM netsh interface ipv4 set dns name="本地串連" source=static addr=202.106.0.20 register=PRIMARY


B、賓館上網用,適用於自己主動擷取IP的設定,beijing-hotal.bat

netsh interface ipv4 set address name="本地串連" source=dhcp
netsh interface ipv4 set dns name="本地串連" source=static addr=202.106.0.20 register=PRIMARY
netsh interface ipv4 add dns name="本地串連" addr=202.106.46.151


建立這兩個指令檔後,在不同的環境僅僅要在其上運行相應的指令檔,非常方便。


著作權聲明:本文部落格原創文章,部落格,未經同意,不得轉載。

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.