redhat7.3 dns服务器配置

简介:

1.基本配置

systemctl stop firewalld.service

systemctl disable firewalld.service

setenforce 0

nmcli connection add con-name in ifname ens33 ipv4.addresses 192.168.1.10/24 type ethernet ipv4.method manual(内网网卡)

nmcli connection add con-name out ifname ens38 ipv4.addresses 192.168.2.10/24 type ethernet ipv4.method manual(外网网卡)

2.配置简单dns服务器

yum install -y bind bind-utils

2.1修改主配置文件

vim /etc/named.conf(修改该文件)

   listen-on port 53 { any; };

   allow-query     { any; };

       zone "fengxiaoli41.com" IN {

        type master;

        file "fengxiaoli41.com.lan";

        allow-update {none;};

};

zone "1.168.192.in-addr.arpa" IN {

        type master;

        file "1.168.192.lan";

        allow-update {none;};

 

};


2.2编辑正解区域

cd /var/named/

cp named.localhost fengxiaoli41.com.lan

vim fengxiaoli41.com.lan

$TTL 665

@IN SOAfengxiaoli41.com. 123@qq.com (

2017062900; serial

3600; refresh

1800; retry

604800; expire

665 ); minimum

@IN NSfengxiaoli41.com.

fengxiaoli41.com. IN A 192.168.1.10

www.fengxiaoli41.com. IN CNAME fengxiaoli41.com.

client.fengxiaoli41.com. IN A 192.168.1.200

@       IN NS   slave.fengxiaoli41.com.

slave.fengxiaoli41.com. IN A 192.168.1.100

2.3编辑反解区域

cp fengxiaoli41.com.lan 1.168.192.lan

vim 1.168.192.lan  

$TTL 665

@IN SOAfengxiaoli41.com. 123@qq.com (

2017062900; serial

3600; refresh

1800; retry

604800; expire

665 ); minimum

@IN NSfengxiaoli41.com.

10      IN PTR fengxiaoli41.com.

200     IN PTR client.fengxiaoli.com.

100     IN PTR slave.fengxiaoli.com.

chown named:named fengxiaoli41.com.lan

chown named:named 1.168.192.lan

2.4重启服务并测试

systemctl restart named

systemctl status named

dig fengxiaoli41.com

3.配置chroot环境

yum install -y bind-chroot

/usr/libexec/setup-named-chroot.sh /var/named/chroot/ on

systemctl stop named.service

systemctl disabled named

systemctl enable named-chroot.service

systemctl start named-chroot

dig fengxiaoli41.com

如果dns只为内网提供解析到此可以结束。


4.配置分离解析的dns(与2,3步独立)

4.1修改主配置文件

 vim /etc/named.conf

listen-on port 53 { any; };

allow-query     { any; };

acl in {192.168.1.0/24;};

acl out { ! 192.168.1.0/24; any;};

view "internal"{

match-clients { in; localhost;};

zone "." IN {

        type hint;

        file "named.ca";

};

zone "fengxiaoli41.com" IN {

        type master;

        file "fengxiaoli41.com.lan";

        allow-update {none;};

};

zone "1.168.192.in-addr.arpa" IN {

        type master;

        file "1.168.192.lan";

        allow-update {none;};

 

};

include "/etc/named.rfc1912.zones";

include "/etc/named.root.key";

};

 注意所有区域都要包含在view里

view "external"{

match-clients {out;};

zone "." IN {

        type hint;

        file "named.ca";

};

zone "fengxiaoli41.com" IN {

        type master;

        file "fengxiaoli41.com.wan";

        allow-update {none;};

};

zone "2.168.192.in-addr.arpa" IN {

        type master;

        file "2.168.192.wan";

        allow-update {none;};

 

};

};

cd /var/named/chroot/var/named/

4.2编辑内网正解反解区域

vim fengxiaoli41.com.lan

$TTL 665

@IN SOAfengxiaoli41.com. 123@qq.com (

2017062900; serial

3600; refresh

1800; retry

604800; expire

665 ); minimum

@IN NSfengxiaoli41.com.

fengxiaoli41.com. IN A 192.168.1.10

www.fengxiaoli41.com. IN CNAME fengxiaoli41.com.

client.fengxiaoli41.com. IN A 192.168.1.200

@       IN NS   slave.fengxiaoli41.com.

slave.fengxiaoli41.com. IN A 192.168.1.100


vim 1.168.192.lan  

$TTL 665

@IN SOAfengxiaoli41.com. 123@qq.com (

2017062900; serial

3600; refresh

1800; retry

604800; expire

665 ); minimum

@IN NSfengxiaoli41.com.

10      IN PTR fengxiaoli41.com.

200     IN PTR client.fengxiaoli.com.

100     IN PTR slave.fengxiaoli.com.


4.3编辑外围正解反解区域

vim fengxiaoli41.com.wan

$TTL 665

@IN SOAfengxiaoli41.com. 123@qq.com (

2017062900; serial

3600; refresh

1800; retry

604800; expire

665 ); minimum

@IN NSfengxiaoli41.com.

fengxiaoli41.com. IN A 192.168.2.10

 

vim 2.168.192.wan

$TTL 665

@IN SOAfengxiaoli41.com. 123@qq.com (

2017062900; serial

3600; refresh

1800; retry

604800; expire

665 ); minimum

@IN NSfengxiaoli41.com.

10IN PTR fengxiaoli41.com.

4.4设置权限重启服务

chown named:named -R  /var/named/chroot/var/named/*

systemctl restart named-chroot

5.主从服务器配置(在2或者4的基础上配置)

5.1主服务器配置

 vim /etc/named.conf

 allow-transfer { 192.168.1.0/24;};

cd /var/named/chroot/var/named/

vim fengxiaoli41.com.lan

@       IN NS   slave.fengxiaoli41.com.

slave.fengxiaoli41.com. IN A 192.168.1.100

 

vim 1.168.192.lan

100     IN PTR slave.fengxiaoli.com.

 

5.2从服务器配置(注意firewalldselinux

nmcli connection add con-name in ifname ens33 ipv4.addresses 192.168.1.100/24 type ethernet ipv4.method manual

yum install -y bind-utils bind

vim /etc/named.conf

  listen-on port 53 { any; };

  allow-query     { any; };

  zone "fengxiaoli41.com" IN {

        type slave;

        masters { 192.168.1.10; };

        file "slaves/fengxiaoli.com.lan";

};

zone "1.168.192.in-addr.arpa" IN {

        type slave;

        masters { 192.168.1.10; };

        file "slaves/1.168.192.lan";

 

};

systemctl restart named

ll /var/named/slaves/


本文转自 fxl风 51CTO博客,原文链接:http://blog.51cto.com/fengxiaoli/1944870

相关文章
|
1月前
|
弹性计算 ice
阿里云4核8G云服务器配置价格:热门ECS实例及CPU处理器型号说明
阿里云2025年4核8G服务器配置价格汇总,涵盖经济型e实例、计算型c9i等热门ECS实例,CPU含Intel Xeon及AMD EPYC系列,月费159元起,年付低至1578元,按小时计费0.45元起,实际购买享折扣优惠。
406 1
|
1月前
|
弹性计算 定位技术 数据中心
阿里云服务器配置选择方法:付费类型、地域及CPU内存配置全解析
阿里云服务器怎么选?2025最新指南:就近选择地域,降低延迟;长期使用选包年包月,短期灵活选按量付费;企业选2核4G5M仅199元/年,个人选2核2G3M低至99元/年,高性价比爆款推荐,轻松上云。
161 11
|
1月前
|
存储 弹性计算 监控
阿里云渠道商:如何挑选阿里云服务器配置?
本文详解通用型、计算型、内存型等实例适用场景,结合性能评估与成本优化策略,助力用户按需选择。以日均1万访问企业网站为例,2核4G+3M带宽月费约200元,性价比高。合理配置更省钱。
|
1月前
|
存储 弹性计算 网络协议
超详细的阿里云服务器购买流程,ECS自定义购买配置教程
本文详细图解阿里云ECS服务器自定义购买全流程,涵盖付费模式、地域选择、网络配置、实例规格、镜像、存储、安全组及登录设置等核心步骤,助您轻松掌握专业级云服务器搭建方法。
|
1月前
|
弹性计算
阿里云ECS云服务器8核16G配置收费价格,多种ECS实例CPU及费用清单
阿里云8核16G云服务器价格因实例类型而异。计算型c9i约743元/月,一年6450元(7折);通用算力型u1仅673元/月,一年4225元(5.1折)。实际价格享时长折扣,详情见ECS官网。
|
1月前
|
弹性计算 Windows
阿里云香港服务器收费价格:香港ECS和轻量应用服务器配置介绍
2025年阿里云香港服务器优惠汇总:ECS 2核4G+5M带宽仅199元/年;轻量服务器30M带宽24元/月起,200M峰值带宽25元/月起。轻量性价比高,适合个人及中小企业建站、跨境业务,具体配置价格详见官方活动页。
812 1
|
2月前
|
弹性计算 定位技术 数据中心
阿里云服务器选择方法:配置、地域及付费模式全解析
2025阿里云服务器选购指南:就近选择地域以降低延迟,企业用户优选2核4G5M带宽u1实例,仅199元/年;个人用户可选2核2G3M带宽ECS,99元/年起。长期稳定业务选包年包月,短期或波动场景用按量付费,轻松搭建网站首选高性价比配置。

相关产品

  • 云解析DNS
  • 推荐镜像

    更多