Re: views support using DLZ
Íèêîëàé <[email protected]> Fri, 20 Feb 2009 00:23:07 +0300
| Newsgroups | gmane.network.dns.bind9.dlz |
|---|---|
| Organization | RCfXI |
| Message-ID | <[email protected]> |
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