Unbound scripts for win
Grayhat
grayhat at gmx.net
Mon Aug 19 14:17:24 UTC 2024
:: On Mon, 19 Aug 2024 16:02:25 +0200
:: <20240819160225.000062c7 at gmx.net>
:: Grayhat via Unbound-users <unbound-users at lists.nlnetlabs.nl> wrote:
>
> > Hello all, I was checking the script in subject
>
> forgive me, was referring to "create_unbound_ad_servers.cmd"
>
here's an example showing how the script could be simplified and
slightly improved
@echo off
cd /D %~dp0
setlocal
:
SET SRCURL="https://pgl.yoyo.org/adservers/serverlist.php?hostformat=unbound&showintro=0&mimetype=plaintext"
SET TMPFIL=block.temp
set BLKFIL=block.zone
set CFGFIL=%CD%\service.conf
:
del /F /Q %TMPFIL% >NUL 2>&1
curl -o %TMPFIL% %SRCURL%
if errorlevel 1 goto QUIT
:
copy /Y %TMPFIL% %BLKFIL%
del /F /Q %TMPFIL% >NUL 2>&1
unbound-control -c "%CFGFIL%" -s 127.0.0.1 reload
:
:QUIT
exit %ERRORLEVEL%
the above assumes that the "blocklist" is contained into a file named
"block.zone", the script fetches the updated zone to a temporary file
using "curl", then if all ok, copies the temp file to the zone file and
uses "unbound-control" to tell unbound to reload the config and the
zones so applying the update, the URL is modified so that the source
site returns the zone data directly in unbound zone format, so that it
doesn't need to be further manipulated
More information about the Unbound-users
mailing list