Konstantin Antselovich » dns 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
BIND zone file creator http://pgl.yoyo.org/as/bind-zone-file-creator.php http://pgl.yoyo.org/as/bind-zone-file-creator.php#comments Sun, 27 May 2012 22:45:56 +0000 konstant1n http://www.delicious.com/url/8247459250ee869343a97bf9b1f2ce4a#konstant1n http://feeds.delicious.com/v2/rss/url/8247459250ee869343a97bf9b1f2ce4a 0 BIND zone file creator http://pgl.yoyo.org/as/bind-zone-file-creator.php http://pgl.yoyo.org/as/bind-zone-file-creator.php#comments Sun, 27 May 2012 22:45:56 +0000 konstant1n http://previous.delicious.com/url/8247459250ee869343a97bf9b1f2ce4a#konstant1n http://feeds.delicious.com/v2/rss/url/8247459250ee869343a97bf9b1f2ce4a 0 BIND zone file creator http://pgl.yoyo.org/as/bind-zone-file-creator.php http://pgl.yoyo.org/as/bind-zone-file-creator.php#comments Sun, 27 May 2012 22:45:56 +0000 konstant1n http://delicious.com/url/8247459250ee869343a97bf9b1f2ce4a#konstant1n http://feeds.delicious.com/v2/rss/url/8247459250ee869343a97bf9b1f2ce4a 0 Round-Robin DNS as Failover – LowEndTalk http://www.lowendtalk.com/questions/6032/round-robin-dns-as-failover http://www.lowendtalk.com/questions/6032/round-robin-dns-as-failover#comments Fri, 29 Apr 2011 22:11:03 +0000 konstant1n http://www.delicious.com/url/cc97cf54e52ed7573c75ba62b024b47b#konstant1n http://feeds.delicious.com/v2/rss/url/cc97cf54e52ed7573c75ba62b024b47b 0 Domain Names – Domain Name Registration – Management – Appraisals – Moniker SnapNames http://www.moniker.com/index.jsp http://www.moniker.com/index.jsp#comments Wed, 29 Dec 2010 20:58:13 +0000 konstant1n http://www.delicious.com/url/828fc9ae8687571c5e30331d95f39849#konstant1n http://feeds.delicious.com/v2/rss/url/828fc9ae8687571c5e30331d95f39849 0 Google over IPv6 http://www.google.com/intl/en/ipv6/ http://www.google.com/intl/en/ipv6/#comments Tue, 07 Dec 2010 08:39:29 +0000 konstant1n http://www.delicious.com/url/938af81f0c31a169283c5bfba13b88d9#konstant1n (i.e., google will reply with AAAA records on queries made from your DNS server)]]> http://feeds.delicious.com/v2/rss/url/938af81f0c31a169283c5bfba13b88d9 0 robtex- swiss army knife internet network information tool http://www.robtex.com/ http://www.robtex.com/#comments Thu, 18 Mar 2010 20:03:56 +0000 konstant1n http://www.delicious.com/url/bcdcfd54ffc4ac4d6b1af7803d3f9af7#konstant1n http://feeds.delicious.com/v2/rss/url/bcdcfd54ffc4ac4d6b1af7803d3f9af7 0 Sébastien Wains » CentOS 5 : chroot DNS with bind http://www.wains.be/index.php/2007/12/13/centos-5-chroot-dns-with-bind/ http://www.wains.be/index.php/2007/12/13/centos-5-chroot-dns-with-bind/#comments Wed, 18 Mar 2009 20:21:17 +0000 konstant1n http://www.delicious.com/url/09289a4972d70a6694c23cd9680ebc36#konstant1n http://feeds.delicious.com/v2/rss/url/09289a4972d70a6694c23cd9680ebc36 0