Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學

Netsh 命令備份/還原網路設定:筆電移動辦公一鍵切換家裡/公司 IP、閘道、DNS

編輯:XP 系統基礎知識

痛點

筆電頻繁在不同網路環境(家裡、公司、客戶端)移動,每次手動設定 IP、閘道、DNS 极其繁瑣。

解決方案:Netsh 匯出/匯入網路設定腳本

1. 備份目前網路設定

在 命令提示字元 執行:

netsh -c interface dump > D:\home.txt

同理備份公司設定:netsh -c interface dump > D:\office.txt。

必須在命令提示字元(cmd.exe)執行,「執行」對話框直接輸入無效。

2. 還原/切換網路設定

需切換時,在「執行」或 cmd 執行:

netsh -f D:\home.txt
netsh -f D:\office.txt

即可秒級套用完整 TCP/IP 設定(IP、子網路遮罩、閘道、DNS、WINS 等)。

3. 製作批次檔一鍵切換

建立 home.bat:@netsh -f D:\home.txt
建立 office.bat:@netsh -f D:\office.txt
放在桌面或快速啟動列,雙擊即切換。

適用版本

Windows 2000 / XP / 2003 / Vista / 7 / 8 / 10 / 11(語法相容)。

進階用法

  • netsh interface ip set address "區域連線" static 192.168.1.100 255.255.255.0 192.168.1.1 直接指令設定靜態 IP。
  • netsh interface ip set dns "區域連線" static 168.95.1.1 設定 DNS。
  • 可結合 netsh wlan 管理無線網路設定檔。

結語:Netsh 是 Windows 內建的網路設定自動化利器,善用 dump/匯入腳本配合批次檔,讓筆電移動辦公網路切換從「分鐘級手動」變成「秒級一鍵」。

Copyright © Windows教程網 All Rights Reserved