├── LICENSE ├── README.md └── OVHDynDNS /LICENSE: -------------------------------------------------------------------------------- 1 | This is free and unencumbered software released into the public domain. 2 | 3 | Anyone is free to copy, modify, publish, use, compile, sell, or 4 | distribute this software, either in source code form or as a compiled 5 | binary, for any purpose, commercial or non-commercial, and by any 6 | means. 7 | 8 | In jurisdictions that recognize copyright laws, the author or authors 9 | of this software dedicate any and all copyright interest in the 10 | software to the public domain. We make this dedication for the benefit 11 | of the public at large and to the detriment of our heirs and 12 | successors. We intend this dedication to be an overt act of 13 | relinquishment in perpetuity of all present and future rights to this 14 | software under copyright law. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | For more information, please refer to 25 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | mikrotik-routeros-scripts 2 | ========================= 3 | My scripts for MikroTik RouterOS 4 | 5 | - [OVHDynDNS](#ovhdyndns) 6 | 7 | 8 | ## OVHDynDNS 9 | **OVH DynDNS Update Script for MikroTik RouterOS** 10 | 11 | This scrip updates your dynamic IP on your OVH dyndns record, when that IP address changes. This script works specifically for the DynDNS service hosted by OVH. 12 | 13 | First you need to create a user to manage access to your DynDNS subdomain. You can do this through your OVH control panel/manager. You will need those credentials for the scipt to work: 14 | 15 | :global ovhddnsuser "" 16 | :global ovhddnspass "" 17 | 18 | Further configuration settings require the interface name on your mikrotik router which holds your public IP. You will also need to specify your OVH DynDNS hostname (something like dynhost.mydomain.com). 19 | 20 | :global theinterface "" 21 | :global ovhddnshost "" 22 | 23 | Install the [script](OVHDynDNS) as 'ovhddns'. 24 | 25 | Define a sheduler to run every 30 minutes. You can lower the interval time, since the script only connects to OVH when your IP has changed. 26 | 27 | /system scheduler 28 | add interval=10m name=OVHDynDNS on-event="/system script run ovhddns" policy=read,write,test start-time=startup 29 | 30 | Thats it! 31 | 32 | Verify your routeros log and do a nslookup to check if everything is working as expected. 33 | 34 | ___ 35 | -------------------------------------------------------------------------------- /OVHDynDNS: -------------------------------------------------------------------------------- 1 | :global ovhddnsuser "" 2 | :global ovhddnspass "" 3 | :global theinterface "" 4 | :global ovhddnshost "" 5 | :global ipddns [:resolve $ovhddnshost] 6 | :global ipfresh [ /ip address get [/ip address find interface=$theinterface ] address ] 7 | :if ([ :typeof $ipfresh ] = nil ) do={ 8 | :log info ("OVHDynDNS: NO IP address on $theinterface") 9 | } else={ 10 | :for i from=( [:len $ipfresh] - 1) to=0 do={ 11 | :if ( [:pick $ipfresh $i] = "/") do={ 12 | :set ipfresh [:pick $ipfresh 0 $i] 13 | } 14 | } 15 | 16 | :if ($ipddns != $ipfresh) do={ 17 | :log info ("OVHDynDNS: $ovhddnshost DNS RECORD IP = $ipddns") 18 | :log info ("OVHDynDNS: $theinterface CURRENT IP = $ipfresh") 19 | :log info ("OVHDynDNS: UPDATING $ovhddnshost -> $ipfresh") 20 | :global str "nic/update?system=dyndns&hostname=$ovhddnshost&myip=$ipfresh&wildcard=OFF&backmx=NO&mx=NOCHG" 21 | 22 | # DEBUG fetch command 23 | #:log info ("OVHDynDNS: /tool fetch address=www.ovh.com host=www.ovh.com src-path=$str mode=https user=$ovhddnsuser password=$ovhddnspass dst-path=(\"/OVHDynDNS.$ovhddnshost\")") 24 | /tool fetch address=www.ovh.com host=www.ovh.com src-path=$str mode=https user=$ovhddnsuser password=$ovhddnspass dst-path=("/OVHDynDNS.".$ovhddnshost) 25 | :delay 1 26 | 27 | :global ovhresult [/file get "OVHDynDNS.$ovhddnshost" contents] 28 | :log info "OVHDynDNS: OVH response: $ovhresult" 29 | 30 | :global str [/file find name="OVHDynDNS.$ovhddnshost"] 31 | /file remove $str 32 | 33 | :if ($ovhresult = "good $ipfresh\n" ) do={ 34 | :log info "OVHDynDNS: SUCCESS" 35 | } else={ 36 | :log info "OVHDynDNS: FAILED" 37 | } 38 | 39 | :global ipddns $ipfresh 40 | :log info "OVHDynDNS: $ovhddnshost DNS RECORD = $ipfresh!" 41 | } else={ 42 | :log info "OVHDynDNS: We good!" 43 | } 44 | } 45 | --------------------------------------------------------------------------------