從辦公室到家、會議室到工位頻繁切換 IP 讓人煩躁,兩支小腳本藥到病除。
@echo off netsh interface ip set address name="local" source=dhcp netsh interface ip set dns name="local" source=dhcp
@echo off netsh interface ip set address local static 192.168.0.84 255.255.255.0 192.168.0.254 netsh interface ip set dns local 192.168.0.254 netsh interface ip add dns local 202.106.196.115 index=2 netsh interface ip add dns local 202.106.0.20 index=3
"local" 為本地網卡名稱,可能是「區域連線」,需自行替換。若在兩組固定 IP 間切換,自行修改第二支腳本。DNS 設定中第一個用 set 設定,後兩個用 add 新增,請替換為當地 DNS 伺服器位址。