I have modified ChangeIP's Dynamic DNS script a bit, this script does a couple of things differently to the stock ChangeIP script.
This script assumes you have two or three ppp interfaces on your RouterBOARD (ppp-local, ppp-international and / or ppp-3g - for people using the new RB751 with a 3G USB Stick and an unrestricted APN)
First it checks if ppp-local is connected, if it is it will update ChangeIP with ppp-local's IP,
if not it checks if ppp-international is connected, if it is it will update ChangeIP with ppp-international's IP,
if not if checks if ppp-3g exists, if it does exist it checks if ppp-3g is connected, if it is it will update ChangeIP with ppp-3g's IP,
if not it will log an error "None of your interfaces are currently Dialled Out",
if ppp-3g doesn't exist it will log an error "DDNS: $ddnsinterface3g Interface doesn't exist and PPPoE Interfaces are Disconnected!"
I will still make this prettier at some point for now it seems to work though.
# Define User Variables
:global ddnsuser <USERNAME>
:global ddnspass <PASSWORD>
:global ddnshost <HOST>
:global ddnsinterface ppp-local
:global ddnsinterfacelcl ppp-local
:global ddnsinterfaceint ppp-international
:global ddnsinterface3g ppp-3g
# Detect Active Interface
/interface pppoe-client monitor $ddnsinterfacelcl once do={
:if ($status != "connected") do={
/interface pppoe-client monitor $ddnsinterfaceint once do={
:if ($status = "connected") do={
:global ddnsinterface $ddnsinterfaceint
} else={
:if ([/interface find name=$ddnsinterface3g] = "") do={
:log error "DDNS: $ddnsinterface3g Interface doesn't exist and PPPoE Interfaces are Disconnected!";
:error;
} else={
/interface pppoe-client monitor $ddnsinterface3g once do={
:if ($status = "connected") do={
:global ddnsinterface $ddnsinterface3g
} else={
:log error "DDNS: None of your interfaces are currently Dialled Out!";
:error;
}
}
}
}
}
}
}
# Define Global Variables
:global ddnssystem ("mt-" . [/system package get [/system package find name=system] version] )
:global ddnsip [ /ip address get [/ip address find interface=$ddnsinterface] address ]
:global ddnslastip
:if ([:len [/interface find name=$ddnsinterface]] = 0 ) do={ :log info "DDNS: No interface named $ddnsinterface, please check configuration." }
:if ([ :typeof $ddnslastip ] = "nothing" ) do={ :global ddnslastip 0.0.0.0/0 }
:if ([ :typeof $ddnsip ] = "nothing" ) 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 changes necessary."
}
}
# END OF SCRIPT