Add script by telnet
Posted: Mon Mar 09, 2015 5:37 pm
Hello! I'm trying to add this script by telnet (I only have activate telnet in the router). I toke the script from this site http://wiki.mikrotik.com/wiki/Dynamic_D ... behind_NAT. When I add the script it appears like Invalid, so it doesn't work and I don't know why. Ideas? Thanks for your time!
/system script
add name=OpenDNS policy=write,read,test,policy source="#\r\
\n# DNSoMatic automatic DNS updates\r\
\n#--------------- Change Values in this section to match your setup ------------------\r\
\n# User account info of DNSoMatic\r\
\n:local maticuser \"honorato.daniel@gmail.com\"\r\
\n:local maticpass \"***************\"\r\
\n# Set the hostname or label of network to be updated. This is the part after the double colon (::) on the DNSoMatic services page.\r\
\n# Hostnames with spaces are unsupported. Replace the value in the quotations below with your host names.\r\
\n# To specify multiple hosts, separate them with commas. \r\
\n# Use \"all.dnsomatic.com\" for the matichost to update all items in dnsomatic with this IP.\r\
\n:local matichost \"all.dnsomatic\"\r\
\n#------------------------------------------------------------------------------------\r\
\n# No more changes need\r\
\n:global previousIP;\r\
\n:log info \"Fetching current IP\"\r\
\n# Get the current public IP using DNS-O-Matic service.\r\
\n/tool fetch url=\"http://myip.dnsomatic.com/\" mode=http dst-path=mypublicip.txt\r\
\n# Read the current public IP into the currentIP variable.\r\
\n:local currentIP [/file get mypublicip.txt contents]\r\
\n:log info \"Fetched current IP as $currentIP\"\r\
\n \r\
\n:if ($currentIP != $previousIP) do={\r\
\n :log info \"DNSoMatic: Update needed\"\r\
\n :set previousIP $currentIP \r\
\n# The update URL. Note the \"\3F\" is hex for question mark. Required since is a special character in commands.\r\
\n :local url \"http://updates.dnsomatic.com/nic/update ... =NOCHG\"\r\
\n :local matichostarray;\r\
\n :set matichostarray [:toarray $matichost];\r\
\n :foreach host in=$matichostarray do={\r\
\n :log info \"DNSoMatic: Sending update for $host\"\r\
\n /tool fetch url=($url . \"&hostname=$host\") user=$maticuser password=$maticpass mode=http dst-path=(\"dnsomaticupdate-\" . $host . \".txt\")\r\
\n :log info \"DNSoMatic: Host $host updated on DNSoMatic with IP $currentIP\"\r\
\n }\r\
\n} else={\r\
\n :log info \"DNSoMatic: Previous IP $previousIP and current IP equal, no update need\"\r\
\n}
/system script
add name=OpenDNS policy=write,read,test,policy source="#\r\
\n# DNSoMatic automatic DNS updates\r\
\n#--------------- Change Values in this section to match your setup ------------------\r\
\n# User account info of DNSoMatic\r\
\n:local maticuser \"honorato.daniel@gmail.com\"\r\
\n:local maticpass \"***************\"\r\
\n# Set the hostname or label of network to be updated. This is the part after the double colon (::) on the DNSoMatic services page.\r\
\n# Hostnames with spaces are unsupported. Replace the value in the quotations below with your host names.\r\
\n# To specify multiple hosts, separate them with commas. \r\
\n# Use \"all.dnsomatic.com\" for the matichost to update all items in dnsomatic with this IP.\r\
\n:local matichost \"all.dnsomatic\"\r\
\n#------------------------------------------------------------------------------------\r\
\n# No more changes need\r\
\n:global previousIP;\r\
\n:log info \"Fetching current IP\"\r\
\n# Get the current public IP using DNS-O-Matic service.\r\
\n/tool fetch url=\"http://myip.dnsomatic.com/\" mode=http dst-path=mypublicip.txt\r\
\n# Read the current public IP into the currentIP variable.\r\
\n:local currentIP [/file get mypublicip.txt contents]\r\
\n:log info \"Fetched current IP as $currentIP\"\r\
\n \r\
\n:if ($currentIP != $previousIP) do={\r\
\n :log info \"DNSoMatic: Update needed\"\r\
\n :set previousIP $currentIP \r\
\n# The update URL. Note the \"\3F\" is hex for question mark. Required since is a special character in commands.\r\
\n :local url \"http://updates.dnsomatic.com/nic/update ... =NOCHG\"\r\
\n :local matichostarray;\r\
\n :set matichostarray [:toarray $matichost];\r\
\n :foreach host in=$matichostarray do={\r\
\n :log info \"DNSoMatic: Sending update for $host\"\r\
\n /tool fetch url=($url . \"&hostname=$host\") user=$maticuser password=$maticpass mode=http dst-path=(\"dnsomaticupdate-\" . $host . \".txt\")\r\
\n :log info \"DNSoMatic: Host $host updated on DNSoMatic with IP $currentIP\"\r\
\n }\r\
\n} else={\r\
\n :log info \"DNSoMatic: Previous IP $previousIP and current IP equal, no update need\"\r\
\n}