<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>DNS | DCMST</title><link>https://portfolio.devcrumbs.com/tag/dns/</link><atom:link href="https://portfolio.devcrumbs.com/tag/dns/index.xml" rel="self" type="application/rss+xml"/><description>DNS</description><generator>Wowchemy (https://wowchemy.com)</generator><language>en-us</language><lastBuildDate>Mon, 11 Apr 2016 00:00:00 +0000</lastBuildDate><image><url>https://portfolio.devcrumbs.com/media/icon_hu28290437db960aa4e7d19bb9f7230401_6937_512x512_fill_lanczos_center_3.png</url><title>DNS</title><link>https://portfolio.devcrumbs.com/tag/dns/</link></image><item><title> Build a Dynamic DNS Client with Rackspace API</title><link>https://portfolio.devcrumbs.com/build-a-dynamc-dns-client-with-rackspace-api/</link><pubDate>Mon, 11 Apr 2016 00:00:00 +0000</pubDate><guid>https://portfolio.devcrumbs.com/build-a-dynamc-dns-client-with-rackspace-api/</guid><description>&lt;p>This time I&amp;rsquo;ve want to create a homemade Server with my Raspberry Pi2 and publish it using my own sub-domain,
the main problem is that the ISP provide me an dynamic IP and we should ensure that if my IP address change the sub-domain record should point to the new IP.&lt;/p>
&lt;p>The instructions assume that you:&lt;/p>
&lt;ul>
&lt;li>
&lt;p>Have a domain&lt;/p>
&lt;/li>
&lt;li>
&lt;p>Have already changed your NS records to point to dns1.stabletransit.com and dns2.stabletransit.com.&lt;/p>
&lt;/li>
&lt;/ul>
&lt;ol>
&lt;li>
&lt;p>You should download the latest version of rsdns from github&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">&lt;span class="nb">cd&lt;/span> ~/bin/
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">git clone https://github.com/linickx/rsdns.git
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;/li>
&lt;li>
&lt;p>Go to your Rackspace portal &lt;a href="https://login.rackspace.com/" target="_blank" rel="noopener">https://login.rackspace.com/&lt;/a> and grab your Username &amp;amp; API key (It&amp;rsquo;s under &amp;ldquo;Your Account&amp;rdquo; -&amp;gt; &amp;ldquo;Account Settings&amp;rdquo; -&amp;gt; &amp;ldquo;API Key&amp;rdquo;)&lt;/p>
&lt;/li>
&lt;li>
&lt;p>Create a configuration file for rsdns (~/.rsdns_config) with your settings.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">&lt;span class="cp">#!/bin/bash
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="cp">&lt;/span>&lt;span class="nv">RSUSER&lt;/span>&lt;span class="o">=&lt;/span>dcmst
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="nv">RSAPIKEY&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="m">1234567890&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="nv">RSPATH&lt;/span>&lt;span class="o">=&lt;/span>~/bin/rsdns/
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;/li>
&lt;li>
&lt;p>You need your domain created on Rackspace(It&amp;rsquo;s under &amp;ldquo;Networking&amp;rdquo; -&amp;gt; &amp;ldquo;Cloud DNS&amp;rdquo; -&amp;gt; &amp;ldquo;Create Domain&amp;rdquo;) if you don&amp;rsquo;t have your domain created you are able to created using rsdns:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">./rsdns-domain.sh -d www.d-cmst.io -e dcmst@devcrumbs.com
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;/li>
&lt;li>
&lt;p>Once you have a domain setup you need to create an A record.
To create the A record you going to need an IP address, you can use &lt;a href="http://icanhazip.com" target="_blank" rel="noopener">http://icanhazip.com&lt;/a> to get your actual current IP.
Again to create a record you are able to do it from Rackspace panel (It&amp;rsquo;s under &amp;ldquo;Networking&amp;rdquo; -&amp;gt; &amp;ldquo;Cloud DNS&amp;rdquo; -&amp;gt; YOUR_DOMAIN -&amp;gt; &amp;ldquo;Add Record&amp;rdquo;) or you can use rsdns:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">./rsdns-a.sh -n dynamic-host.d-cmst.io -i 123.123.123.123 -t &lt;span class="m">3600&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>In the above the TTL is set to 1hr (3600 secs), this is so that DNS caches do not keep the record too long. That&amp;rsquo;s all the pre-work done, now lets get your dynamic host setup!&lt;/p>
&lt;/li>
&lt;li>
&lt;p>The script to update your a record is rsdns-dc.sh, and you run it like this:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">./rsdns-dc.sh -n dynamic-host.d-cmst.io
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>The script uses icanhazip to get your current IP, it then update the A record with it.&lt;/p>
&lt;p>I never switch off my router so I have create a created a cronjob to run that script every 2 hours,
plus the 1hr TTL should mean that the record is roughly in sync with my IP without making unnecessary requests&lt;/p>
&lt;/li>
&lt;li>
&lt;p>I use CentOS, so I can simply drop the following file called rsdns-dc into /etc/cron.d/ with this&amp;hellip;&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">vim /etc/cron.d/rsdns-dc
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">* */2 * * * dcmst /home/dcmst/bin/rsdns/rsdns-dc.sh -n dynamic-host.d-cmst.io &lt;span class="p">&amp;amp;&lt;/span>&amp;gt;/dev/null
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;/li>
&lt;/ol>
&lt;p>Now we are done! Private Dynamic DNS on your own zone using the Rackspace API.&lt;/p></description></item></channel></rss>