Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PowerDNS and CNAME to external domain

I'm using PowerDNS (2.9.22) for my clients. Because it can store all data into MySQL database and it's easy for clients to edit their zones as they like.

Now I have a problem with CNAMEs:

Here are records into MySQL database:

+-----------------------+-------+-----------------------+
| localhost.example.com |   A   | 127.0.0.1             |
+-----------------------+-------+-----------------------+
| a.example.com         | CNAME | localhost.example.com |
+-----------------------+-------+-----------------------+
| www.example.com       | CNAME | andreyzentavr.com     |
+-----------------------+-------+-----------------------+

PowerDNS config is here:

allow-recursion=127.0.0.1, 173.193.**.162, 173.193.**.163
allow-recursion-override=on
cache-ttl=20
config-dir=/etc/powerdns
daemon=yes
default-soa-name=ns3.bserver.com
disable-axfr=yes
guardian=no
launch=gmysql
gmysql-host=127.0.0.1
gmysql-port=3306
gmysql-user=powerdns
gmysql-dbname=powerdns
gmysql-password=123123
lazy-recursion=yes
local-address=173.193.**.162, 173.193.**.163
local-port=53
log-dns-details=yes
log-failed-updates=yes
logfile=/var/log/pdns.log
loglevel=6
master=yes
max-queue-length=5000
max-tcp-connections=10
module-dir=/usr/lib/powerdns
query-logging=yes
recursor=127.0.0.1:53
setgid=pdns
setuid=pdns
skip-cname=no
slave=yes
slave-cycle-interval=600
soa-minimum-ttl=3600
soa-refresh-default=10800
soa-retry-default=3600
soa-serial-offset=0
socket-dir=/var/run
use-logfile=yes
wildcards=yes
version-string=powerdns

when I'm doing nslookup query, I got this:

server:~# nslookup
> set q=any
> server ns3.***.com
Default server: ns3.***.com
Address: 173.193.**.163#53
> a.example.com
Server:         ns3.***.com
Address:       173.193.***.163#53

a.example.com      canonical name =localhost.example.com.
Name: localhost.example.com
Address: 127.0.0.1
>
>
> www.example.com
Server:         ns3.***.com
Address:       
173.193.***.163#53

** server can't find www.example.com: NXDOMAIN

As you can see, if CNAME points to INTERNAL record - everything resolves fine. But if it points to external domain - I have an error.

andreyzentavr.com is existant domain and points to 194.126.204.41

Is it bug in PowerDNS? Or did I configure it wrongly?

like image 939
Andrey Zentavr Avatar asked Aug 15 '10 17:08

Andrey Zentavr


2 Answers

Solution is to put the recursor in front of the authoritative server and configure the recursor to forward specific domains to the authoritative server using the forward-zones-recurse directive. Requires version 3.2 of the recursor.

like image 93
user615501 Avatar answered Oct 20 '22 00:10

user615501


Usually, with DNS, if you want to point a CNAME to an external record, you have to add a period to the end of the record (sub.domain.com.). When you leave off the final dot, DNS interprets it as a relative record (so sub.domain.com would be interpreted as sub.domain.com.domain.com, for example).

I would assume since you have an 'A' record for localhost.example.com set up in your database, PowerDNS sees that and knows that's the domain you mean to point to, even though you didn't make the other CNAME absolute (localhost.example.com.) or relative (just localhost in the hostname).

like image 20
bhamby Avatar answered Oct 20 '22 01:10

bhamby