I want one to update the one gateway / interface and the other to do the other gateway / interface
What do I need to change in the scripts to specify which one to update?
Here is my script (Both are the same except for user and password)
# Set needed variables
:local username "username"
:local password "password"
:local hostname "hostname"
:global dyndnsForce
:global previousIP
# print some debug info
:log info ("UpdateDynDNS: username = $username")
:log info ("UpdateDynDNS: hostname = $hostname")
:log info ("UpdateDynDNS: previousIP = $previousIP")
# get the current IP address from the internet (in case of double-nat)
/tool fetch mode=http address="checkip.dyndns.org" src-path="/" dst-path="/dyndns.checkip.html"
:local result [/file get dyndns.checkip.html contents]
# parse the current IP result
:local resultLen [:len $result]
:local startLoc [:find $result ": " -1]
:set startLoc ($startLoc + 2)
:local endLoc [:find $result "</body>" -1]
:local currentIP [:pick $result $startLoc $endLoc]
:log info "UpdateDynDNS: currentIP = $currentIP"
# Remove the # on next line to force an update every single time - useful for debugging, but you could end up getting blacklisted by DynDNS!
#:set dyndnsForce true
# Determine if dyndns update is needed
# more dyndns updater request details available at http://www.dyndns.com/developers/specs/syntax.html
:if (($currentIP != $previousIP) || ($dyndnsForce = true)) do={
:set dyndnsForce false
:set previousIP $currentIP
/tool fetch user=$username password=$password mode=http address="members.dyndns.org" src-path="/nic/update?hostname=$hostname&myip=$currentIP" dst-path="/dyndns.txt"
:local result [/file get dyndns.txt contents]
:log info ("UpdateDynDNS: Dyndns update needed")
:log info ("UpdateDynDNS: Dyndns Update Result: ".$result)
:put ("Dyndns Update Result: ".$result)
} else={
:log info ("UpdateDynDNS: No dyndns update needed")
}
Maybe you can use two different addresses for fetching and route each thru the corresponding gateway. Then you will know both ip addresses. Or always change the routing before fetching. Then one address will be sufficient.
Remove the # on next line to force an update every single time - useful for debugging,
but you could end up getting blacklisted by DnsExit!
#:set dyndnsForce true
Determine if dyndns update is needed
more dyndns updater request details on DnsExit.com
:if (($currentIP != $previousIP) || ($dyndnsForce = true)) do={
:set dyndnsForce false
:log info “UpdateDnsExit: Current IP $currentIP”
:log info “UpdateDnsExit: Previous IP $previousIP”
:set previousIP $currentIP
/tool fetch mode=http address=“www.dnsexit.com”
src-path=“RemoteUpdate.sv?login=$username&password=$password&host=$hostname&myip=$currentIP”
dst-path=“usb1/dnsexit.txt” port=80 host=www.dnsexit.com:local result [/file get usb1/dnsexit.txt contents] #:log info “UpdateDnsExit: previousIP = $previousIP”
:log info (“DnsExit: DnsExit update needed”)
:log info ("UpdateDnsExit: DnsExit Update Result: ".$result)
:log info ("DnsExit Update Result: ".$result)
} else={
:log info (“UpdateDnsExit: No DnsExit update needed”)
}For you it can be similar or maybe just almost the same.
There is not important from what address I am changing the dns record, it is important which IP I am giving that should be linked to my domain. As you maybe cannot be sure what ip is really your external ip (in case of 1:1 NAT of your ISP), it is smart to ask some service to tell you what is my ip (how it does see you). So therefore I am asking the ip.dnsexit.com which gives you back an text file with your real external IP. Then I put this IP into the dns record. If I had more wans with dynamic IPs, I just need to ask thru first wan then trhu second wan and so on. So my way would be to have for this the special routing rule that will cycle the wans between each request.
parse the ip address, check if it changed and if so, make the dns update with “wan2.mydomain.tld”
and so on…
As ip.dnsexit.com can also change its ip address, I would make resolve of it first to be able to set static route to it according to my needs (step 0 above).
Unfortunatelly it needs to write a file - I did not managed to get the ip from the response without saving a file to disk.
then you just add the route for this destination trhu first gateway. You can name it a then you can use “set” to change the destination or the gateway as you need by your script according to the name…