Block access to specific websites

1.catch all dns requests:
/ip firewall nat
add action=redirect chain=dstnat comment=DNS dst-port=53 protocol=tcp to-ports=53
add action=redirect chain=dstnat dst-port=53 protocol=udp to-ports=53
/ip firewall filter
add chain=forward dst-address-list=restricted action=drop

2.write a script and schedule it to run, lets say, every 30 seconds
:foreach i in=[/ip dns cache find] do={
:local bNew "true";
:local NameAddress [/ip dns cache all get $i name] ;

:put $NameAddress;

:if (([:find $NameAddress "freedownload"] != 0)) do={

:local tempAddress [/ip dns cache get $i address] ;

:put $tempAddress;

if address list is empty do not check

:if ( [/ip firewall address-list find ] = "") do={
:log info ("added entry: $[/ip dns cache get $i name] IP $tempAddress");
/ip firewall address-list add address=$tempAddress list=restricted comment=$NameAddress;
} else={
:foreach j in=[/ip firewall address-list find ] do={
:if ( [/ip firewall address-list get $j address] = $tempAddress ) do={
:set bNew "false";
}
}
:if ( $bNew = "true" ) do={
:log info ("added entry: $[/ip dns cache get $i name] IP $tempAddress");
/ip firewall address-list add address=$tempAddress list=restricted comment=$NameAddress;
}
}
}
}