Bind9+mysql Dlz (Dynamically Loadable Zones)

Source: Internet
Author: User
Tags install openssl openssl nameserver

Yum Install OpenSSL Openssl-devel

Groupadd MySQL
Useradd-g mysql-s/sbin/nologin-m MySQL
Chown-r Mysql:mysql/usr/local/mysql

./configure--prefix=/usr/local/mysql/--enable-assembler--with-extra-charsets=complex-- Enable-thread-safe-client-with-big-tables--with-readline--with-ssl--with-embedded-server--enable-local-infile- -with-plugins=partition,innobase,myisammrg

Make && make install

/usr/local/mysql/bin/mysql_install_db--basedir=/usr/local/mysql--datadir=/usr/local/mysql/var--user=mysql
Cd/usr/local/mysql
CP SHARE/MYSQL/MY-MEDIUM.CNF/ETC/MY.CNF


Nphup./mysqld_safe--defaults-file=/etc/my.cnf--user=mysql--datadir=/usr/local/mysql/var &
Login Mysql/usr/local/mysql/bin/mysql

Insert into Mysql.user (Host,user,password) VALUES ("localhost", "DNS", Password ("DNS"));
Insert into Mysql.user (Host,user,password) VALUES ("%", "DNS", Password ("DNS"));
GRANT all privileges on * * to ' DNS ' @ '% ' identified by ' DNS ' with GRANT OPTION;
Flush privileges;

CREATE TABLE ' Dns_records ' (
' id ' int (ten) unsigned not NULL auto_increment,
' Zone ' varchar (255) Not NULL,
' Host ' varchar (255) Not NULL default ' @ ',
' Type ' enum (' MX ', ' CNAME ', ' NS ', ' SOA ', ' A ') not NULL,
' Data ' varchar (255) Default NULL,
' TTL ' int (one) not NULL default ' 800 ',
' mx_priority ' varchar (255) Default NULL,
' Refresh ' int (one) default NULL,
' Retry ' int (one) default NULL,
' Expire ' int (one) default NULL,
' Minimum ' int (one) default NULL,
' Serial ' bigint () default NULL,
' Resp_person ' varchar (255) Default NULL,
' Primary_ns ' varchar (255) Default NULL,
PRIMARY KEY (' id '),
KEY ' id ' (' id '),
KEY ' type ' (' type '),
KEY ' Host ' (' Host '),
KEY ' zone ' (' zone ')
) Engine=myisam auto_increment=1 DEFAULT Charset=utf8;

--soa
INSERT into Dns_records (Zone,host,type,serial,refresh,retry,expire,minimum,primary_ns,resp_person)
VALUES (' linuxtone.org ', ' @ ', ' SOA ', 2009030200, 172800, 1209600, 3600, ' ns1.linuxtone.org ', ' root.linuxtone.org ');

--linuxtone.org redirection for any host to linuxtone.org.
INSERT into Dns_records (zone,host,type,data)
VALUES (' linuxtone.org ', ' * ', ' CNAME ', ' linuxtone.org ');

--nameserver for Zone
INSERT into Dns_records (zone,host,type,data)
VALUES (' linuxtone.org ', ' @ ', ' NS ', ' ns1.linuxtone.org ');

--toplevel-ip-address of Zone itself
INSERT into Dns_records (zone,host,type,data)
VALUES (' linuxtone.org ', ' @ ', ' A ', ' 192.168.0.103 ');

2. #host anlegen:
--ip nameserver (Resp_person can be NULL)
INSERT into Dns_records (Zone,host,type,data,resp_person)
VALUES (' linuxtone.org ', ' ns1 ', ' A ', ' 192.168.0.103 ', ' root.linuxtone.org ');

a:www.linuxtone.org
INSERT into Dns_records (zone,host,type,data)
VALUES (' linuxtone.org ', ' www ', ' A ', ' 192.168.0.108 ');

a:bbs.linuxtone.org
INSERT into Dns_records (zone,host,type,data)
VALUES (' linuxtone.org ', ' bbs ', ' A ', ' 192.168.0.109 ');

3. #host Alias anlegen:
--ns2 directs to ns1
INSERT into Dns_records (Zone,host,type,data,resp_person)
VALUES (' linuxtone.org ', ' ns2 ', ' CNAME ', ' ns1.linuxtone.org ', ' root.linuxtone.org. ');

alias:man.linuxtone.org CNAME www
INSERT into Dns_records (zone,host,type,data)
VALUES (' linuxtone.org ', ' man ', ' CNAME ', ' www ');

alias:host.linuxton.org CNAME BBS
INSERT into Dns_records (zone,host,type,data)
VALUES (' linuxtone.org ', ' host ', ' CNAME ', ' bbs.linuxtone.org ');

4. #mailserver anlegen:
--ns2 directs to ns1
INSERT into Dns_records (zone,host,type,data,mx_priority, Resp_person)
VALUES (' linuxtone.org ', ' * ', ' MX ', ' mail.linuxtone.org ', ' Up ', ' root.linuxtone.org ');


Install bind,9.4.0 The above version has DLZ patch, DLZ (Dynamically Loadable Zones), allow zone records to be placed in the database, and support multiple databases.
./configure--with-dlz-mysql--enable-largefile--enable-threads=no--prefix=/usr/local/bind-- Disable-openssl-version-check
Make && make install

cd/usr/local/bind/etc/
.. /sbin/rndc-confgen >rndc.conf
Tail-n10 rndc.conf | Head-n9 | SED-E s/#\//g >named.conf

Dig > Named.root//It doesn't matter if you don't succeed in this step.


Vi/usr/local/bind/etc/named.conf
Dlz "Mysql zone" {
Database "MySQL
{host=127.0.0.1 Dbname=dns ssl=false port=3306 user=root pass=}
{Select zone from dns_records where zone = ' $zone $ ' limit 1}
{Select TTL, type, mx_priority, case if lower (type) = ' txt ' then concat (' \ ' ', 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 $ ' and not (type = ' SOA ' or type = ' NS ')}
{Select zone from xfr_table where zone = ' $zone $ ' and client = ' $client $ '}
{Update Data_count Set count = Count + 1 where zone = ' $zone $ '} ';
};

Start
/usr/local/bind/sbin/named-c/usr/local/bind/etc/named.conf

Bind9+mysql Dlz (dynamically Loadable Zones)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.