MySQL Bind

From D3xt3r01.tk
Jump to navigationJump to search

WHY

Because I found out that Bind ( the nameserver ) can use mysql to read records and have them updated in real time without restarting. I'm doing this on a centos box.

HOW

wget http://ftp.isc.org/isc/bind9/9.7.1-P2/bind-9.7.1-P2.tar.gz tar -xzf bind-9.7.1-P2.tar.gz cd bind-9.7.1-P2

wget http://sourceforge.net/projects/mysql-bind/files/mysql-bind/mysql-bind-0.2%20src/mysql-bind.tar.gz/download tar -xzf mysql-bind.tar.gz

cp mysql-bind/mysqldb.c bin/named/ cp mysql-bind/mysqldb.h bin/named/ cp mysql-bind/mysqldb.c bin/named/include/named/ cp mysql-bind/mysqldb.h bin/named/include/named/

Edit bin/named/Makefile.in to have something like this:

DBDRIVER_OBJS = mysqldb.@O@ DBDRIVER_SRCS = mysqldb.c Get the output of `mysql_config --cflags` and set it like DBDRIVER_INCLUDES = -I/usr/include/mysql -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fno-strict-aliasing -fwrapv Get the output of `mysql_config --libs` and set it like DBRIVER_LIBS = -rdynamic -L/usr/lib64/mysql -lmysqlclient -lz -lcrypt -lnsl -lm -L/usr/lib64 -lssl -lcrypto

Edit bin/named/main.c : 1) Add #include "mysqldb.h" <-- (including quotes) At the top of the includes 2) Search for "setup(void)" (without quotes), at the end of the function you should see a ns_server_create(ns_g_mctx, &ns_g_server); right before it add: mysqldb_init(); 3) Search for "cleanup(void)" (without quotes), in the first few lines of the function you should see a call to ns_server_destroy(&ns_g_server); right after it add: mysqldb_clear();

And compile && install

./configure --prefix=/usr/local --disable-openssl-version-check make make install