Script help!

Hi All.

I’m using a 3g card in an RB230, and all is going well. I’d like to create a script, however I’m still learning. I understand the basics but not the find arguments etc.

I’d like a script that monitors the IP assigned to the ppp connection. If it starts with 192 10 or 172 then I want to drop the connection and redial. The mobile provider does issue real IP’s but sometimes I get a nat’ed IP, which is no use for ChangeIP updates!

I’ve got to ensure that the connection is reachable from the internet, as the RB will be left in a remote location, and I’ll be connecting to check the status of some equpment.

Thanks in advance.

Glen

http://wiki.mikrotik.com/wiki/Sending_your_self_an_e-mail_with_DSL_interface_IP_address

This would be a good place to start. Just then modify the command that sends an email to check if the ip starts with 192 or 172, 10 and if not, disable and re-enable the interface.

If you send ChangeIP.com a private IP address (rfc1918) we will automatically resolve your public IP from it now. If you do not want this behavious we can bypass your UserID in the system to actually have it update using the private IP.

We will be coming out with an updated script that handles natted connections better, look for something in the next few weeks.

changeip, the other problem is that he needs to be able to connect remotely

yep…

so if your natted you cannot connect back using port 8291 ?

Here is some pseudo-code from our inbound load balancing script… it loops thru the bypassed subnets and checks to see it’s within that range. for your use you could probably just parse the first octet and compare instead of the logic below, but here it is for your reference.

     :global ddns-bypass "10.0.0.0/8,172.16.0.0/12,192.168.0.0/16"

              :foreach net in=[:toarray $ddns-bypass ] do={
    
                :log info ( "DDNS: Is " . $tmp . " within network " . $net >
                :if ( ([:pick $net 0 [:find $net "/"]] & (255.255.255.255 << \
                      (32 - [:pick $net ([:find $net "/"] + 1) [:len $net]]))>
                      ($tmp & (255.255.255.255 << (32 - [:pick $net \
                      ([:find $net "/"] + 1) [:len $net]])))) do={
                     :log debug ( "DDNS: Bypassed network: " . $net )
                 }

That full script is here if you want more of it:
http://forum.mikrotik.com/t/changeip-com-ddns-inbound-load-balancing/3821/1