Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學
您现在的位置: Windows教程網 >> Windows教程 >  >> Windows 綜合教學 >> 關於 Windows

Windows 指令模式設定靜態 IP 與 DNS 完整教學:netsh 指令詳解

編輯:關於 Windows

需快速設定靜態 IP 或 DNS 時,透過 netsh 指令比圖形介面更高效,適合腳本自動化或遠端管理。以下是完整指令語法:

設定靜態 IP

# 互動模式
netsh
interface
ip
set address "連線名稱" static 新IP 子網路遮罩 閘道 1

# 單行指令(建議)
netsh interface ip set address "連線名稱" static 新IP 子網路遮罩 閘道 1

# 範例
netsh interface ip set address "乙太網路 3" static 192.168.1.108 255.255.255.0 192.168.0.1 1

恢復 DHCP 自動取得 IP

netsh interface ip set address "連線名稱" dhcp

設定靜態 DNS

netsh interface ip set dns "連線名稱" static DNS位址
# 範例
netsh interface ip set dns "乙太網路 3" static 8.8.8.8

恢復 DHCP 取得 DNS

netsh interface ip set dns "連線名稱" dhcp

注意事項

  • 「連線名稱」請參考「網路連線」介面實際名稱(支援中文,引號用半形)。
  • 參數間需有空格,結尾的 1 代表確認。
  • 設定後變為靜態 IP,若衝突可用「疑難排解」或上述 DHCP 指令恢復。
  • 需系統管理員權限執行 CMD。

熟悉 netsh 指令可大幅提升網路設定效率,是系統管理必備技能。

Copyright © Windows教程網 All Rights Reserved