2011-12-02

Windows networking reconfiguration script

If you happen to travel a lot, you'll find yourself changing the ip configuration of your windows laptop more than you'd like to.
Here are a couple of scripts that may come handy.

This script sets your ethernet to DHCP:

@echo off

set INTERFACENAME="Local Area Connection"
ipconfig | findstr Connessione >nul:
if %ERRORLEVEL%==0 set INTERFACENAME="Connessione alla rete locale (LAN)"

netsh interface ip set address %INTERFACENAME% dhcp
netsh interface ip set dns %INTERFACENAME% dhcp

ipconfig /renew %INTERFACENAME%

Note that the script tries to detect the windows language and sets the ethernet interface name accordingly.

This one sets a static IP 1.2.3.4:

@echo off
set IP=1.2.3.4
set MASK=255.255.0.0
set GW=1.2.3.1
set DNS=1.2.3.10

set INTERFACENAME="Local Area Connection"
ipconfig | findstr Connessione >nul:
if %ERRORLEVEL%==0 set INTERFACENAME="Connessione alla rete locale (LAN)"

ipconfig /release %INTERFACENAME%

netsh interface ip set address %INTERFACENAME% static %IP% %MASK% %GW% 1
netsh interface ip set dns %INTERFACENAME% static %DNS%



No comments:

Post a Comment