域名查找顺序 设置 /etc/host.conf
1. bind 安装
$ yum install bind bind-utils
nslookup (name server lookup) 在bind-utils 中
查看安装结果
$rpm -aq | grep bind
bind-license-9.9.4-29.el7_2.3.noarch
bind-utils-9.9.4-29.el7_2.3.x86_64
bind-libs-lite-9.9.4-29.el7_2.3.x86_64
bind-libs-9.9.4-29.el7_2.3.x86_64
bind-9.9.4-29.el7_2.3.x86_64
搭建域名 bodani.com
2.配置主DNS服务器:
------------------------------------------------------------------------------------------------------------
2.1. 主要配置文件:
/etc/named.conf 主要配置入口
/etc/named.rfc1912.zones 定义正反解区域相关
/var/named/ 正反解数据库
配置 named.conf
// listen-onport 53 { 127.0.0.1; }; (默认监听53 端口)
// listen-on-v6port 53 { ::1; };
directory "/var/named"; (默认配置数据存放位置)
dump-file "/var/named/data/cache_dump.db";
statistics-file"/var/named/data/named_stats.txt";
memstatistics-file"/var/named/data/named_mem_stats.txt";
allow-query { any; }; (允许访问配置,默认localhost 只本机可用)
include"/etc/named.rfc1912.zones";
include"/etc/named.bodani.com.zones";
配置 zones
$cp/etc/named.rfc1912.zones /etc/named.bodani.com.zones
$vim /etc/named.bodani.com.zones
zone"bodani.com" IN {
type master;
file "named.bodani.com";
allow-update { none; };
};
配置域名IP named.bodani.com
默认查找文件位置为 named.conf 中 directory变量指定位置
$cp /var/named/named.localhost /var/named/named.bodani.com
$vim /var/named/named.bodani.com
$TTL 1D
@ IN SOA @ rname.invalid. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS @
A 127.0.0.1
AAAA ::1
node IN A 10.2.0.10
node IN A 10.2.0.11
node IN A 10.2.0.12
node IN A 10.2.0.13
node IN A 10.2.0.14
node IN A 10.2.0.15
3 启动named
检验配置
$ named-checkconf
启动服务
$service named start
$service named status
4 测试
$ ss -tuln | grep 53
vim /etc/resove.conf (指定域名服务器)
nameserver 127.0.0.1
$ nslookup node.bodani.com 127.0.0.1
Server: 127.0.0.1
Address: 127.0.0.1#53
Name: node.bodani.com
Address: 10.2.0.13
Name: node.bodani.com
Address: 10.2.0.11
Name: node.bodani.com
Address: 10.2.0.12
Name: node.bodani.com
Address: 10.2.0.15
Name: node.bodani.com
Address: 10.2.0.14
Name: node.bodani.com
Address: 10.2.0.10