Last active
April 20, 2016 16:51
-
-
Save jmkim/037809c66d207f7d8aa7 to your computer and use it in GitHub Desktop.
DNS updater, written in Windows Batch
This file contains 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
:: Copyright (C) 2014 Jongmin Kim / kdzlvaids@gmail.com | |
:: This program is free software: you can redistribute it and/or modify | |
:: t under the terms of the GNU General Public License as published by | |
:: the Free Software Foundation, either version 3 of the License, or | |
:: (at your option) any later version. | |
:: This program is distributed in the hope that it will be useful, | |
:: but WITHOUT ANY WARRANTY; without even the implied warranty of | |
:: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
:: GNU General Public License for more details. | |
:: You should have received a copy of the GNU General Public License | |
:: along with this program. If not, see <http://www.gnu.org/licenses/>. | |
:: Last edited at: Sun Nov 2 14:55:23 KST 2014 | |
:: Last edited by: Jongmin Kim (kdzlvaids@gmail.com) | |
@ECHO OFF | |
GOTO :INIT | |
:INIT | |
SETLOCAL | |
ECHO Initialising... | |
CHCP 949 2>NUL | |
IF NOT ERRORLEVEL 1 GOTO :MAIN ELSE ( | |
SET "ERRCOM=Codepage 949 not available" | |
SET "ERRFUS=1" | |
) | |
ECHO This system is not supported yet (%ERRCOM%) | |
ECHO Press any key to continue . . . | |
PAUSE >NUL | |
ENDLOCAL | |
EXIT /B 1 | |
:MAIN | |
CLS | |
CALL :PROMPT01 | |
ENDLOCAL | |
EXIT /B | |
:PROMPT01 | |
netsh interface show interface | |
SET /P "PROMPT01=Interface name: " | |
GOTO :PROMPT02 | |
:PROMPT02 | |
CLS | |
ECHO. | |
IF "%PROMPT02_ERR%" EQU "1" ( | |
ECHO. | |
ECHO Error: "%PROMPT02%" was not expected. | |
) ELSE ( | |
ECHO List of Public DNS Server | |
ECHO Your interface name is: %PROMPT01% | |
) | |
netsh interface ip show dns | |
ECHO [PROVIDER] [PRIMATY] [SECONDARY] [COMMENT] | |
ECHO 1 KT DNS 168.126.63.1 168.126.63.2 kth Search Engine | |
ECHO 2 KT DNS 211.45.150.201 211.45.151.201 | |
ECHO 3 SK Broadband 210.220.163.82 219.250.36.130 | |
ECHO 4 LG U+ 164.124.101.2 203.248.252.2 | |
ECHO 5 Google Public DNS 8.8.8.8 8.8.4.4 | |
ECHO 6 OPEN DNS 208.67.222.222 208.67.220.220 | |
ECHO 7 Comodo Secure DNS 8.26.56.26 8.20.247.20 | |
ECHO 8 Norton ConnectSafe 198.153.192.40 198.153.194.40 Security | |
ECHO 9 Norton ConnectSafe 198.153.192.50 198.153.194.50 Sec + Pornography | |
ECHO 10 Norton ConnectSafe 198.153.192.60 198.153.194.60 Sec + Porn + Family | |
ECHO. | |
SETLOCAL | |
SET /P "PROMPT02=Select connection number: " | |
IF "%PROMPT02%" EQU "1" ( | |
SET "IP01=168.126.63.1" | |
SET "IP02=168.126.63.2" | |
) ELSE IF "%PROMPT02%" EQU "2" ( | |
SET "IP01=211.45.150.201 " | |
SET "IP02=211.45.151.201" | |
) ELSE IF "%PROMPT02%" EQU "3" ( | |
SET "IP01=210.220.163.82" | |
SET "IP02=219.250.36.130" | |
) ELSE IF "%PROMPT02%" EQU "4" ( | |
SET "IP01=164.124.101.2" | |
SET "IP02=203.248.252.2" | |
) ELSE IF "%PROMPT02%" EQU "5" ( | |
SET "IP01=8.8.8.8" | |
SET "IP02=8.8.4.4" | |
) ELSE IF "%PROMPT02%" EQU "6" ( | |
SET "IP01=208.67.222.222" | |
SET "IP02=208.67.220.220" | |
) ELSE IF "%PROMPT02%" EQU "7" ( | |
SET "IP01=8.26.56.26" | |
SET "IP02=8.20.247.20" | |
) ELSE IF "%PROMPT02%" EQU "8" ( | |
SET "IP01=198.153.192.40" | |
SET "IP02=198.153.194.40" | |
) ELSE IF "%PROMPT02%" EQU "9" ( | |
SET "IP01=198.153.192.50" | |
SET "IP02=198.153.194.50" | |
) ELSE IF "%PROMPT02%" EQU "10" ( | |
SET "IP01=198.153.192.60" | |
SET "IP02=198.153.194.60" | |
) ELSE ( | |
ENDLOCAL | |
SET "PROMPT02_ERR=1" | |
GOTO :PROMPT02 | |
) | |
CALL :DO_NETSH | |
ENDLOCAL | |
EXIT /B | |
:DO_NETSH | |
ECHO. | |
ECHO Your interface name is: %PROMPT01% | |
ECHO. | |
ECHO Purging old DNS settings . . . | |
netsh interface ip delete dns "%PROMPT01%" all | |
ECHO Setting primary DNS server to: %IP01% . . . | |
netsh interface ip add dns "%PROMPT01%" %IP01% index=1 | |
ECHO Setting secondary DNS server to: %IP02% . . . | |
netsh interface ip add dns "%PROMPT01%" %IP02% index=2 | |
ECHO Press any key to continue . . . | |
PAUSE >NUL | |
EXIT /B |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment