-
-
Save googlebe/922c49995d36e23d286ddd6fdc0c040a to your computer and use it in GitHub Desktop.
Batch Script to Change DNS Servers
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
@ECHO OFF | |
ipconfig /all | findstr "Servers" | findstr "xx.xx.xx.xx" | |
if %ERRORLEVEL% equ 0 ( | |
rem echo Findstr FOUND xx.xx.xx.xx in the DNS list. | |
goto google | |
) else ( | |
rem echo Findstr DID NOT find xx.xx.xx.xx in the DNS list. | |
goto local | |
) | |
:local | |
echo Error Level: %errorlevel% - Did not find local DNS server, inputting local settings now... | |
netsh interface ip delete dnsservers "Local Area Connection" all | |
netsh interface ip add dns name="Local Area Connection" addr=xx.xx.xx.xx index=1 | |
netsh interface ip add dns name="Local Area Connection" addr=zz.zz.zz.zz index=2 | |
echo Current DNS Settings: | |
ipconfig /all | findstr /c:"xx.xx.xx.xx" | |
ipconfig /all | findstr /c:"zz.zz.zz.zz" | |
pause | |
goto end | |
echo Error Level: %errorlevel% - Found local DNS server, inputting Google settings now... | |
netsh interface ip delete dnsservers "Local Area Connection" all | |
netsh interface ip add dns name="Local Area Connection" addr=8.8.4.4 index=1 | |
netsh interface ip add dns name="Local Area Connection" addr=8.8.8.8 index=2 | |
echo Current DNS Settings: | |
ipconfig /all | findstr /c:"8.8.4.4" | |
ipconfig /all | findstr /c:"8.8.8.8" | |
pause | |
goto end | |
:end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment