背景
为了方便记忆,我们的线上服务器都按照一定规则定义了hostname,这样就不用记忆ip了,之前机器很少,直接在每台机器上配置了host(/etc/hosts)就行了,但是每次增加机器就要逐台修改host配置,比较麻烦,想着内部配置一个DNS就能很好解决这个问题。
安装
yum install named bind bind-chroot bind-utils
配置
vim /etc/named.conf
options {
listen-on port 53 { any; };
listen-on-v6 port 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;};
recursion yes;
dnssec-enable yes;
dnssec-validation yes;
bindkeys-file "/etc/named.iscdlv.key";
managed-keys-directory "/var/named/dynamic";
pid-file "/run/named/named.pid";
session-keyfile "/run/named/session.key";
};
logging {
channel default_debug {
file "data/named.run";
severity dynamic;
};
};
zone "." IN {
type hint;
file "named.ca";
};
zone "ydh.net" {
type master;
file "/var/named/ydh.net.zone";
};
vim /var/named/ydh.net.zone
$TTL 3H
@ IN SOA @ ydh.net. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
@ IN NS ns.ydh.net.
ns IN A 10.xxx.xxx.xxx
www IN A 10.xxx.xxx.xxx
t01.bj IN A 10.xxx.xxx.xxx
启动服务
systemctl restart named.service
设置开机启动
systemctl enable named
使用DNS服务器
vim /etc/resolv.conf
nameserver 10.xxx.xxx.xxx
测试
ping t01.bj.ydh.net
看能否通
原文链接:https://www.f2er.com/centos/379018.html