Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Implementation
- What we do here is check the IP on the interface in question every minute (less or more if you want) using the system scheduler. The main script included below keeps an internal record of the IP of the interface it is checking and if the IP is seen to change it send off an update.
- The other 2 scripts are to see what the system thinks the last known IP was, and to reset the know IP so as to force an update.
- ==DynDNS==
- # Define Variables
- :local ddnsuser "username"
- :local ddnspass "password"
- :local ddnshost "host.domain.name"
- :local ddnsinterface "interface name"
- :global ddnsip
- :global ddnslastip
- #Set empty to 0 value
- :if ([ :typeof $ddnslastip ] = nil ) do={ :global ddnslastip "0" }
- # Grab the current IP address on that interface.
- :global ddnsip [ /ip address get [/ip address find interface=$ddnsinterface ] address ]
- :local endloc [:find $ddnsip "/" -1]
- :set ddnsip [:pick $ddnsip 0 $endloc]
- # Did we get an IP address to compare?
- :if ([ :typeof $ddnsip ] = nil ) do={
- :log info ("DynDNS: No ip address present on " . $ddnsinterface . ", please check.")
- } else={
- :if ($ddnsip != $ddnslastip) do={
- :log info "Address Changed from $ddnslastip to $ddnsip"
- :log info "DynDNS: Sending UPDATE!"
- :local str "/nic/update?hostname=$ddnshost&myip=$ddnsip&wildcard=NOCHG&mx=NOCHG&backmx=NOCHG"
- /tool fetch address=members.dyndns.org src-path=$str mode=http user=$ddnsuser password=$ddnspass dst-path=("/DynDNS.".$ddnshost)
- :delay 1
- :local str [/file find name="DynDNS.$ddnshost"];
- /file remove $str
- :global ddnslastip $ddnsip
- }
- }
- ==DynInfo==
- :global ddnslastip
- :log info "IP was $ddnslastip"
- ==DynReset==
- :global ddnslastip "0"
- =======
- Add this line to the scheduler, called DynDNS, set the interval to 00:01:00, Start Date to Jan/01/1970 and allow all access in the policies.
- =======
- /system script run DynDNS
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement