Script to change gateway by command

@echo off
rem eth //eth 爲網卡名稱,可在網絡連接中查詢,如"本地連接"
set eth="本地連接"
rem ip //ip 爲你想更改的IP
set ip=10.0.125.38
rem gw //gw 爲網關地址
set gw=10.0.125.2
rem netmasks //netmasks 爲子網掩碼
set netmasks=255.255.255.0
rem echo 正在將本機IP更改到: %ip%
rem
if %gw%==none netsh interface ip set address %eth% static %ip% %netmasks% %gw% > nul
if not %gw%==none netsh interface ip set address %eth% static %ip% %netmasks% %gw% 1 > nul
netsh interface ip set dns "本地連接" static 10.0.125.2
netsh interface ip add dns "本地連接" 210.22.84.3
echo.........................
echo 檢查當前本機IP:
ipconfig
echo.........................
echo 成功將本機IP更改爲%ip%!
pause
close

發佈了257 篇原創文章 · 獲贊 6 · 訪問量 31萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章