Re: views support using DLZ
Luis Silva <[email protected]> Sun, 22 Feb 2009 00:29:40 +0000
| Newsgroups | gmane.network.dns.bind9.dlz |
|---|---|
| Message-ID | <[email protected]> |
Tks a lot for the quick reply. I'm still set up my environment and following
the simple example present on the web page.
I have in my named.conf:
dlz "postgres zone" {
database "postgres 2
{host=10.112.64.59 port=5432 dbname=dns_data user=postgres}
{select zone from dns_records where zone = '%zone%'}
{select ttl, type, mx_priority, case when lower(type)='txt' then '\"' ||
data
|| '\"' else data end from dns_records where zone = '%zone%' and
host = '%record%'
and not (type = 'SOA' or type = 'NS')}
{select ttl, type, mx_priority, data, resp_person, serial, refresh,
retry, expire,
minimum from dns_records where zone = '%zone%' and (type = 'SOA' or
type='NS')}
{select ttl, type, host, mx_priority, data, resp_person, serial, refresh,
retry, expire,
minimum from dns_records where zone = '%zone%'}";
};
My database:
CREATE TABLE dns_records
(
"zone" text,
host text,
ttl integer,
"type" text,
mx_priority integer,
data text,
resp_person text,
serial integer,
refresh integer,
retry integer,
expire integer,
minimum integer
)
The only record present in table dns_records:
zone | host | ttl | type | mx_priority | data | resp_person
| serial | refresh | retry | expire | minimum
---------------+------+-----+------+-------------+------+--------------------+--------+---------+-------+---------+---------
ptinovacao.pt | @ | 800 | SOA | | | ns1.ptinovacao.pt.
| 324 | 10800 | 1800 | 3600000 | 86400
But I got this error:
named[5211]: dns_rdata_fromtext: buffer-0xbff36800:1: near eof: unexpected
end of input
named[5211]: dns_sdlz_putrr returned error. Error code was: unexpected end
of input
named[5211]: dns_rdata_fromtext: buffer-0xbff36540:1: near eof: unexpected
end of input
named[5211]: dns_sdlz_putrr returned error. Error code was: unexpected end
of input
I'm running red hat AS 4 and postgres 8.2. Can this error be a version
problem?
Thanks in advance.
Regards,
Luis
On Thu, Feb 19, 2009 at 9:23 PM, Íèêîëàé <[email protected]> wrote:
> Hello, Luis.
>
> LS> Hi all,
> LS> Is it possible to setup DLZ with bind views? I'm trying to find an
> example
> LS> but i'm not having any success so far.
> LS> Thanks a lot in advance.
>
> LS> Kind Regards,
> LS> Luis
>
> For example my config files:
> --------------------------------------------------------
> dlz.conf
>
> dlz "Mysql zone" {
> database "mysql
> {host=localhost dbname=**** user=**** pass=****}
> {SELECT rec.zone FROM rec
> WHERE ((rec.host ='@' AND rec.zone = '%zone%')
> OR (rec.host != '@' AND rec.type = 'NS' AND
> concat(rec.host,'.',rec.zone) = '%zone%'))
> LIMIT 1}
> {SELECT ttl, type, priority, IF(type = 'TXT',
> CONCAT('\"',data,'\"'), data) AS data FROM rec
> WHERE rec.zone = '%zone%' AND rec.host = '%record%' AND
> type <> 'NS' AND type <> 'SOA'}
> {SELECT ttl, type, data, ns, contact, serial, refresh,
> retry, expire, minimum FROM rec
> WHERE ((rec.host = '@' AND rec.zone = '%zone%') OR
> (rec.host != '@' AND
> concat(rec.host,'.',rec.zone) = '%zone%'))
> AND (type = 'SOA' OR type='NS')
> ORDER BY type='SOA' desc}
> {SELECT ttl, type, host, priority, IF(type = 'TXT',
> CONCAT('\"',data,'\"'), data) AS data, ns, contact, serial,
> refresh, retry, expire, minimum FROM rec
> WHERE rec.zone = '%zone%'}
> {SELECT xfr.zone from xfr
> WHERE xfr.client = '%client%' AND '%zone%' like xfr.zone
> ORDER BY zone = xfr.zone DESC LIMIT 1}
> {INSERT INTO counting SET count=1,zone='%zone%' ON DUBLICATE
> KEY UPDATE count=count+1}
> ";
> };
>
>
> -------------------------------------------------------------------------------------------
> named.conf
>
> skip...
> logging {
> channel query_log {
> file "/var/log/named/query_log";
> print-time yes;
> print-severity yes;
> print-category yes;
> };
> channel default_log {
> file "/var/log/named/named_log";
> severity notice;
> print-time yes;
> print-severity yes;
> print-category yes;
> };
> category queries {
> query_log;
> };
> category default {
> default_log;
> };
>
> };
> include "dlz.conf";
>
> --------------------------------------------------------------------------------------------
> Mysql struct:
>
> show tables;
> +---------------+
> | Tables_in_dns |
> +---------------+
> | counting |
> | rec |
> | xfr |
> +---------------+
>
> show create table counting;
> CREATE TABLE `counting` (
> `zone` varchar(255) NOT NULL DEFAULT '',
> `count` int(10) unsigned DEFAULT '0',
> PRIMARY KEY (`zone`)
> ) ENGINE=MyISAM DEFAULT CHARSET=utf8
>
> show create table rec;
> CREATE TABLE `rec` (
> `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
> `zone` varchar(255) NOT NULL DEFAULT '',
> `ttl` int(11) NOT NULL DEFAULT '86400',
> `type` varchar(32) NOT NULL DEFAULT '',
> `host` varchar(255) NOT NULL DEFAULT '@',
> `priority` int(11) DEFAULT NULL,
> `data` text,
> `ns` varchar(255) DEFAULT NULL,
> `contact` varchar(255) DEFAULT NULL,
> `serial` bigint(20) DEFAULT NULL,
> `refresh` int(11) DEFAULT NULL,
> `retry` int(11) DEFAULT NULL,
> `expire` int(11) DEFAULT NULL,
> `minimum` int(11) DEFAULT NULL,
> PRIMARY KEY (`id`),
> KEY `type` (`type`),
> KEY `host` (`host`),
> KEY `zone` (`zone`),
> KEY `zone_type` (`zone`,`type`),
> KEY `host_zone` (`host`,`zone`)
> ) ENGINE=InnoDB AUTO_INCREMENT=100883 DEFAULT CHARSET=utf8
>
> show create table xfr
> CREATE TABLE `xfr` (
> `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
> `zone` varchar(255) NOT NULL DEFAULT '',
> `client` varchar(255) NOT NULL DEFAULT '',
> `comment` text,
> PRIMARY KEY (`id`),
> KEY `zone` (`zone`),
> KEY `client` (`client`)
> ) ENGINE=MyISAM AUTO_INCREMENT=11 DEFAULT CHARSET=utf8
>
>
> ---------------------------------------------------------------------------------------------------
> Example zone.
>
> in rec table
>
>
> +-----+-------------+------+------+------+----------+--------------------------+-------------------+------------------+------------+---------+-------+---------+---------+
> | id | zone | ttl | type | host | priority | data
> | ns | contact | serial | refresh | retry |
> expire | minimum |
>
> +-----+-------------+------+------+------+----------+--------------------------+-------------------+------------------+------------+---------+-------+---------+---------+
> | 552 | example.tld | 7200 | SOA | @ | NULL | NULL
> | ns1.example.tld. | noc.example.tld. | 1217358518 | 10800 | 1800 |
> 3600000 | 86400 |
> | 553 | example.tld | 7200 | NS | @ | NULL | ns1.example.tld.
> | NULL | NULL | NULL | NULL | NULL |
> NULL | NULL |
> | 554 | example.tld | 7200 | NS | @ | NULL | ns2.example.tld.
> | NULL | NULL | NULL | NULL | NULL |
> NULL | NULL |
> | 555 | example.tld | 7200 | MX | @ | 10 | cluster.example.tld.
> | NULL | NULL | NULL | NULL | NULL |
> NULL | NULL |
> | 556 | example.tld | 7200 | A | @ | NULL | ip.ad.dr.es
> | NULL | NULL | NULL | NULL | NULL |
> NULL | NULL |
> | 557 | example.tld | 7200 | A | * | NULL | ip.ad.dr.es
> | NULL | NULL | NULL | NULL | NULL |
> NULL | NULL |
>
> +-----+-------------+------+------+------+----------+--------------------------+-------------------+------------------+------------+---------+-------+---------+---------+
>
>
> I`ll gled if will help you. :)
>
>
> --
> Best regards,
> Nikolas mailto:[email protected]
>
>
------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Bind-dlz-testers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bind-dlz-testers