编译和安装bind9和geoip
# tar -xzvf bind-9.2.4.tar.gz
# tar -xzvf GeoIP-1.4.6.tar.gz
# cd GeoIP-1.4.6
# ./configure –prefix=/usr/local/geoip
# make
# make install
# cd ..
# patch -p0 < bind-9.2.4-geodns-patch/patch.diff //给bind9打补丁,让bind9直接支持geoip库
# cd bind-9.2.4
# CFLAGS=”-I/usr/local/geoip/include” LDFLAGS=”-L/usr/local/geoip/lib -lGeoIP” ./configure –prefix=/usr/local/bind
# make
# make install
Debian 安装 bind9和geoip
#apt-get install bind9 bind9-host dnsutils
配置文件说明
配置文件族:
# ls /etc/bind/ -l
total 44
-rw-r--r-- 1 root root 237 Jan 16 2006 db.0
-rw-r--r-- 1 root root 271 Jan 16 2006 db.127
-rw-r--r-- 1 root root 237 Jan 16 2006 db.255
-rw-r--r-- 1 root root 353 Jan 16 2006 db.empty
-rw-r--r-- 1 root root 256 Jan 16 2006 db.local
-rw-r--r-- 1 root root 1507 Jan 16 2006 db.root
-rw-r--r-- 1 root bind 1611 Jan 16 2006 named.conf
-rw-r--r-- 1 root bind 165 Jan 16 2006 named.conf.local
-rw-r--r-- 1 root bind 672 Jan 16 2006 named.conf.options
-rw-r----- 1 bind bind 77 Aug 4 08:41 rndc.key
-rw-r--r-- 1 root root 1317 Jan 16 2006 zones.rfc1918
配置文件说明:
named.conf
设置一般的named参数,指向该服务器使用的域数据库的信息源
named.conf.options
全局选项
db.root
根服务器指向文件, 由Internet NIC创建和维护, 无需修改, 但是需要定期更新
db.local
localhost正向区文件,用于将名字localhost转换为本地回送IP地址 (127.0.0.1)
db.127
localhost反向区文件,用于将本地回送IP地址(127.0.0.1)转换为名字localhost
其中,主配置文件/etc/named.conf的配置语句
命令 用法
acl 定义IP地址的访问控制清单
control 定义ndc使用的控制通道
include 把其他文件包含到配置文件中
key 定义授权的安全密钥
logging 定义日志写什么,写到哪
opitons 定义全局配置选项和缺省值
server 定义远程服务器的特征
trunsted-keys 为服务器定义DNSSEC加密密钥
zone 定义一个区
默认情况下, 内容如下:
include "/etc/bind/named.conf.options";
zone "." {
type hint;
file "/etc/bind/db.root";
};
zone "localhost" {
type master;
file "/etc/bind/db.local";
};
zone "127.in-addr.arpa" {
type master;
file "/etc/bind/db.127";
};
zone "0.in-addr.arpa" {
type master;
file "/etc/bind/db.0";
};
zone "255.in-addr.arpa" {
type master;
file "/etc/bind/db.255";
};
include "/etc/bind/named.conf.local";
其中type项的值:
master:表示定义的是主域名服务器
slave :表示定义的是辅助域名服务器
hint:表示是互联网中根域名服务器
在Debian环境中,options语句的配置内容, 被移至named.conf.options文件中:
options {
directory "/var/cache/bind";
// If there is a firewall between you and nameservers you want
// to talk to, you might need to uncomment the query-source
// directive below. Previous versions of BIND always asked
// questions using port 53, but BIND 8.1 and later use an unprivileged
// port by default.
// query-source address * port 53;
// If your ISP provided one or more IP addresses for stable
// nameservers, you probably want to use them as forwarders.
// Uncomment the following block, and insert the addresses replacing
// the all-0's placeholder.
// forwarders {
// 0.0.0.0;
// };
auth-nxdomain no; # conform to RFC1035
};
制作匹配的name.conf文件
view “us” {
// 匹配北美的客户端 US & Canada
match-clients { country_US; country_CA; };
// Provide recursive service to internal clients only.
recursion no;
zone “cdn.xianglei.com” {
type master;
file “pri/xianglei-us.db”;
};
zone “.” IN {
type hint;
file “named.ca”;
};
};
view “latin” {
// 匹配到南美国家
match-clients { country_AR; country_CL; country_BR; };
recursion no;
zone “cdn.xianglei.com” {
type master;
file “pri/xianglei-latin.db”;
};
zone “.” IN {
type hint;
file “named.ca”;
};
};
最新评论