Konstantin Antselovich » computer 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
How to replace or upgrade memory in Dell Latitude D830, D820 notebook >> Inside my laptop http://www.insidemylaptop.com/replace-upgrade-memory-ram-in-dell-latitude-d830-notebook/ http://www.insidemylaptop.com/replace-upgrade-memory-ram-in-dell-latitude-d830-notebook/#comments Sun, 24 Jul 2011 01:00:33 +0000 konstant1n http://www.delicious.com/url/d1e233a59e170881362ed0bbc59e519d#konstant1n http://feeds.delicious.com/v2/rss/url/d1e233a59e170881362ed0bbc59e519d 0 How to replace or upgrade memory in Dell Latitude D830, D820 notebook >> Inside my laptop http://www.insidemylaptop.com/replace-upgrade-memory-ram-in-dell-latitude-d830-notebook/ http://www.insidemylaptop.com/replace-upgrade-memory-ram-in-dell-latitude-d830-notebook/#comments Sun, 24 Jul 2011 01:00:33 +0000 konstant1n http://wwwav.delicious.com/url/d1e233a59e170881362ed0bbc59e519d#konstant1n http://feeds.delicious.com/v2/rss/url/d1e233a59e170881362ed0bbc59e519d 0 Cowboy Frank’s Webcam Reviews http://cowboyfrank.net/webcams/ http://cowboyfrank.net/webcams/#comments Fri, 20 Aug 2010 18:27:12 +0000 konstant1n http://www.delicious.com/url/b3dc5def082bc48c236ca72fca370841#konstant1n http://feeds.delicious.com/v2/rss/url/b3dc5def082bc48c236ca72fca370841 0 [x86 booting] How Computers Boot Up http://duartes.org/gustavo/blog/post/how-computers-boot-up http://duartes.org/gustavo/blog/post/how-computers-boot-up#comments Wed, 23 Jul 2008 07:30:52 +0000 konstant1n http://www.delicious.com/url/0bbff70c4f2f1e7cbd3e6dd5bbf645aa#konstant1n http://feeds.delicious.com/v2/rss/url/0bbff70c4f2f1e7cbd3e6dd5bbf645aa 0 storm-leet08.pdf (application/pdf Object) Measurements and Mitigation of Peer-to-Peer-based Botnets: http://www.honeyblog.org/junkyard/paper/storm-leet08.pdf http://www.honeyblog.org/junkyard/paper/storm-leet08.pdf#comments Fri, 25 Apr 2008 19:00:03 +0000 konstant1n http://www.delicious.com/url/bc3779ebcbdf6927e33f9b9a494014aa#konstant1n http://feeds.delicious.com/v2/rss/url/bc3779ebcbdf6927e33f9b9a494014aa 0 malware_biz.pdf (application/pdf Object) http://www.cs.auckland.ac.nz/~pgut001/pubs/malware_biz.pdf http://www.cs.auckland.ac.nz/~pgut001/pubs/malware_biz.pdf#comments Thu, 17 Apr 2008 05:47:08 +0000 konstant1n http://www.delicious.com/url/213ca6d1018e3a454d4a4e73f2b47f63#konstant1n http://feeds.delicious.com/v2/rss/url/213ca6d1018e3a454d4a4e73f2b47f63 0 STSC CrossTalk – Computer Science Education: Where Are the Software Engineers of Tomorrow? – Jan 2008 http://www.stsc.hill.af.mil/CrossTalk/2008/01/0801DewarSchonberg.html http://www.stsc.hill.af.mil/CrossTalk/2008/01/0801DewarSchonberg.html#comments Tue, 08 Jan 2008 20:00:17 +0000 konstant1n http://www.delicious.com/url/eac4d92c568231c00901d06e142547e8#konstant1n http://feeds.delicious.com/v2/rss/url/eac4d92c568231c00901d06e142547e8 0