Skip to content

Instantly share code, notes, and snippets.

@ArtiomL
Last active December 28, 2015 02:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ArtiomL/7429173 to your computer and use it in GitHub Desktop.
Save ArtiomL/7429173 to your computer and use it in GitHub Desktop.
IP - TCP/IP Configuration Script
@echo off
REM IP - TCP/IP Configuration Script
REM (CC0) No Rights Reserved
REM Artiom Lichtenstein
REM v1.6, 24/03/2014
if [%1]==[] goto lbl_HELP
set str_NIC=Local Area Connection
REM ----------
REM DISABLE
REM ----------
if [%1]==[dis] netsh interface set interface "%str_NIC%" disabled > nul
if [%1]==[dis] ipconfig /all
if [%1]==[dis] echo.
if [%1]==[dis] goto lbl_END
netsh interface set interface "%str_NIC%" enabled > nul
REM ----------
REM DHCP
REM ----------
if [%1]==[dhcp] netsh int ipv4 set addr "%str_NIC%" dhcp > nul
if [%1]==[dhcp] netsh int ipv4 set dns "%str_NIC%" dhcp > nul
if [%1]==[dhcp] netsh int ipv4 set wins "%str_NIC%" dhcp > nul
if [%1]==[dhcp] ipconfig/release *%str_NIC%> nul
if [%1]==[dhcp] ipconfig/renew *%str_NIC%> nul
if [%1]==[dhcp] ipconfig /all
if [%1]==[dhcp] echo.
if [%1]==[dhcp] goto lbl_END
REM ----------
REM STATIC
REM ----------
netsh int ip set addr "%str_NIC%" static %1 > nul
if NOT [%2]==[] netsh int ip add route 0.0.0.0/0 "%str_NIC%" %2 > nul
if NOT [%3]==[] netsh int ip set dns "%str_NIC%" static %3 primary > nul
ipconfig /all
echo.
goto lbl_END
:lbl_HELP
cls
echo.
echo ____________________________________________ v1.6 ___
echo.
echo Usage: ip {DIS ^| DHCP ^| IP_ADDRESS/CIDR} [DG] [DNS]
echo _____________________________________________________
echo.
echo Examples: ip dhcp
echo ip 192.168.1.1/24
echo ip 172.16.17.18/16 172.16.1.254 8.8.4.4
echo _____________________________________________________
echo.
ipconfig /all
echo.
:lbl_END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment