netsh: ērti nomainīt IP (windows)

Submitted by Jancis on Mon, 11/21/2005 - 18:54

Ir gadījumi, kad visu laiku nepieciešams mainīt adresi. Ar laiku, aizpildīt TCP/IP uzstādījumu ailītes, apnīk.

Varu piedāvāt ērtāku risinājumu kā pamatā ir netsh komanda:

; dinamiska adrese no DHCP
netsh interface ip set address "Local Area Connection" dhcp
netsh interface ip set dns name="Local Area Connection" source=dhcp

; statiska adrese
netsh interface ip set address "Local Area Connection" static 192.168.0.10 255.255.255.0 192.168.0.1 1
netsh interface ip set dns "Local Area Connection" static 159.148.60.20

; atteelot konfiguraaciju
netsh interface ip show config

; avots: http://www.windowsitpro.com/Articles/Index.cfm?ArticleID=41111&DisplayTab=Article

Papildus šim, varu piedāvāt arī bat failu, kur kā parametru var norādīt izvēli:

@echo off
if [%1]==[] goto error
goto %1
:d
netsh interface ip set address "Local Area Connection" dhcp
netsh interface ip set dns "Local Area Connection" dhcp
goto :eof
:s
netsh int ip set addr local static 192.168.0.2 255.255.255.0 192.168.0.1 1
netsh interface ip set dns "Local Area Connection" static 158.148.60.20
goto :eof
:error
cls
Echo. ch_ip d (dncp) : s (192.168.0.2)