使用Bind搭建DNS服务

安装

ubuntu: apt install bind9 -y

centos: yum install bind -y

配置

/etc/bind/named.conf.options

options {
    directory "/var/cache/bind";

    auth-nxdomain no;    # conform to RFC1035
    listen-on-v6 { any; };
    listen-on port 53 { 192.168.199.130; };
    allow-query { any; };
    forwarders { 192.168.199.1; };
    dnssec-enable no;
    dnssec-validation no;
    recursion yes;
};

192.168.199.130是本机。192.168.199.1是网关。

注意格式严格按照示例,不能省略空格。

/etc/bind/named.conf.local

zone "host.com" IN {
    type master;
    file "host.com.zone";
    allow-update { 192.168.199.130; };
};

这样就添加了一个zone,zone的文件在/var/cache/bind(named.conf.options中配置)目录下。

/var/cache/bind/host.com.zone 
$ORIGIN host.com.
$TTL 600;
@ IN SOA dns.host.com. dnsadmin.host.cm. (
    20211019;
    10800;
    900;
    60480;
    86400;
    )
    NS dns.host.com.
$TTL 60;
dns    A    192.168.199.130
www    A    192.168.199.130

配置了host.com这个zone中的两台服务器,dns和www。

校验

named-checkconf    --验证配置正确

named-checkzone host.com /var/cache/bind/host.com.zone    --验证区域配置文件正确

重启服务

service bind9 restart

验证

dig -t A dns.host.com @192.168.199.130 +short

排错

默认,日志文件在/var/log/syslog中

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

noodle_bear

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值