DNS配置-BIND安装配置全过程
下载bind,我下载的是bind-9.11.13.tar.gz
我下载的文件放在/root目录下
进入目录解压缩
[root@localhost ~]# tar zxf bind-9.11.13.tar.gz
进入刚解压出来的目录
[root@localhost ~]# cd bind-9.11.13/
编译配置
[root@localhost bind-9.11.13]# ./configure --prefix=/usr/local/bind-9.11.13 --sysconfdir=/etc --localstatedir=/var --enable-threads --without-openssl
[root@192 bind-9.11.13]# make && make install
[root@192 bind-9.11.13]# cd /usr/local/bind-9.11.13/
建立etc目录
[root@192 bind-9.11.13]# mkdir etc
生成rndc控制命令的key文件
[root@192 bind-9.11.13]# sbin/rndc-confgen > etc/rndc.conf
从rndc.conf文件中提取named.conf用的key
[root@192 bind-9.11.13]# cd etc
[root@192 etc]# tail -10 rndc.conf | head -9 | sed s/#\ //g > named.conf
自动在/usr/local/named/etc 生成named,conf文件
建立区文件目录(已有可以不用创建)
[root@192 etc]# cd /var/named/
[root@192 named]# vim test.com.zone
$TTL 86400 @ IN SOA dns.test.com. dns.www.test.com. ( 66 ;Serial 3H ;refresh 15M ;retry 1w ;expire 1D) ;minimum @ IN NS dns.test.com. dns.test.com. IN A 192.168.40.134 dns.test.com. IN A 192.168.40.133 @ IN MX 10 mail.www.test.com www.test.com. IN A 192.168.40.134
dig命令直接生成named.root文件(内网可不加)
dig > named.root
建立test.com域名正向解析文件
[root@192 etc]# vim named.conf
key "rndc-key" { algorithm hmac-md5; secret "YcMiK1dLZF+lMt9RtnuH1g=="; }; controls { inet 127.0.0.1 port 953 allow { 127.0.0.1; } keys { "rndc-key"; }; }; options { listen-on port 53 { any; }; directory "/var/named"; #named区文件目录 pid-file "named.pid"; #进程id文件名 allow-query { any; }; }; zone "test.com" IN { type master; file "test.com.zone"; allow-update {none; }; };
启动bind
[root@192 etc]# /usr/local/bind-9.11.13/sbin/named -gc /usr/local/bind-9.11.13/etc/named.conf
网卡配置文件
[root@192 network-scripts]# vim /etc/resolv.conf
验证:
遇到问题:
1. openssl没有安装
configure: error: OpenSSL was not found in any of /usr /usr/local /usr/local/ssl /opt/local /usr/pkg /usr/sf
w; use --with-openssl=/path
当执行./configure --prefix=/usr/local/bind-9.11.13 --sysconfdir=/etc --localstatedir=/var --enable-threads --with-openssl
有提示报错,是因为没有安装openssl
解决:
1. 可以直接--without-openssl,不使用openssl进行安装
2. 可以先yum -y install openssl-devel 安装完,在执行./configure --prefix=/usr/local/bind-9.11.13 --sysconfdir=/etc --localstatedir=/var --enable-threads --with-openssl (建议使用openssl)
2.--without-openssl
BIND 9 is being built without cryptography support. This means it will not have DNSSEC support. Use --with-openssl, or --with-pkcs11 and --enable-native-pkcs11 to enable cryptography.
1.使用--without-openssl会提示上述信息