Created
March 28, 2020 12:25
-
-
Save itsimba/74941ba9d3beceadd2cd3764faaa448f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:: Set primary and alternate DNS for IPv4 on Windows Server 2000/2003/2008 & | |
:: Windows XP/Vista/7 | |
@ECHO OFF | |
SETLOCAL EnableDelayedExpansion | |
SET adapterName= | |
FOR /F "tokens=* delims=:" %%a IN ('IPCONFIG ^| FIND /I "ETHERNET ADAPTER"') DO ( | |
SET adapterName=%%a | |
REM Removes "Ethernet adapter" from the front of the adapter name | |
SET adapterName=!adapterName:~17! | |
REM Removes the colon from the end of the adapter name | |
SET adapterName=!adapterName:~0,-1! | |
netsh interface ipv4 set dns name="!adapterName!" static 114.114.114.114 primary | |
netsh interface ipv4 add dns name="!adapterName!" 119.29.29.29 index=2 | |
) | |
ipconfig /flushdns | |
:EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment