2023年11月21日 星期二

在windows 設定多個IP

 

因為Windows 11 22H2 112/‎1/‎21 22621.2715找不到以前可以設定多個IP,所以使用Command line的方式增加IP設定,使用"netsh"

使用方式: netsh [-a AliasFile] [-c Context] [-r RemoteMachine] [-u [DomainName\]UserName] [-p Password | *]
             [Command | -f ScriptFile]

exp:
設定IP
netsh interface ip set address "3USB-1N-White" static 10.254.1.25 255.255.255.0

增加IP
netsh interface ip add address "3USB-1N-White" 10.254.1.25 255.255.255.0

 
增加多個IP
netsh interface ip set address "3USB-1N-White" static 10.254.1.25 255.255.255.0

netsh interface ip add address "3USB-1N-White" 10.254.2.25 255.255.255.0
netsh interface ip add address "3USB-1N-White" 10.254.3.25 255.255.255.0
...

如果要設定包含gateway
netsh interface ip set address "3USB-1N-White" 10.254.1.25 255.255.255.0 10.254.1.1
netsh interface ip add address "3USB-1N-White" 10.254.2.25 255.255.255.010.254.2.1
netsh interface ip add address "3USB-1N-White" 10.254.3.25 255.255.255.010.254.3.1
...

netsh ?可查詢所有可用的命令:

這個內容中的命令:
?              - 顯示命令清單。
add            - 新增項目清單中的設定項目。
advfirewall    - 變更到 `netsh advfirewall' 內容。
bridge         - 變更到 `netsh bridge' 內容。
delete         - 刪除項目清單中的設定項目。
dhcpclient     - 變更到 `netsh dhcpclient' 內容。
dnsclient      - 變更到 `netsh dnsclient' 內容。
dump           - 顯示設定指令檔。
exec           - 執行指令檔。
firewall       - 變更到 `netsh firewall' 內容。
help           - 顯示命令清單。
http           - 變更到 `netsh http' 內容。
interface      - 變更到 `netsh interface' 內容。
ipsec          - 變更到 `netsh ipsec' 內容。
lan            - 變更到 `netsh lan' 內容。
mbn            - 變更到 `netsh mbn' 內容。
namespace      - 變更到 `netsh namespace' 內容。
netio          - 變更到 `netsh netio' 內容。
nlm            - 變更到 `netsh nlm' 內容。
p2p            - 變更到 `netsh p2p' 內容。
ras            - 變更到 `netsh ras' 內容。
rpc            - 變更到 `netsh rpc' 內容。
set            - 更新組態設定。
show           - 顯示資訊。
trace          - 變更到 `netsh trace' 內容。
wcn            - 變更到 `netsh wcn' 內容。
wfp            - 變更到 `netsh wfp' 內容。
winhttp        - 變更到 `netsh winhttp' 內容。
winsock        - 變更到 `netsh winsock' 內容。
wlan           - 變更到 `netsh wlan' 內容。

下列是可使用的子內容:
 advfirewall bridge dhcpclient dnsclient firewall http interface ipsec lan mbn namespace netio nlm p2p ras rpc trace wcn wfp winhttp winsock wlan

如果您要檢視命令的說明,請輸入該命令,後面接著一個空格,
 然後輸入 ?。