智能DNS工作原理:
在用户解析一个域名的时候,判断一下用户的IP,然后跟DNS服务器内部的IP表匹配一下,看看用户是电信还是网通用户,然后给用户返回对应的IP地址。目前的域名服务运营商不提供智能DNS服务,所以必须自行架设DNS服务或者使用网上免费的智能DNS服务,如DNSPOD本实例中我架设的是一个简单的内外解析模式,如果需要增加其他类别(电信、网通)只需添加对于的 view 即可。bind 在很早以前就已经集成了bind-dlz 数据库模块,可支持sqllit、bdb Mysql PostgreSQL ODBC LDAP等数据源,详见:
http://bind-dlz.sourceforge.net/本次架设采用PostgreSQL作为数据源实现,数据库已经准备完毕(可使用已有的数据库系统,创建一个新库即可)。1、配置说明
两个view
local 内部网络
any 其他(公网)两台DNS服务器
master dns 10.0.0.8 222.222.222.8
slave dns 10.0.0.9 222.222.222.9
2、创建数据库、表并添加基本记录记录
- create database dns_dlz;
- create table dns_records(
- zone character varying(256),
- host character varying(256) NOT NULL default "@",
- ttl integer,
- view character varying(256),
- type character varying(256),
- mx_priority integer,
- data character varying(256),
- resp_person character varying(256),
- serial integer,
- refresh integer,
- retry integer,
- expire integer,
- minimum integer
- );
-
- create INDEX dns_records_host_index on dns_records (host);
- create INDEX dns_records_type_index on dns_records ("type");
- create INDEX dns_records_zone_index on dns_records ("zone");
# zone sample.com
- #soa 记录
- insert into dns_records(zone, host, ttl, view, type, mx_priority, data, resp_person, serial, refresh, retry, expire, minimum) values ("sample.com", "@", 600, "LOCAL", "SOA", NULL, "sample.com.", "root.sample.com.", 2011083001, 28800, 14400, 86400, 86400);
- insert into dns_records(zone, host, ttl, view, type, mx_priority, data, resp_person, serial, refresh, retry, expire, minimum) values ("sample.com", "@", 600, "ANY", "SOA", NULL, "sample.com.", "root.sample.com.", 2011083001, 28800, 14400, 86400, 86400);
- #dns 记录
- insert into dns_records(zone, host, ttl, view, type, mx_priority, data, resp_person, serial, refresh, retry, expire, minimum) values ("sample.com", "@", 600, "LOCAL", "NS", NULL, "ns1.sample.com.", NULL, 2011083001, 28800, 14400, 86400, 86400);
- insert into dns_records(zone, host, ttl, view, type, mx_priority, data, resp_person, serial, refresh, retry, expire, minimum) values ("sample.com", "@", 600, "ANY", "NS", NULL, "ns1.sample.com.", NULL, 2011083001, 28800, 14400, 86400, 86400);
- #A记录 time.sample.com
- insert into dns_records(zone, host, ttl, view, type, mx_priority, data, resp_person, serial, refresh, retry, expire, minimum) values ("sample.com", "time", 600, "LOCAL", "A", NULL, "10.0.0.8", NULL, 2011083001, 28800, 14400, 86400, 86400);
- insert into dns_records(zone, host, ttl, view, type, mx_priority, data, resp_person, serial, refresh, retry, expire, minimum) values ("sample.com", "time", 600, "ANY", "A", NULL, "222.222.222.8", NULL, 2011083001, 28800, 14400, 86400, 86400);
- #A记录 ns1.sample.com
- insert into dns_records(zone, host, ttl, view, type, mx_priority, data, resp_person, serial, refresh, retry, expire, minimum) values ("sample.com", "ns1", 600, "LOCAL", "A", NULL, "10.0.0.10", NULL, NULL, NULL, NULL, NULL, NULL);
- insert into dns_records(zone, host, ttl, view, type, mx_priority, data, resp_person, serial, refresh, retry, expire, minimum) values ("sample.com", "ns1", 600, "ANY", "A", NULL, "222.222.222.10", NULL, NULL, NULL, NULL, NULL, NULL);
- #mx记录
- insert into dns_records(zone, host, ttl, view, type, mx_priority, data, resp_person, serial, refresh, retry, expire, minimum) values ("sample.com", "@", 600, "LOCAL", "MX", 10, "mail.sample.com.", NULL, NULL, NULL, NULL, NULL, NULL);
- insert into dns_records(zone, host, ttl, view, type, mx_priority, data, resp_person, serial, refresh, retry, expire, minimum) values ("sample.com", "@", 600, "ANY", "MX", 10, "mail.sample.com.", NULL, NULL, NULL, NULL, NULL, NULL);
其他域名的添加方式类似,将zone项替换为对于的域名即可3、bind 编译安装及配置rpm包默认不支持dlz模式,需要使用源码编译
- ./configure --with-dlz-postgres --enable-threads --prefix=/usr/local/bind
或
- ./configure --with-dlz-postgres --build=x86_64-RedHat-linux-gnu --host=x86_64-redhat-linux-gnu --target=x86_64-redhat-linux-gnu --program-prefix= --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --sysconfdir=/etc --datadir=/usr/share --includedir=/usr/include --libdir=/usr/lib64 --libexecdir=/usr/libexec --sharedstatedir=/usr/com --mandir=/usr/share/man --infodir=/usr/share/info --with-libtool --localstatedir=/var --enable-threads --enable-ipv6 --with-pic --disable-openssl-version-check
以下安装路径为系统默认路径 配置文件 /etc/named.conf 其他配置文件路径 /etc/named/4、创建相关配置文件
- cd /etc
- rndc-confgen >rndc.conf
- tail -n6 rndc.conf | head -n5 | sed -e s/#//g >named.conf
- rm -f rndc.conf (该文件与 rndc.key 文件一起出现会出现 rndc警告,删除为妙)
- dig > named/named.root
查看是否存在 /etc/rndc.key 文件,如果没有就生成一个rndc-confgen -a -c rndc.key
默认的rndc.key 文件中的key名称 好像是 rndckey手动生成的key名称是 rndc-keykey的名称一定要一致,否则会出现不能使用 rndc 刷新、不能同步的问题。
使用 dnssec-keygen 生成view TSIG key - dnssec-keygen -a hmac-md5 -b 128 -n HOST local
- dnssec-keygen -a hmac-md5 -b 128 -n HOST any
将生成的key 填入named.conf 对应的位置 如:
- key "any" {
- algorithm hmac-md5;
- secret "0bUZSQ1p3OMbX/6nGB6YPQ==";
- };
详细见下面的完整配置文件,该配置文件包含文件存储和数据库两种方式(数据库存储已经注视掉),文件存储方式已经包含master slave 之间的TSIG 方式同步。及在不同的view中使用各自key进行同步。完整 named.conf 内容
- options
- {
- directory "/var/named";
- dump-file "data/cache_dump.db";
- statistics-file "data/named_stats.log";
- memstatistics-file "data/named_mem_stats.log";
- #listen-on port 53 { 127.0.0.1; 10.0.0.8; 222.222.222.8; };
- allow-recursion { 127.0.0.1; };
- allow-transfer { dns_ip; }; #使用文件存储zone时使用 slave 无需此项
- also-notify { 10.0.1.9; }; #使用文件存储zone时使用 slave 无需此项
-
- edns-udp-size 512;
- };
- include "/etc/rndc.key";
- controls {
- inet 127.0.0.1 port 953
- allow { 127.0.0.1; } keys { "rndckey"; };
- };
- key "any" {
- algorithm hmac-md5;
- secret "0bUZSQ1p3OMbX/6nGB6YPQ==";
- };
- key "local" {
- algorithm hmac-md5;
- secret "OuhPGr+uFmSeOm04ZPJFmA==";
- };
-
- acl "dns_ip" {
- 10.0.0.8; #master
- 10.0.0.9; #slave
- };
-
-
- acl "LOCAL" {
- 10.0.0.0/8;
- };
-
- include "/etc/named/local_acl.conf";
- include "/etc/named/any.conf";
-
- logging {
- category edns-disabled { null; };
- channel query_log {
- file "/var/named/data/query.log" versions 3 size 20m;
- severity info;
- print-time yes;
- print-category yes;
- };
- category queries {
- query_log;
- };
- };
RMAN 备份出现:RMAN-20021: database not setLinux 运行 DB2 script相关资讯 PostgreSQL
- Ubuntu 16.04 下安装 PostgreSQL (08月14日)
- PostgreSQL 发布全系安全更新 (02月12日)
- 使用pg_basebackup搭建PostgreSQL (12/30/2015 09:00:29)
| - Linux下RPM包方式安装PostgreSQL (03月04日)
- PostgreSQL9.5新特性之行级安全性 (01月19日)
- 利用pgpool实现PostgreSQL的高可用 (12/30/2015 08:54:36)
|
本文评论 查看全部评论 (0)