Skip to content

Instantly share code, notes, and snippets.

@alessandromrc
Created November 2, 2022 21:37
Show Gist options
  • Save alessandromrc/8db2b3a4dc87fa3a3c4e387ea21a9f0e to your computer and use it in GitHub Desktop.
Save alessandromrc/8db2b3a4dc87fa3a3c4e387ea21a9f0e to your computer and use it in GitHub Desktop.
Auto Configurator for Cloudflare DNS made with batch for windows
@echo off
Title Cloudflare DNS Auto Configurator
set first_server= "1.1.1.1"
set second_server= "1.0.0.1"
:checkPrivileges
NET FILE 1>NUL 2>NUL
if '%errorlevel%' == '0' ( goto gotPrivileges ) else ( goto getPrivileges )
:getPrivileges
echo You have no admin rights. Please run me as administrator.
goto end
:gotPrivileges
echo You have admin rights. Continuing...
REM clearing up the cache
echo Clearing DNS Cache
wmic nicconfig where (IPEnabled=TRUE) call SetDNSServerSearchOrder ()
REM configure cloudflare as DNS server
echo Configuring Cloudflare as DNS server
wmic nicconfig where (IPEnabled=TRUE) call SetDNSServerSearchOrder (%first_server%, %second_server%)
goto end
:end
pause
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment