resolve command on 3.x release for blacklist filter.

Hi to all. I need help regarding my script that work perfect on 2.9 release but on 3.x release not work.
The problem is in :resolve command. In 2.9 release work but in 3.0 release responde "failure".
The Primary DNS and Secondary DNS is correct and work but for example if i write:

:resolve www2.media.it . On 2.9 reply widthout any error. On 3.x reply "failure".
www2.media.it not is definied in DNS entry but because "failure" ? Failure condition stop my script but also for 0.0.0.0 address, 3.x release, reply "failure".

This is a problem when i ask to resolve ip for spam-check blacklist as in following script.

The reply on resolve command in 2.9 release is 0.0.0.0 (for spammer ip) and failure for 3.x release and script NOT WORK !!
my conclusion is. On 3.x release any command :resolve with incorrect address or reply 0.0.0.0 address cause failure script and all stop my script.

:global SCRIPT "";
:global ALIST "";
:global COMM "";
:global IP "";
:global IPL "";
:global A "";
:global B "";
:global C "";
:global D "";
:global n 0;
:global l 0;
:global COUNT 0;
:global DSBL "";
:global SPAM "";
:global NOME "";

:set SCRIPT "itwbspam";
:if ([:len [/system script job find script=$SCRIPT]] < 10) do={
:set ALIST checkspam;
:foreach IPT in [/ip firewall address-list find list=$ALIST] do={
:set COMM [/ip firewall address-list get $IPT comment];

:if ($COMM = "") do={
/ip firewall address-list set $IPT comment=checking;

:set IP [/ip firewall address-list get $IPT address];
:set IPL $IP;
:set l [:len $IP];
:set n [:find $IP .];
:set A [:pick $IP 0 $n];
:set IP [:pick $IP ($n + 1) 15];
:set n [:find $IP .];
:set B [:pick $IP 0 $n];
:set l [:len $IP];
:set IP [:pick $IP ($n + 1) 15];
:set n [:find $IP .];
:set C [:pick $IP 0 $n];
:set l [:len $IP];
:set IP [:pick $IP ($n + 1) 15];
:set D $IP;

:set COUNT 0;

:set DSBL .dnsbl.sorbs.net;
:set NOME ($D . "." . $C . "." . $B . "." . $A . $DSBL);
:log info $NOME
:set IP [:resolve $NOME];
:if ($IP != "0.0.0.0") do={ :set COUNT ($COUNT + 1); }

:set DSBL .cbl.abuseat.org;
:set SPAM 127.0.0.2;
:set NOME ($D . "." . $C . "." . $B . "." . $A . $DSBL);
:set IP [:resolve $NOME];
:if ($IP = $SPAM) do={ :set COUNT ($COUNT + 1); }

:set DSBL .bl.spamcop.net;
:set SPAM 127.0.0.2;
:set NOME ($D . "." . $C . "." . $B . "." . $A . $DSBL);
:set IP [:resolve $NOME];
:if ($IP = $SPAM) do={ :set COUNT ($COUNT + 1); }

:set DSBL .combined.njabl.org;
:set SPAM 127.0.0.2;
:set NOME ($D . "." . $C . "." . $B . "." . $A . $DSBL);
:set IP [:resolve $NOME];
:if ($IP = $SPAM) do={ :set COUNT ($COUNT + 1); }

:set DSBL .bhnc.njabl.org;
:set SPAM 127.0.0.2;
:set NOME ($D . "." . $C . "." . $B . "." . $A . $DSBL);
:set IP [:resolve $NOME];
:if ($IP = $SPAM) do={ :set COUNT ($COUNT + 1); }

:if ($COUNT > 1) do= {
:if ($COUNT = 1) do={ /ip firewall address-list add list=tempspamlight address=$IPL; }
:if ($COUNT = 2) do={ /ip firewall address-list add list=tempspammedium address=$IPL; }
:if ($COUNT = 3) do={ /ip firewall address-list add list=tempspamhard address=$IPL; }
:if ($COUNT > 3) do={ /ip firewall address-list add list=tempspamhard address=$IPL; }
} else= {
/ip firewall address-list add list=tempsmtp address=$IPL;
}

/ip firewall address-list remove $IPT;

}
}
}

I can solve ? :frowning: help please

www2.media.it doesn’t exist…

http://www.changeip.com/tools/NsLookup.vbs.asp?domain=www2.media.it&type=255&server=ns1.media.it

Sam

One of the changes I just found is the format for the foreach command. The ‘in’ part requires ‘=’ now.

In V2.9
:foreach i in $variable do={ :command }

In V3.X
:foreach i in=$variable do={ :command }

Here is resolve:

[admin@test] > :put [:resolve www.yahoo.com]
69.147.76.15

HINT: When converting scripts from V2.9 to V3.X, you should check the scripts with
/system script
edit scriptname source

This will show you in color where all your errors are. Just like KWrite for those familiar with KDE script programming in php, Perl, C, shell scripts, etc…
Highlighted characters or whitespace in the script is not good except the default cursor at the beginning of the first line.

thanks for reply SurferTim. The problem is the :resolve command. If you ask correct address reply as you tell

[admin@test] > :put [:resolve http://www.yahoo.com]
69.147.76.15

but if you ask incorrect address or ip associated 0.0.0.0 this is reply

[admin@test] > :put [:resolve www2.media.it]
failure

IN 2.x release

[admin@test] > :put [:resolve www2.media.it]
0.0.0.0

It is essential for me because many SBL DNS reply 0.0.0.0 for spammer ip.
Failure condition cause STOP of script. :resolve command in 3.x release work only with valid address.

Thanks

You are correct! It apparently aborts the script when the domain cannot be resolved. I get no return value from the command on fail. I did not catch that on the new version. It now prints “failure” on the command line, and normally you would be able to get that as a return value. But you don’t even get that (with V3.14 anyway).

:frowning: I have open ticket on Mikrotik website but any response. :frowning: Now i receive all spam inbound widthout any protection because my new 3.20 release not permit to resolve invalid or 0.0.0.0 reply.

i can only receive help only here.

Thanks for all that help me.

yes, that practically limits the use of “:resolve” command in scripts, since for example if site is not present or even just internet connection is down (and dns record is not in local cache) it will silently stop the script, and no further actions will be performed - very irritating :frowning:
sup.

I agree, but that may not be all of it. Here is the post to the Beta forum I made after discovering this:
http://forum.mikrotik.com/t/script-file-and-resolve-return-values-file-solved/26182/1
If that call is failing, it is possible other dns calls are failing too. They are aware of the problem, and I am sure they are working on it. They always have.