Dyndns script problem with auth

Hello

i want to use dyndns script to update one of my clients mikrotik router.

the problem is, when i run the script, i get an error of auth failed.

this is because clients username is “username@gmail.com

so with the fetch command, i have problem with the “@” symbol.

Any idea how to make it work???

Thanks…

Try encoding the url. Replace @ with %40

@ is not allowed in a url. Browsers and web servers may allow it but will encode the url before sending it to the server.

More info on URL encoding:
https://en.wikipedia.org/wiki/Percent-encoding

I tried it but i have the same error: badauth

the script i user is:

# Set needed variables
:local username "user@gmail.com"
:local password "password"
:local hostname "host.dyndns.org"

: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")
}

any ideas please???

I found this on dyndns’ website:

http://username:password@members.dyndns.org/nic/update?hostname=yourhostname&myip=ipaddress&wildcard=NOCHG&mx=NOCHG&backmx=NOCHG

if you use fetch user=$username password=$password then I don’t think it builds the url as seen above. I think it’ll use a www-authenticate header in the http get request.

So try this where username is in encoded format: user%40domain.com

/tool fetch url=“http://$username:$password@members.dyndns.org/nic/update?hostname=$yourhostname&myip=$currentIP&wildcard=NOCHG&mx=NOCHG&backmx=NOCHG” mode=http dst-path=“/dyndns.txt”

Or test this in a browser with your user, pass, hostname and IP.

thank you for the answer but even with this i have again the same error: “badauth”

Another user has a similar issue, found it to be an issue with the recent firmware. See this post:
http://forum.mikrotik.com/t/6-30-rc-final-fixes-before-release/89112/1