Community discussions

MikroTik App
 
mabsolutions
just joined
Topic Author
Posts: 8
Joined: Thu May 31, 2007 4:06 am

CHANGEIP script for V3.0

Mon Jan 21, 2008 12:23 am

I edited and got the v2.9 script for Dynamic DNS running on V3.0.

Here is my script

:log info "DDNS: Begin"

:global ddnsuser "YOURUSERNAME"
:global ddnspass "YOURPASSWORD"
:global ddnshost "*1"
:global ddnsinterface "YOUREXACTINTERFACENAME"

:global ddnsip [ /ip address get [/ip address find interface=$ddnsinterface] address ]

:if ([ :typeof ddnslastip ] = nil ) do={ :global ddnslastip 0.0.0.0/0 }

:if ([ :typeof $ddnsip ] = nil ) do={

:log info ("DDNS: No ip address present on " . $ddnsinterface . ", please check.")

} else={

:if ($ddnsip != ddnslastip) do={

:log info "DDNS: Sending UPDATE!"
:log info [ /tool dns-update name=$ddnshost address=[:pick $ddnsip 0 [:find $ddnsip "/"] ] key-name=$ddnsuser key=$ddnspass ]
:global ddnslastip $ddnsip

} else={

:log info "DDNS: No change"

}

}

:log info "DDNS: End"



Hope it works for you
 
changeip
Forum Guru
Forum Guru
Posts: 3833
Joined: Fri May 28, 2004 5:22 pm

Re: CHANGEIP script for V3.0

Mon Jan 21, 2008 9:27 pm

You can try this new and improved script that is compatible with 3.0:

http://wiki.mikrotik.com/wiki/Dynamic_D ... angeIP.com

If there are problems with interface detection in this version please let me know. This should automatically figure out which interface the current default gateway is using and send us updates using that IP - in effect allowing failover for multiple WANs as well.
 
mabsolutions
just joined
Topic Author
Posts: 8
Joined: Thu May 31, 2007 4:06 am

Re: CHANGEIP script for V3.0

Sat Jan 26, 2008 10:18 pm

I tried the script you sugested.


When I run from the terminal it runs fine. But when I add it to scripts and setup a schedule to run the script, then it the log it just says "DDNS: Sending update" DDNS is the name of my script. But the update never goes through.

Also what I need is a bit diferent from what the script is.

I have 2 interface connected to the internet. The first one is a Public Fixed ip on ether5 on a RB150. That is used for browsing and email. It is also my default GW.

The second one is a ADSL 4MB line which is used for VoIP. As this is a capped account I only allow the VoIP traffic going through it. A have a route set to route the traffic through the ADSL Line. That words fine. My interface is called "ADSL". This is how I changed the script. Pleas see if I made any mistakes

***************************************************************

# Define User Variables
:global ddnsuser "ChangeIPUsername"
:global ddnspass "ChangeIPPassword"
:global ddnshost "*1" # Also tried the ddns url something.changeip.net

# Define Global Variables
:global ddnsip
:global ddnslastip
:global ddnsinterface "ADSL" # I added this
:global ddnssystem ("mt-" . [/system package get system version] )



# Define Local Variables
:local int

# Loop thru interfaces and look for ones containing
# default gateways without routing-marks
#:foreach int in=[/ip route find dst-address=0.0.0.0/0 active=yes ] do={
# :if ([:typeof [/ip route get $int routing-mark ]] != str ) do={
# :global ddnsinterface [/ip route get $int interface]
# }
#}
# I hassed this out

# Grab the current IP address on that interface.
:global ddnsip [ /ip address get [/ip address find interface=@ddnsinterface ] address ]

# Did we get an IP address to compare?
:if ([ :typeof $ddnsip ] = nil ) do={
:log info ("DDNS: No ip address present on " . $ddnsinterface . ", please check.")
} else={

:if ($ddnsip != $ddnslastip) do={

:log info "DDNS: Sending UPDATE!"
:log info [ :put [/tool dns-update name=$ddnshost address=[:pick $ddnsip 0 [:find $ddnsip "/"] ] key-name=$ddnsuser key=$ddnspass ] ]
:log info "DDNS: After UPDATE!" # It never gets to this.
:global ddnslastip $ddnsip

} else={
:log info "DDNS: No update required."
}

}

****************************************************************


If I past this in the terminal, it runs fine?

URGENT Please
 
stelios-k
just joined
Posts: 4
Joined: Thu Jan 24, 2008 11:45 am

Re: CHANGEIP script for V3.0

Sat Jan 26, 2008 11:51 pm

I was getting timeouts (on 2.9) and i found out that port 443 needs to be open for the update to work.
http://forum.mikrotik.com/viewtopic.php?f=9&t=21315
 
changeip
Forum Guru
Forum Guru
Posts: 3833
Joined: Fri May 28, 2004 5:22 pm

Re: CHANGEIP script for V3.0

Sun Jan 27, 2008 6:52 pm

On this line:

:global ddnsip [ /ip address get [/ip address find interface=@ddnsinterface ] address ]

Are you really using an @ sign instead of a $ sign ?

Also - reboot the router and manually run the script. Then go to terminal and type ':env print' to see what the variables show. If there are some global variables missing maybe thats the problem. It seems like 3.0 does global variables a little differently... like they are only global sometimes : )

Sam
 
mabsolutions
just joined
Topic Author
Posts: 8
Joined: Thu May 31, 2007 4:06 am

Re: CHANGEIP script for V3.0

Sun Jan 27, 2008 8:00 pm

Typing error when I typed on the forum, I'm using a $
 
mabsolutions
just joined
Topic Author
Posts: 8
Joined: Thu May 31, 2007 4:06 am

Re: CHANGEIP script for V3.0

Sun Jan 27, 2008 8:17 pm

Ckecked Global Variables with :env print

All values are correct. But update not happening. When I run the script it give the "Sending Update" ion the log but nothing happens.

Then I copy the following line into the terminal

:log info [ :put [/tool dns-update name=$ddnshost address=[:pick $ddnsip 0 [:find $ddnsip "/"] ] key-name=$ddnsuser key=$ddnspass ] ]

And the Log replies " Updates Suceed" so according to that it shows me that it is picking up the variables but the dns-update don't work from the script.

Anything else I can try?

I have no firewall rules set. thus port 443 should be opened.
I also added a rule to accept input traffic on port 443 just in case.

Any ideas?
 
mabsolutions
just joined
Topic Author
Posts: 8
Joined: Thu May 31, 2007 4:06 am

Re: CHANGEIP script for V3.0

Mon Feb 11, 2008 6:26 pm

:shock:

Ok the problem on the V3.0 and V2.9 scripts not working was that I did not press enter after the last command. Thus not going to a new line in my scripts.

Does this make sence?
 
changeip
Forum Guru
Forum Guru
Posts: 3833
Joined: Fri May 28, 2004 5:22 pm

Re: CHANGEIP script for V3.0

Mon Feb 11, 2008 6:27 pm

Ah, that makes sense. I will add some comments at the bottom of the script so that people don't make that mistake again.

Thx,
Sam
 
backi
just joined
Posts: 2
Joined: Tue Feb 19, 2008 12:23 pm

Re: CHANGEIP script for V3.0

Tue Feb 19, 2008 1:32 pm

I delete all "$", "@" etc....

it acts almost well , but

and in all script, I see error here:

:global ddnsip [ /ip address get [/ip address find interface=ddnsinterface ] address ]

exacly here

:/ip address find interface=pppoe-out1 #for me =pppoe-out1 :) #

error: ambiguous value of interface, more than one possible value matches input

I don't understand this erros because I have one pppoe-out1
 
changeip
Forum Guru
Forum Guru
Posts: 3833
Joined: Fri May 28, 2004 5:22 pm

Re: CHANGEIP script for V3.0

Tue Feb 19, 2008 8:48 pm

dont use : in front of that command.

Can you type this in terminal to see what is stored:

:env print

See what the ddnsinterface is showing.

Thx,
Sam
 
backi
just joined
Posts: 2
Joined: Tue Feb 19, 2008 12:23 pm

Re: CHANGEIP script for V3.0

Thu Feb 21, 2008 10:47 am

this working correctly for v3.2



:global ddnsuser "user for changeip"
:global ddnspass "pass for changeip"
:global ddnshost "host for changeip"
:global ddnsip
:global ddnslastip # first run --> :global ddnslastip 0 #
:if ([ :typeof $ddnslastip ] = nil ) do={ :global ddnslastip "0" }
:global ddnsinterface
# :global ddnssystem ("mt-" . [/system package get system version] ) # unnecessary #
:local int
:foreach int in=[/ip route find dst-address=0.0.0.0/0 active=yes ] do={
:if ([:typeof [/ip route get $int routing-mark ]] != str ) do={
:global ddnsinterface [/ip route get $int interface]}}
:global ddnsip [ /ip address get [/ip address find interface=$ddnsinterface ] address ]
:if ([ :typeof $ddnsip ] = nil ) do={
:log info ("DDNS: No ip address present on " . $ddnsinterface . ", please check.")
} else={
:if ($ddnsip != $ddnslastip) do={
:log info "DDNS: Sending UPDATE!"
:log info [ :put [/tool dns-update name=$ddnshost address=[:pick $ddnsip 0 [:find $ddnsip "/"] ] key-name=$ddnsuser key=$ddnspass ] ]
:global ddnslastip $ddnsip
} else={
:log info "DDNS: No update required."}}
 
danletkeman
Member Candidate
Member Candidate
Posts: 110
Joined: Mon Oct 18, 2004 5:42 pm

Re: CHANGEIP script for V3.0

Wed Feb 27, 2008 3:19 am

It wouldn't work for me on version 3.3 so I changed line 5 & 6 to look like this:

:global ddnslastip
# first run --> :global ddnslastip 0 #

instead of this:

:global ddnslastip # first run --> :global ddnslastip 0 #
 
corehosting
just joined
Posts: 1
Joined: Thu May 25, 2006 3:03 pm

Re: CHANGEIP script for V3.0

Wed Feb 27, 2008 2:27 pm

Hello @all,

perhapes a stupid but short question:

Could I use this script together with DynDNS.com?


Kind Regards

Fabian
 
Tasmanet
just joined
Posts: 15
Joined: Fri Sep 16, 2005 5:43 pm
Location: Tasmania, Australia
Contact:

Re: CHANGEIP script for V3.0

Wed Feb 27, 2008 3:32 pm

Hi Guys,

Still having problems getting this script going... i have been using this script. (Running 3.3)


:global ddnsuser "username"
:global ddnspass "password"
:global ddnshost "myhostname"

:global ddnsip
:global ddnslastip

# first run --> :global ddnslastip 0 #

:if ([ :typeof $ddnslastip ] = nil ) do={ :global ddnslastip "0" }

:global ddnsinterface
# :global ddnssystem ("mt-" . [/system package get system version] ) # unnecessary #
:local int
:foreach int in=[/ip route find dst-address=0.0.0.0/0 active=yes ] do={
:if ([:typeof [/ip route get $int routing-mark ]] != str ) do={
:global ddnsinterface [/ip route get $int interface]}}
:global ddnsip [ /ip address get [/ip address find interface=$ddnsinterface ] address ]
:if ([ :typeof $ddnsip ] = nil ) do={
:log info ("DDNS: No ip address present on " . $ddnsinterface . ", please check.")
} else={
:if ($ddnsip != $ddnslastip) do={
:log info "DDNS: Sending UPDATE!"
:log info [ :put [/tool dns-update name=$ddnshost address=[:pick $ddnsip 0 [:find $ddnsip "/"] ] key-name=$ddnsuser key=$ddnspass ] ]
:global ddnslastip $ddnsip
} else={
:log info "DDNS: No update required."}}



Any help or ideas would be fantastic!
Cheers, Andy
 
danletkeman
Member Candidate
Member Candidate
Posts: 110
Joined: Mon Oct 18, 2004 5:42 pm

Re: CHANGEIP script for V3.0

Thu Feb 28, 2008 6:07 am

Hi Guys,

Still having problems getting this script going... i have been using this script. (Running 3.3)


:global ddnsuser "username"
:global ddnspass "password"
:global ddnshost "myhostname"

:global ddnsip
:global ddnslastip

# first run --> :global ddnslastip 0 #

:if ([ :typeof $ddnslastip ] = nil ) do={ :global ddnslastip "0" }

:global ddnsinterface
# :global ddnssystem ("mt-" . [/system package get system version] ) # unnecessary #
:local int
:foreach int in=[/ip route find dst-address=0.0.0.0/0 active=yes ] do={
:if ([:typeof [/ip route get $int routing-mark ]] != str ) do={
:global ddnsinterface [/ip route get $int interface]}}
:global ddnsip [ /ip address get [/ip address find interface=$ddnsinterface ] address ]
:if ([ :typeof $ddnsip ] = nil ) do={
:log info ("DDNS: No ip address present on " . $ddnsinterface . ", please check.")
} else={
:if ($ddnsip != $ddnslastip) do={
:log info "DDNS: Sending UPDATE!"
:log info [ :put [/tool dns-update name=$ddnshost address=[:pick $ddnsip 0 [:find $ddnsip "/"] ] key-name=$ddnsuser key=$ddnspass ] ]
:global ddnslastip $ddnsip
} else={
:log info "DDNS: No update required."}}



Any help or ideas would be fantastic!
Cheers, Andy
Try running the script via the terminal. It should tell you what line of the script is causing the problem.
 
maximo64
just joined
Posts: 13
Joined: Mon Nov 26, 2007 6:35 pm

Re: CHANGEIP script for V3.0

Sat Mar 01, 2008 12:34 am

My configuration is

Internet-----ADSL Modem (running ppoe) ----- ether1 (10.0.0.1)- MT -- RF AP --------- Station --- MT --- ether1 --- PC

When I run this script changeip.com always get the same IP address of ether1 of the edge router (10.0.0.1) and not the one dynamically assigned by ppoe to the adsl modem.
 
aandcp
just joined
Posts: 8
Joined: Mon Mar 03, 2008 11:47 am

Re: CHANGEIP script for V3.0

Mon Mar 03, 2008 11:49 am

Remove all of the "commented lines"... I have just tried the script that tasmanet posted with all of the comment lines removed and it is working fantastic.

It seems that "hashed-out" comment lines are not supported, or at least not in the correct format. Remove them and all is good!
 
danletkeman
Member Candidate
Member Candidate
Posts: 110
Joined: Mon Oct 18, 2004 5:42 pm

Re: CHANGEIP script for V3.0

Wed Mar 05, 2008 3:46 am

Upgraded to 3.4 and the script is dead.

This command:
ip route find dst-address=0.0.0.0/0 active=yes

Gives this error:
invalid value of active, must be either yes or no

And as you can clearly see it is already set to "yes"

There are more than likely other errors as well.

Anyone else try 3.4 with this script yet?
 
danletkeman
Member Candidate
Member Candidate
Posts: 110
Joined: Mon Oct 18, 2004 5:42 pm

Re: CHANGEIP script for V3.0

Sat Mar 08, 2008 4:43 am

Downgraded to 3.3, everything works great.....no one has tried 3.4 yet?
 
Martell
just joined
Posts: 8
Joined: Sat Mar 15, 2008 11:48 pm

Re: CHANGEIP script for V3.0

Sun Mar 16, 2008 12:16 am

Hi everybody, there is a working solution for you now!

I modified the script a little for those running version 3.4 (like myself). One important thing is, as earlier mentioned, that no comments is allowed with '#'-marks.
Put your own values for the variables and don't forget to mark down your right interface or the piece of code for getting it from the original script.

:global ddnsuser "USER"
:global ddnspass "PWD"
:global ddnshost "my.dyn.ip"
:global ddnsip
:global ddnslastip [:tostr [:resolve $ddnshost] ]
:if ([ :typeof $ddnslastip ] = nil ) do={ :global ddnslastip "0" }
:global ddnsinterface "pppoe-out1"
:global ddnssystem ("mt-" . [/system package get system version] )

:local int

:local ddnsipfn [ /ip address get [/ip address find interface=$ddnsinterface ] address ]
:global ddnsip [:pick $ddnsipfn 0 [:find $ddnsipfn "/"]]

:if ([ :typeof $ddnsip ] = nil ) do={
:log info ("DDNS: No ip address present on " . $ddnsinterface . ", please check.")
} else={

:if ($ddnsip != $ddnslastip) do={

:log info "DDNS: Sending UPDATE!"
:log info [ :put [/tool dns-update name=$ddnshost address=$ddnsip key-name=$ddnsuser key=$ddnspass ] ]
:global ddnslastip $ddnsip

} else={
:log info "DDNS: No update required."
}

}


BTW, thanks for suggesting the ChangeIP.com!

Who is online

Users browsing this forum: No registered users and 12 guests