<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>PMA Media Group&#187; Powerdns</title>
	<atom:link href="http://www.pmamediagroup.com/tag/powerdns/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.pmamediagroup.com</link>
	<description>Unique Marketing Techniques and Strategies with Guaranteed Results!</description>
	<lastBuildDate>Thu, 29 Jul 2010 15:34:44 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Setting PowerDNS To Ignore Records For Downed Web Sites</title>
		<link>http://www.pmamediagroup.com/2009/06/setting-powerdns-to-ignore-records-for-downed-web-sites/</link>
		<comments>http://www.pmamediagroup.com/2009/06/setting-powerdns-to-ignore-records-for-downed-web-sites/#comments</comments>
		<pubDate>Wed, 10 Jun 2009 23:15:03 +0000</pubDate>
		<dc:creator>Aaron Murphy</dc:creator>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Daemon]]></category>
		<category><![CDATA[gmysql]]></category>
		<category><![CDATA[Powerdns]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.pmamediagroup.com/?p=591</guid>
		<description><![CDATA[If you are using PowerDNS for round robin on multiple websites, you can set it up so that it will return only the records for sites that are up. I set up a Ruby daemon to monitor sites and connect to the PowerDNS MySQL table used by PowerDNS on Rails. You can use any language [...]]]></description>
			<content:encoded><![CDATA[<p>If you are using <a href="http://www.powerdns.com/">PowerDNS</a> for round robin on multiple websites, you can set it up so that it will return only the records for sites that are up. I set up a Ruby daemon to monitor sites and connect to the PowerDNS <a href="http://www.mysql.com/">MySQL</a> table used by <a href="http://kennethkalmer.github.com/powerdns-on-rails/">PowerDNS on Rails</a>. You can use any language or system you like. It just needs to be able to access your PowerDNS database.<span id="more-591"></span></p>
<p>First add the following line to /etc/powerdns/pdns.conf:</p>

<div class="wp_syntax"><div class="code"><pre class="vim" style="font-family:monospace;"> gmysql<span style="color: #000000;">-</span>any<span style="color: #000000;">-</span>query=select content,ttl,prio,<span style="color: #25BB4D;">type</span>,domain_id,name from records where name=<span style="color: #C5A22D;">'%s'</span> and <span style="color: #000000;">&#40;</span>prio<span style="color: #000000;">&lt;&gt;-</span><span style="color: #000000; font-weight:bold;">1</span> or prio is null<span style="color: #000000;">&#41;</span></pre></div></div>

<p>Thats the trickiest part. If you mess up on the sql query, PowerDNS may not return any results for your domain.<br />
Then restart pdns. I use CentOS so I type</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">service pdns restart</pre></div></div>

<p>Now you just need a daemon to monitor your websites. Something like the following might work for you:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#008000; font-style:italic;">#!/usr/bin/env ruby</span>
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'net/http'</span>
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'rubygems'</span>
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'activerecord'</span>
&nbsp;
SITE_ADDRESSES = <span style="color:#006600; font-weight:bold;">%</span>w<span style="color:#006600; font-weight:bold;">&#40;</span> www.<span style="color:#9900CC;">yourdomain</span>.<span style="color:#9900CC;">com</span> www.<span style="color:#9900CC;">example</span>.<span style="color:#9900CC;">com</span> <span style="color:#006600; font-weight:bold;">&#41;</span>
SITE_THAT_IS_ALWAYS_UP = <span style="color:#996600;">&quot;&quot;</span> <span style="color:#008000; font-style:italic;"># some well known site that is always up</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">class</span> Record <span style="color:#006600; font-weight:bold;">&lt;</span> <span style="color:#6666ff; font-weight:bold;">ActiveRecord::Base</span>
  <span style="color:#6666ff; font-weight:bold;">ActiveRecord::Base</span>.<span style="color:#9900CC;">establish_connection</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:adapter</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;mysql&quot;</span>,
    <span style="color:#ff3333; font-weight:bold;">:encoding</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;utf8&quot;</span>, <span style="color:#ff3333; font-weight:bold;">:database</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;powerdns_production&quot;</span>,
    <span style="color:#ff3333; font-weight:bold;">:username</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;your_mysql_username&quot;</span>, <span style="color:#ff3333; font-weight:bold;">:password</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;your_secret_password_here&quot;</span>,
    <span style="color:#ff3333; font-weight:bold;">:host</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;ns1.your_isp.com&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  set_inheritance_column <span style="color:#ff3333; font-weight:bold;">:ruby_type</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#ff6633; font-weight:bold;">$running</span> = <span style="color:#0000FF; font-weight:bold;">true</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">def</span> signal_trap_exit<span style="color:#006600; font-weight:bold;">&#40;</span>signal_name<span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;#{Time.now} received #{signal_name} signal&quot;</span>
  <span style="color:#ff6633; font-weight:bold;">$running</span> = <span style="color:#0000FF; font-weight:bold;">false</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
our_exit_signals = <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;TERM&quot;</span>, <span style="color:#996600;">&quot;INT&quot;</span>, <span style="color:#996600;">&quot;KILL&quot;</span>, <span style="color:#996600;">&quot;HUP&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span>
<span style="color:#9966CC; font-weight:bold;">for</span> exit_signal_name <span style="color:#9966CC; font-weight:bold;">in</span> our_exit_signals
  <span style="color:#CC00FF; font-weight:bold;">Signal</span>.<span style="color:#CC0066; font-weight:bold;">trap</span><span style="color:#006600; font-weight:bold;">&#40;</span>exit_signal_name, <span style="color:#996600;">&quot;signal_trap_exit('#{exit_signal_name}')&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">def</span> check_internet
  <span style="color:#9966CC; font-weight:bold;">begin</span>
    Timeout::timeout<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006666;">5</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">do</span>
      <span style="color:#6666ff; font-weight:bold;">Net::HTTP</span>.<span style="color:#9900CC;">get_response</span><span style="color:#006600; font-weight:bold;">&#40;</span>SITE_THAT_IS_ALWAYS_UP, <span style="color:#996600;">&quot;/&quot;</span>, <span style="color:#006666;">80</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>response<span style="color:#006600; font-weight:bold;">|</span>
        <span style="color:#0000FF; font-weight:bold;">return</span> response.<span style="color:#9900CC;">code</span>.<span style="color:#9900CC;">match</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">/</span><span style="color:#006666;">2</span><span style="color:#006600; font-weight:bold;">|</span><span style="color:#006666;">3</span>\d<span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006666;">2</span><span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">/</span><span style="color:#006600; font-weight:bold;">&#41;</span>
      <span style="color:#9966CC; font-weight:bold;">end</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
  <span style="color:#9966CC; font-weight:bold;">rescue</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> e
    <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;#{Time.now} Error connecting to internet: #{e}&quot;</span>
    <span style="color:#0000FF; font-weight:bold;">return</span> <span style="color:#0000FF; font-weight:bold;">false</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">def</span> get_site_ip_addresses
  <span style="color:#9966CC; font-weight:bold;">begin</span>
    Record.<span style="color:#9900CC;">find</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:all</span>, <span style="color:#ff3333; font-weight:bold;">:conditions</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;type = ? and name in (?)&quot;</span>, <span style="color:#996600;">&quot;A&quot;</span>, SITE_ADDRESSES<span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#9966CC; font-weight:bold;">rescue</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> e
    <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;#{Time.now} Error finding all records: #{e}&quot;</span>
    <span style="color:#0000FF; font-weight:bold;">return</span> <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006600; font-weight:bold;">&#93;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">def</span> make_inactive<span style="color:#006600; font-weight:bold;">&#40;</span>ip_record<span style="color:#006600; font-weight:bold;">&#41;</span>
  Record.<span style="color:#9900CC;">update_all</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;prio=-1&quot;</span>, <span style="color:#996600;">&quot;name='#{ip_record.name}' and content='#{ip_record.content}'&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">def</span> make_active<span style="color:#006600; font-weight:bold;">&#40;</span>ip_record<span style="color:#006600; font-weight:bold;">&#41;</span>
  Record.<span style="color:#9900CC;">update_all</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;prio=1&quot;</span>, <span style="color:#996600;">&quot;name='#{ip_record.name}' and content='#{ip_record.content}'&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">while</span><span style="color:#006600; font-weight:bold;">&#40;</span>$running<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">do</span>
  get_site_ip_addresses.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>ip_address<span style="color:#006600; font-weight:bold;">|</span>
    <span style="color:#9966CC; font-weight:bold;">begin</span>
      Timeout::timeout<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006666;">5</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">do</span>
        <span style="color:#6666ff; font-weight:bold;">Net::HTTP</span>.<span style="color:#9900CC;">get_response</span><span style="color:#006600; font-weight:bold;">&#40;</span>ip_address.<span style="color:#9900CC;">content</span>.<span style="color:#9900CC;">to_s</span>, <span style="color:#996600;">&quot;/&quot;</span>, <span style="color:#006666;">80</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>response<span style="color:#006600; font-weight:bold;">|</span>
          <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;#{Time.now} Response code for #{ip_address.content.to_s}: #{response.code}&quot;</span>
          make_active<span style="color:#006600; font-weight:bold;">&#40;</span>ip_address<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">if</span> ip_address.<span style="color:#9900CC;">prio</span> == <span style="color:#006600; font-weight:bold;">-</span><span style="color:#006666;">1</span>
        <span style="color:#9966CC; font-weight:bold;">end</span>
      <span style="color:#9966CC; font-weight:bold;">end</span>
    <span style="color:#9966CC; font-weight:bold;">rescue</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> e
      <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;#{Time.now} Error connecting to #{ip_address.content.to_s}: #{e}&quot;</span>
      <span style="color:#9966CC; font-weight:bold;">if</span> check_internet
        make_inactive<span style="color:#006600; font-weight:bold;">&#40;</span>ip_address<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">unless</span> ip_address.<span style="color:#9900CC;">prio</span> == <span style="color:#006600; font-weight:bold;">-</span><span style="color:#006666;">1</span>
      <span style="color:#9966CC; font-weight:bold;">end</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#CC0066; font-weight:bold;">sleep</span> <span style="color:#006666;">15</span> <span style="color:#9966CC; font-weight:bold;">if</span> <span style="color:#ff6633; font-weight:bold;">$running</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.pmamediagroup.com/2009/06/setting-powerdns-to-ignore-records-for-downed-web-sites/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>PowerDNS With Empty CNAME = Fail!</title>
		<link>http://www.pmamediagroup.com/2009/04/powerdns-with-empty-cname-fail/</link>
		<comments>http://www.pmamediagroup.com/2009/04/powerdns-with-empty-cname-fail/#comments</comments>
		<pubDate>Tue, 07 Apr 2009 20:58:26 +0000</pubDate>
		<dc:creator>Aaron Murphy</dc:creator>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[cloud]]></category>
		<category><![CDATA[CNAME]]></category>
		<category><![CDATA[Powerdns]]></category>

		<guid isPermaLink="false">http://www.pmamediagroup.com/?p=474</guid>
		<description><![CDATA[Just used up my morning trying to resolve an MX record problem. We were not getting our email through our new Google Apps account. I tried to send from Gmail to myself and it worked. I tried to send to someone else in our domain, and got a &#8220;550 550 Unrouteable address (state 14)&#8221; error.

I [...]]]></description>
			<content:encoded><![CDATA[<p>Just used up my morning trying to resolve an MX record problem. We were not getting our email through our new <a href="http://www.google.com/apps/intl/en/business/index.html">Google Apps</a> account. I tried to send from Gmail to myself and it worked. I tried to send to someone else in our domain, and got a &#8220;550 550 Unrouteable address (state 14)&#8221; error.</p>
<p><span id="more-474"></span></p>
<p>I tried to dig for our domain. It didn&#8217;t report our correct MX record. We use <a href="http://kennethkalmer.github.com/powerdns-on-rails/">PowerDNS on Rails</a>. This makes it easy to administer <a href="http://www.powerdns.com/">PowerDNS</a>. The settings for the Google MX records were right.</p>
<p>It turns out that earlier we had changed our domain to a new <a href="http://en.wikipedia.org/wiki/Cloud_Computing">cloud system</a>. We had to setup <a href="http://en.wikipedia.org/wiki/CNAME_record">CNAME</a> records in our DNS so that users would get routed properly. Luckily, we use <a href="http://www.dnsstuff.com/">DNS Stuff</a> to help us out. They report &#8220;RFC1912 2.4 and RFC2181 10.3 state that there should be no CNAMEs if an NS (or any other) record is present.&#8221;</p>
<p>So I removed the CNAME record and everything works now.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pmamediagroup.com/2009/04/powerdns-with-empty-cname-fail/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/


Served from: www.pmamediagroup.com @ 2010-07-31 10:52:52 -->