圖形介面設定 IP 有時會失效 (如 Win10 預覽版 10049),或需在無螢幕伺服器、自動化腳本中配置網路。`netsh interface ip` 指令集提供完整的命令列解決方案,適用 Win7/8.1/10/11/Server 全系列。
C:\> netsh
netsh> interface
netsh interface> ip
netsh interface ip> set address "乙太網路" static 192.168.1.100 255.255.255.0 192.168.1.1 1
netsh interface ip> set dns "乙太網路" static 8.8.8.8
netsh interface ip> quit
:: 設定靜態 IP
netsh interface ip set address "乙太網路" static 192.168.1.100 255.255.255.0 192.168.1.1 1
:: 設定靜態 DNS
netsh interface ip set dns "乙太網路" static 8.8.8.8
:: 新增第二組 DNS
netsh interface ip add dns "乙太網路" 8.8.4.4 index=2
:: 恢復 DHCP 自動取得 IP
netsh interface ip set address "乙太網路" dhcp
:: 恢復 DHCP 自動取得 DNS
netsh interface ip set dns "乙太網路" dhcp

| 參數 | 說明 |
|---|---|
| "介面名稱" | 需與「網路連線」中顯示完全一致,支援中文,必須用英文雙引號 |
| static | 指定靜態參數 |
| IP 位址 | 如 192.168.1.100 |
| 子網路遮罩 | 如 255.255.255.0 |
| 預設閘道 | 如 192.168.1.1 |
| 1 (結尾) | 代表確認/啟用,不可省略 |
netsh interface ip show config "乙太網路"
netsh interface ip show dnsservers "乙太網路"
New-NetIPAddress -InterfaceAlias "乙太網路" -IPAddress 192.168.1.100 -PrefixLength 24 -DefaultGateway 192.168.1.1
Set-DnsClientServerAddress -InterfaceAlias "乙太網路" -ServerAddresses 8.8.8.8, 8.8.4.4
# 恢復 DHCP
Remove-NetIPAddress -InterfaceAlias "乙太網路" -IPAddress 192.168.1.100 -Confirm:$false
Set-DnsClientServerAddress -InterfaceAlias "乙太網路" -ResetServerAddresses