Difference between revisions of "Network/DNS"
Jump to navigation
Jump to search
(→Geo) |
|||
| Line 1: | Line 1: | ||
| + | == Bind == | ||
| + | |||
| + | '''named.conf''': | ||
| + | <pre> | ||
| + | </pre> | ||
| + | |||
| + | '''named.conf.local''': | ||
| + | <pre> | ||
| + | include "/etc/bind/geoip/GeoIP.acl"; | ||
| + | include "/etc/bind/geoip/GeoIPv6.acl"; | ||
| + | |||
| + | logging { | ||
| + | channel simple_log { | ||
| + | file "/var/log/named/bind.log" versions 3 size 5m; | ||
| + | //severity client; | ||
| + | print-time yes; | ||
| + | print-severity yes; | ||
| + | print-category yes; | ||
| + | }; | ||
| + | category default{ | ||
| + | simple_log; | ||
| + | }; | ||
| + | }; | ||
| + | |||
| + | |||
| + | view "America" { | ||
| + | match-clients { US; CA; }; | ||
| + | recursion no; | ||
| + | include "/etc/bind/named.conf.default-zones"; | ||
| + | //include "/etc/bind/named.conf.zones"; | ||
| + | zone "lunasys.fr" { | ||
| + | type master; | ||
| + | file "/etc/bind/geoip/us.lunasys.fr.hosts"; | ||
| + | }; | ||
| + | }; | ||
| + | |||
| + | |||
| + | view "Asia" { | ||
| + | match-clients { HK; CN; }; | ||
| + | recursion no; | ||
| + | include "/etc/bind/named.conf.default-zones"; | ||
| + | //include "/etc/bind/named.conf.zones"; | ||
| + | zone "lunasys.fr" { | ||
| + | type master; | ||
| + | file "/etc/bind/geoip/as.lunasys.fr.hosts"; | ||
| + | }; | ||
| + | }; | ||
| + | |||
| + | |||
| + | view "Europe" { | ||
| + | match-clients { FR; }; | ||
| + | recursion no; | ||
| + | include "/etc/bind/named.conf.default-zones"; | ||
| + | //include "/etc/bind/named.conf.zones"; | ||
| + | zone "lunasys.fr" { | ||
| + | type master; | ||
| + | file "/etc/bind/geoip/eu.lunasys.fr.hosts"; | ||
| + | }; | ||
| + | }; | ||
| + | |||
| + | |||
| + | view "Default" { | ||
| + | match-clients { any; }; | ||
| + | recursion no; | ||
| + | include "/etc/bind/named.conf.default-zones"; | ||
| + | //include “/etc/bind/named.conf.zones"; | ||
| + | zone "lunasys.fr" { | ||
| + | type master; | ||
| + | file "/etc/bind/geoip/us.lunasys.fr.hosts"; | ||
| + | }; | ||
| + | }; | ||
| + | </pre> | ||
| + | |||
| + | '''geoip/us.lunasys.fr.hosts''': | ||
| + | <pre> | ||
| + | $TTL 86400 ; 24 hours could have been written as 24h or 1d | ||
| + | $ORIGIN lunasys.fr. | ||
| + | @ 1D IN SOA ns1.lunasys.fr. hostmaster.lunasys.fr. ( | ||
| + | 2002022401 ; serial | ||
| + | 3H ; refresh | ||
| + | 15 ; retry | ||
| + | 1w ; expire | ||
| + | 3h ; minimum | ||
| + | ) | ||
| + | IN NS ns1.lunasys.fr. ; in the domain | ||
| + | IN MX 10 mail.google.com. | ||
| + | ; server host definitions | ||
| + | ns1 IN A 198.245.55.128 | ||
| + | yuki IN A 103.5.15.123 | ||
| + | yuko IN A 198.245.55.128 | ||
| + | </pre> | ||
| + | |||
| + | |||
== PowerDNS == | == PowerDNS == | ||
Revision as of 23:37, 23 June 2012
Bind
named.conf:
named.conf.local:
include "/etc/bind/geoip/GeoIP.acl";
include "/etc/bind/geoip/GeoIPv6.acl";
logging {
channel simple_log {
file "/var/log/named/bind.log" versions 3 size 5m;
//severity client;
print-time yes;
print-severity yes;
print-category yes;
};
category default{
simple_log;
};
};
view "America" {
match-clients { US; CA; };
recursion no;
include "/etc/bind/named.conf.default-zones";
//include "/etc/bind/named.conf.zones";
zone "lunasys.fr" {
type master;
file "/etc/bind/geoip/us.lunasys.fr.hosts";
};
};
view "Asia" {
match-clients { HK; CN; };
recursion no;
include "/etc/bind/named.conf.default-zones";
//include "/etc/bind/named.conf.zones";
zone "lunasys.fr" {
type master;
file "/etc/bind/geoip/as.lunasys.fr.hosts";
};
};
view "Europe" {
match-clients { FR; };
recursion no;
include "/etc/bind/named.conf.default-zones";
//include "/etc/bind/named.conf.zones";
zone "lunasys.fr" {
type master;
file "/etc/bind/geoip/eu.lunasys.fr.hosts";
};
};
view "Default" {
match-clients { any; };
recursion no;
include "/etc/bind/named.conf.default-zones";
//include “/etc/bind/named.conf.zones";
zone "lunasys.fr" {
type master;
file "/etc/bind/geoip/us.lunasys.fr.hosts";
};
};
geoip/us.lunasys.fr.hosts:
$TTL 86400 ; 24 hours could have been written as 24h or 1d
$ORIGIN lunasys.fr.
@ 1D IN SOA ns1.lunasys.fr. hostmaster.lunasys.fr. (
2002022401 ; serial
3H ; refresh
15 ; retry
1w ; expire
3h ; minimum
)
IN NS ns1.lunasys.fr. ; in the domain
IN MX 10 mail.google.com.
; server host definitions
ns1 IN A 198.245.55.128
yuki IN A 103.5.15.123
yuko IN A 198.245.55.128
PowerDNS
General Configuration
/etc/powerdns/pdns.conf
allow-recursion=127.0.0.1 config-dir=/etc/powerdns daemon=yes disable-axfr=yes guardian=yes lazy-recursion=yes local-address=0.0.0.0 local-port=53 loglevel=8 module-dir=/usr/lib/powerdns setgid=pdns setuid=pdns socket-dir=/var/run webserver=yes webserver-address=0.0.0.0 webserver-password=<pass> webserver-port=8080 version-string=powerdns launch=gmysql,geo include=/etc/powerdns/pdns.d
MySQL
MySQL tables (and samples):
DROP TABLE IF EXISTS `domains`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `domains` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(255) NOT NULL, `master` varchar(128) DEFAULT NULL, `last_check` int(11) DEFAULT NULL, `type` varchar(6) NOT NULL, `notified_serial` int(11) DEFAULT NULL, `account` varchar(40) DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `name_index` (`name`) ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=latin1; INSERT INTO `domains` VALUES (1,'lunasys.fr',NULL,NULL,'NATIVE',NULL,NULL); DROP TABLE IF EXISTS `records`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `records` ( `id` int(11) NOT NULL AUTO_INCREMENT, `domain_id` int(11) DEFAULT NULL, `name` varchar(255) DEFAULT NULL, `type` varchar(10) DEFAULT NULL, `content` varchar(64000) DEFAULT NULL, `ttl` int(11) DEFAULT NULL, `prio` int(11) DEFAULT NULL, `change_date` int(11) DEFAULT NULL, PRIMARY KEY (`id`), KEY `rec_name_index` (`name`), KEY `nametype_index` (`name`,`type`), KEY `domain_id` (`domain_id`) ) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=latin1; INSERT INTO `records` VALUES (3,1,'as.www.lunasys.fr','A','3.1.1.1',600,NULL,NULL),(4,1,'us.www.lunasys.fr','A','2.1.1.1',600,NULL,NULL),(5,1,'eu.www.lunasys.fr','A','4.1.1.1',600,NULL,NULL); DROP TABLE IF EXISTS `supermasters`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `supermasters` ( `ip` varchar(25) NOT NULL, `nameserver` varchar(255) NOT NULL, `account` varchar(40) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
In pdns.d/pdns.local, add:
gmysql-host=127.0.0.1 gmysql-user=root gmysql-password=<pass> gmysql-dbname=pdns
Geo
In pdns.d/pdns.local, add:
geo-zone=lunasys.fr #geo-ns-records=ns0.lunasys.fr geo-ip-map-zonefile=/etc/powerdns/zz.countries.nerd.dk.rbldnsd geo-maps=/etc/powerdns/geo-maps
Write geo-maps/lunasys:
$RECORD www $ORIGIN lunasys.fr. 56 eu.www 344 as.www 250 eu.www 840 us.www 124 us.www 0 eu.www
Finally retrieve countries zone file with the following rsync command:
rsync -avz rsync://countries-ns.mdc.dk/zone .
And copy the zz.countries.nerd.dk.rbldnsd in /etc/powerdns/