So, I figured it was simple enough, and I had some code to go on already, I'd thought I'd come out with another variation.
95% of this script is from others, so big thanks to them, I did work out the No-IP stuff that "should" work, and in the process of making it a more "general" script.
It's a work in progress (DO NOT stick this in your RB yet!), as you can see, I'm trying to design it for several DDNS providers, and allow multiple DDNS accounts (one per interface basically).
Personally, I just No-IP, and I need two interfaces to update, but I like to design things generally.
It's missing a loop for the "accounts" and tieing settings to an interface (/account), ddnsip and ddnslastip also need to be interface/account specific.
I'll look around the wiki for further syntax information to see if I can work out what to do, any pointers are welcome, didn't really expect to have to learn RB scripting for DDNS, figured there would be a package or it part of the main package. I know, somehow at the back is going to shout "make one yourself", err... let's see how I go with this first!
For those curious (DON'T put this in your RB, it's unfinished and doesn't work!)
Code: Select all
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# EDIT YOUR DETAILS / CONFIGURATION HERE
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Define DDNS Accounts for RB Interfaces, one per interface.
# The RB interface
:global ddnsinterface "ether1"
# The DDNS Provider (Choice of NOIP, DYNDNS or EVERYDNS)
:global ddnsprovider "NOIP"
# The Hostname to update.
:global ddnshost "NOIPHOST"
# Your Account Username
:global ddnsuser "NOIPUSER"
# Your Account Password
:global ddnspass "NOIPPASS"
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# END OF USER DEFINED CONFIGURATION
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Define Global Variables
:global ddnssystem ("mt-" . [/system package get system version] )
:global ddnsip
:global ddnslastip
:if ([ :typeof $ddnslastip ] = nil ) do={ :global ddnslastip "0" }
:if ($ddnsprovider = "NOIP") do={
:global $ddnsprovname "NoIP"
:global str "/nic/update?hostname=$ddnshost&myip=$ddnsip"
:global $ddnsprovaddress "dynupdate.no-ip.com"
} elseif ($ddnsprovider = "DYNDNS") do={
:global $ddnsprovname "DynDNS"
:global str "/nic/update?hostname=$ddnshost&myip=$ddnsip&wildcard=NOCHG&mx=NOCHG&backmx=NOCHG"
:global $ddnsprovaddress "members.dyndns.org"
} elseif ($ddnsprovider = "EVERYDNS") do={
:global $ddnsprovname "EveryDNS"
:global str "/index.php?ver=0.1&ip=$ddnsip&domain=$ddnshost"
:global $ddnsprovaddress "dyn.everydns.net"
}
# 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 ("NoIP: No ip address present on " . $ddnsinterface . ", please check.")
} else={
:if ($ddnsip != $ddnslastip) do={
:log info $ddnsprovname.": Sending UPDATE!"
/tool fetch address=$ddnsprovaddress src-path=$str mode=http user=$ddnsuser password=$ddnspass dst-path=("/DDNS-".$ddnsprovname.".".$ddnshost)
}
:delay 1
:local str [/file find name="$ddnsprovider.$ddnshost"];
/file remove $str
:global ddnslastip $ddnsip
}
}