批處理改IP

2021-04-13 08:56:23 字數 1516 閱讀 8414

最近經常切換網路,又要改動態ip ,一會又要改回靜態ip,挺麻煩的。。

下面的內容是改為動態獲取ip 另存為autoip.bat雙擊就可以了

@echo off

rem eth //eth為網絡卡名稱,可在網路連線中查詢,如"本地鏈結"

set eth="本地連線"

echo 正在修改ip為自動獲取,請稍候

cmd /c netsh inte***ce ip set address %eth% dhcp

cmd /c netsh inte***ce ip set dns %eth%dhcp

pause

close

下面是改為靜態的 也是另存為字尾為bat的檔案就好

@echo off

rem eth //eth 為網絡卡名稱,可在網路連線中查詢,如"本地鏈結"

set eth="本地連線"

rem ip //ip 為你想更改的ip

set ip=192.168.1.3

rem gateway //gateway 為閘道器位址

set gateway=192.168.1.1

rem netmasks //netmasks 為子網掩碼

set netmasks=255.255.255.0

rem dns //dns 為首選dns

set dns=192.168.1.1

rem dns2 //dns2 為備用dns

rem set dns2=202.103.0.68

echo 正在將本機ip更改到: %ip% 請等候...

remif %gateway%==none netsh inte***ce ip set address %eth% static %ip% %netmasks% %gateway% > nul

if not %gateway%==none netsh inte***ce ip set address %eth% static %ip% %netmasks% %gateway% 1 > nul

if %dns%==none netsh inte***ce ip set dns %eth% static %dns%> nul

if not %dns%==none netsh inte***ce ip set dns %eth% static %dns%> nul

rem if %dns2%==none netsh inte***ce ip add dns %eth% %dns2%> nul

rem if not %dns2%==none netsh inte***ce ip add dns %eth% %dns2% 2> nul

echo.........................

echo 檢查當前本機ip:

ipconfig

echo.........................

echo 成功將本機ip更改為: %ip%

批處理 改IP

xx.bat,以管理員身份執行 cls echo off start clsecho 請輸入數字選擇下一步操作 echo 1 ip設定為192.168.1.20 echo 2 設定為dhcp自動獲取ip echo 3 退出 set p var if var 1 goto ip20 if var 2 ...

批處理修改IP

上次乙個要我做的乙個ip轉換的批處理,貼出來給大家使用.可以在2個ip之前相互轉換,不必再去修改本地連線了,你要做的只是輸入1或者2。請按自己的須求做相應的修改,原始碼如下 echo off title ip轉換工具 powered by px mode con cols 40 lines 10 c...

批處理設定IP

有些公司加入域後影響一些正常的上網行為,這個時候需要設定靜態ip,下面乙個批處理檔案 可以自動設定ip echo off netsh inte ce ip set address name 本地連線 source static addr 10.16.252.77 mask 255.255.252.0...