I've made some modifications to the script above
here it is...
# Script to add Facebook DNS IP addresses
# Syed Jahanzaib / aacable@hotmail.com / mod by kolorasta
# Script Source: N/A / GOOGLE : )
:log warning "Script Started ... Adding Facebook DNS ip's to address list name facebook_dns_ips"
:foreach i in=[/ip dns cache find] do={
:if ([/ip dns cache all get $i type]="A") do={
:local bNew "true";
:local cacheName [/ip dns cache all get $i name] ;
:if ([:find $cacheName ".fbcdn.net"] != 0 or [:find $cacheName ".facebook.com"] != 0) do={
:local tmpAddress [/ip dns cache get $i address] ;
:put $tmpAddress;
:if ( [/ip firewall address-list find ] = "") do={
:log info ("added entry: $[/ip dns cache get $i name] IP $tmpAddress");
/ip firewall address-list add address=$tmpAddress list=facebook_dns_ips comment=$cacheName;
} else={
:foreach j in=[/ip firewall address-list find ] do={
:if ( [/ip firewall address-list get $j address] = $tmpAddress ) do={
:set bNew "false";
}
}
:if ( $bNew = "true" ) do={
:log info ("added entry: $[/ip dns cache get $i name] IP $tmpAddress");
/ip firewall address-list add address=$tmpAddress list=facebook_dns_ips comment=$cacheName;
}
}
}
}
}
:log warning "Script Finished ... Adding Facebook DNS ip's to address list name facebook_dns_ips"
# FB DNS IP ADD Script Ended ...
first i added this line
:if ([/ip dns cache all get $i type]="A") do={
because i have to process only A records... without this line, the code will hang when a AAAA record is found
then i modified this line
:if ([:find $cacheName ".fbcdn.net"] != 0 or [:find $cacheName ".facebook.com"] != 0) do={
it is wrong to search for "facebook" key word, because sites like "
www.facebooklovers.com" or "facebook.mysite.com" would be included, and i don't want that. that's wrong because they are not facebook. I have to search for ".facebook.com" or ".fbcdn.net". Those are facebook domains.
sorry for my english