Konstantin Antselovich » api http://konstantin.antselovich.com random generator Wed, 25 Feb 2015 01:21:33 +0000 en hourly 1 http://wordpress.org/?v=3.1 Mikrotik + ClouldFlare = DynDNS http://konstant1n.livejournal.com/9759.html http://konstant1n.livejournal.com/9759.html#comments Sun, 06 Oct 2013 20:32:10 +0000 Random Journal http://konstant1n.livejournal.com/9759.html

I got fed up with free service from DynDNS: your record will disappear in 30 days unless you login into their site and "confirm" it. DynDNS annoys you on purpose, so you buy their "pro" service. I do not like being annoyed, and I do not see a point of paying for DynDNS service -- their value proposition is weak, as anyone can create a script that updates DNS records.

I have a website that is protected by ClouldFlare service. ClouldFlare offers an API that can be used to update DNS records, so I wrote a script for Mikrotik RouterOS that does just that.



Note that you need RouterOS v6 ( as fetch command supports https only since version 6.0rc12


##############Script Settings##################

:local CFemail "clouldflare email login "
:local CFtkn "api access token"
:local CFzone "clouldflare website, example: example.com"
:local CFid "dns record id, available via rec_load_all API call, example: 12345"
:local CFtype "A"
:local CFttl "300"
:local CFservicemode "0"
:local CFDomain "FQDN DNS record that you will be updating, example: myhomeip.exmaple.com"

############## Build CF API Url ################
:local CFurl "https://www.cloudflare.com/api_json.html\3F"
:set CFurl ($CFurl . "a=rec_edit&tkn=$CFtkn&id=$CFid");
:set CFurl ($CFurl . "&email=$CFemail&z=$CFzone&type=$CFtype");
:set CFurl ($CFurl . "&name=$CFDomain&service_mode=$CFservicemode&ttl=$CFttl");

:local WANInter "name of the outing network interface on mikrotik router, example: ether1-gateway"

###############################################

:local IpCurrent [/ip address get [find interface=$WANInter] address];
:for i from=( [:len $IpCurrent] - 1) to=0 do={
:if ( [:pick $IpCurrent $i] = "/") do={
:local NewIP [:pick $IpCurrent 0 $i];
:if ([:resolve $CFDomain] != $NewIP) do={
:log info "Will update: $NewIP"
/tool fetch mode=https url="$CFurl&content=$NewIP" keep-result=no
:log info "CF Update: $CFDomain - $NewIP"
}
}
}





http://www.cloudflare.com/docs/client-api.html
http://wiki.mikrotik.com/wiki/Manual:Scripting]]>
http://konstantin.antselovich.com/archives/2013/10/06/mikrotik-clouldflare-dyndns/feed/ 0
Mikrotik + ClouldFlare = DynDNS https://konstant1n.livejournal.com/9759.html https://konstant1n.livejournal.com/9759.html#comments Sun, 06 Oct 2013 20:32:10 +0000 konstant1n https://konstant1n.livejournal.com/9759.html

I got fed up with free service from DynDNS: your record will disappear in 30 days unless you login into their site and "confirm" it. DynDNS annoys you on purpose, so you buy their "pro" service. I do not like being annoyed, and I do not see a point of paying for DynDNS service -- their value proposition is weak, as anyone can create a script that updates DNS records.

I have a website that is protected by ClouldFlare service. ClouldFlare offers an API that can be used to update DNS records, so I wrote a script for Mikrotik RouterOS that does just that.



Note that you need RouterOS v6 ( as fetch command supports https only since version 6.0rc12


##############Script Settings##################

:local CFemail "clouldflare email login "
:local CFtkn "api access token"
:local CFzone "clouldflare website, example: example.com"
:local CFid "dns record id, available via rec_load_all API call, example: 12345"
:local CFtype "A"
:local CFttl "300"
:local CFservicemode "0"
:local CFDomain "FQDN DNS record that you will be updating, example: myhomeip.exmaple.com"

############## Build CF API Url ################
:local CFurl "https://www.cloudflare.com/api_json.html\3F"
:set CFurl ($CFurl . "a=rec_edit&tkn=$CFtkn&id=$CFid");
:set CFurl ($CFurl . "&email=$CFemail&z=$CFzone&type=$CFtype");
:set CFurl ($CFurl . "&name=$CFDomain&service_mode=$CFservicemode&ttl=$CFttl");

:local WANInter "name of the outing network interface on mikrotik router, example: ether1-gateway"

###############################################

:local IpCurrent [/ip address get [find interface=$WANInter] address];
:for i from=( [:len $IpCurrent] - 1) to=0 do={
:if ( [:pick $IpCurrent $i] = "/") do={
:local NewIP [:pick $IpCurrent 0 $i];
:if ([:resolve $CFDomain] != $NewIP) do={
:log info "Will update: $NewIP"
/tool fetch mode=https url="$CFurl&content=$NewIP" keep-result=no
:log info "CF Update: $CFDomain - $NewIP"
}
}
}





http://www.cloudflare.com/docs/client-api.html
http://wiki.mikrotik.com/wiki/Manual:Scripting]]>
http://konstantin.antselovich.com/archives/2013/10/06/mikrotik-clouldflare-dyndns-2/feed/ 0
libgit2: a linkable library for Git http://libgit2.github.com/ http://libgit2.github.com/#comments Thu, 02 Dec 2010 20:28:09 +0000 konstant1n http://www.delicious.com/url/e1da8bd3f281c59099a6e02e0ab6cee1#konstant1n http://feeds.delicious.com/v2/rss/url/e1da8bd3f281c59099a6e02e0ab6cee1 0 IBM developerWorks : Linux : Technical library view: Kernel APIs articles http://www.ibm.com/developerworks/views/linux/libraryview.jsp?site_id=1&contentarea_by=Linux&sort_by=Date&sort_order=1&start=1&end=3&topic_by=-1&product_by=&type_by=Articles&show_abstract=true&search_by=kernel%20apis, http://www.ibm.com/developerworks/views/linux/libraryview.jsp?site_id=1&contentarea_by=Linux&sort_by=Date&sort_order=1&start=1&end=3&topic_by=-1&product_by=&type_by=Articles&show_abstract=true&search_by=kernel%20apis,#comments Tue, 11 May 2010 17:04:22 +0000 konstant1n http://www.delicious.com/url/bf291fd89560d696fc6f3eead0918d8c#konstant1n http://feeds.delicious.com/v2/rss/url/bf291fd89560d696fc6f3eead0918d8c 0 Anatomy of the libvirt virtualization library http://www.ibm.com/developerworks/linux/library/l-libvirt/index.html http://www.ibm.com/developerworks/linux/library/l-libvirt/index.html#comments Thu, 14 Jan 2010 19:34:39 +0000 konstant1n http://www.delicious.com/url/26f0e98d21dab2faba60122f47a3e25e#konstant1n http://feeds.delicious.com/v2/rss/url/26f0e98d21dab2faba60122f47a3e25e 0