Hi! Saving lists to USB drive will save space on the router and the resource of the router’s storage chip, will allow you to load lists immediately after rebooting the router:
:if [/ip/dns/adlist find] do={/ip/dns/adlist reload};
If you have a USB in your router and a flash drive, add this script to the scheduler (once a day), you will always have an updated file on the USB drive::
# MikroTik Adlist USB by UkRainUa (without external functions)
# hardcoded: url, usb1-part1
# hAP ac2 7.16, 7.17 - test ok
:local scriptName "adlist";
/log debug "$scriptName started";
# update adlist function
:local UpdateAdlist do={
:local scriptName "$1->UpdateAdlist->$description";
:do {
/log debug "$scriptName started";
# fetch new adlist source file
/tool/fetch mode=https check-certificate=yes url=$url output=file dst-path=$description as-value;
# short delay to ensure file is created
:delay 1s
# check adlist
:if ([/file/get [find name="$description"] value-name=size] > 1000000) do={
:if [/ip/dns/adlist find where file=$description] do={
/ip/dns/adlist reload;
/log debug "$scriptName adlist reloaded";
} else={
# Create new adlist from file
/ip/dns/adlist add file=$description ssl-verify=no;
/log debug "$scriptName adlist added";
};
} else={
/ip/dns/adlist remove [find where file=$description];
/file/remove [find name=$description];
/log warning "$scriptName runtime error: file not created or corrupted, adlist removed";
};
/log debug "$scriptName executed";
} on-error={
/log warning "$scriptName runtime error";
};
};
# check cache size and adjust if not large enough
:if ([ip/dns/get cache-size]!=32768) do={/ip/dns/set cache-size=32768};
# StevenBlackFGP: Unified hosts + fakenews + gambling + porn
:do {
# run adlist update function
$UpdateAdlist $scriptName url=https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/fakenews-gambling-porn/hosts description=usb1-part1/StevenBlackFGP;
} on-error={
/log warning "$scriptName StevenBlackFGP update failed";
};
# StevenBlack: Unified hosts (adware + malware)
# :do {
# # run adlist update function
# $UpdateAdlist $scriptName url=https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts description=usb1-part1/StevenBlack;
# } on-error={
# /log warning "$scriptName StevenBlack update failed;
# };
# HaGeZiLight
:do {
# run adlist update function
$UpdateAdlist $scriptName url=https://raw.githubusercontent.com/hagezi/dns-blocklists/refs/heads/main/hosts/light.txt description=usb1-part1/HaGeZiLight;
} on-error={
/log warning "$scriptName HaGeZiLight update failed";
};
/log debug "$scriptName executed";
If fetch ends with an error, the script does nothing but report an error, the file will be downloaded and reloaded next time. A script is possible with checking the message in the log about the success of the fetch execution, it will be a little more complicated, it is wise to use a universal external log analysis function for this.