Thursday, March 22, 2012

Change IP Script

Got tired of all the clicking and right clicking to change my interface address one day while setting up a bunch of equipment that lived in different subnets.

-=The Script=-


@echo off
title Set IP
echo Which Interface?
netsh interface show interface
set /p int=
cls
echo Interface %int%
Echo Static (s) or DHCP (d)
set /p con=
if %con%==s goto setip
if %con%==d goto dhcp

:setip
cls
echo Interface %int%
Echo Enter IP Address
set /p ipadd=
echo Enter Subnet Mask
set /p subnet=
echo Enter Default Gateway
set /p defgat=
echo Do you want to set DNS servers also? (y/n)
set /p ans=
if %ans%==y goto sdns
if %ans%==n echo DNS servers will not be set.
Echo Setting IP Address...
netsh interface ip set address "%int%" static %ipadd% %subnet% %defgat% 1
pause
exit

:sdns
cls
echo DNS Server Setup
echo Enter the IP address of the first dns server
set /p one=
echo Enter the IP address of the second dns server
set /p two=
echo Adding DNS 1...
netsh interface ip add dns "%int%" %one%
echo Adding DNS 2...
netsh interface ip add dns "%int%" %two%
Echo Setting IP Address...
netsh interface ip set address "%int%" static %ipadd% %subnet% %defgat% 1
exit

:dhcp
cls
Echo Interface %int%
echo Setting Interface to DHCP...
netsh interface ip set address "%int%" dhcp
pause
exit

No comments:

Post a Comment

All comments moderated.
Comments like "sweet dude" or "this is awesome" or "thanks" will be denied,
if you've got something genuinely interesting to say, say it. Other than that just sit back and bask in the glory.