18 September 2017
Mikrotik adblock script – lite
I made a tutorial to block ads on Mikrotik router, but it works only on devices with at least 128 mb ram, so I decided to make another list for devices with 64 mb ram.
It’s the same script with one modification the host files address is:
https://micu.eu/adblock/adblock_lite.php
It has approximately 3000 entries.
So for devices with 64 mb of ram the script is:
/system script
add name=adblock policy=\
ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source=":\
log warning \"starting adblock update\";\r\
\n\
\n\
\n:delay 20;\r\
\n\
\n\
\n:log warning \"downloading adblock\";\r\
\n\
\n\
\n\
\n\
\n:local hostScriptUrl \"https://micu.eu/adblock/adblock_lite.php\";\
\n\
\n\
\n\
\n\r\
\n:local scriptName \"adblock\";\
\n\
\n\
\n\
\n\r\
\ndo {\
\n\
\n /tool fetch mode=http url=\$hostScriptUrl dst-path=(\"./\".\$scriptName\
);\
\n\
\n\r\
\n:delay 20;\
\n\
\n\r\
\n:if ([:len [/file find name=\$scriptName]] > 0) do={\r\
\n\
\n\
\n :log warning \"removing old adblock list\";\
\n\
\n\r\
\n /ip dns static remove [/ip dns static find address=127.0.0.1];\
\n\
\n\r\
\n :log warning \"importing new adblock list\";\r\
\n\
\n\
\n /import file-name=\$scriptName;\r\
\n\
\n\
\n /file remove \$scriptName;\r\
\n\
\n\
\n :log warning \"adblock list imported\";\r\
\n\
\n\
\n } else={\
\n\
\n \r\
\n:log warning \"adblock list not downloaded, script stopped\";\r\
\n\
\n\
\n }\r\
\n\
\n\
\n} on-error={\
\n\
\n \r\
\n:log warning \"adblock list download FAILED\";\
\n\
\n\r\
\n};"
/system scheduler
add interval=1d name=adblock on-event=adblock policy=\
ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon \
start-time=startup
add name=adblock_startup on-event=\
":delay 30;\r\
\n/system script run adblock" policy=\
ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon \
start-time=startup
Don’t forget to force DNS requests to be resolved by the router:
/ip firewall nat add action=redirect chain=dstnat dst-port=53 in-interface=bridge protocol=udp
And set DNS to router IP:
12 Comments

dear sir inenterface me wan port ha ya local out internet or is script ko loadbalancer me dalna ha ya server user me
Hello, I’m sorry but I can’t understand your message.
Hello, it works ok with PC but it won’t block video ads on Smart TV. Is there anything i can do? I made sure that TV uses mikrotik router as primary DNS server.
i forgot to mention i meant video ads on Youtube.
Unfortunately the YouTube ads service uses some sorth of randomly generated domains and I’m not able to block all the ads.
I use as a walk around “YouTube Vanced” for android (you will find the apk on xda-developers) and I stream to the Smart TV from my phone.
work great with hAP ac lite !! thanks a lot
Blocks critical google services, blocks uploading to gdrive and new devices cannot connect to services at all.
For me it works whitout any issue.
Hi! The adblock_240 script works great for me (127.0.0.1 causes issues), however my router becomes uncomfortably short on ram. Could we get a 240 version of this lite script please?
Hi, I want to ask why when downloading always stops.
Is there something wrong?
I use Rb1100ah
When I use it with only ipv4, it’s ok, but when using ipv6 with load blancing PCC, it no longer works to block ads.