配置一个简单的DNS服务

本文详细介绍如何在Linux环境下配置DNS服务,包括更改主机名、安装DNS服务、编辑主配置文件以及子配置文件等关键步骤,确保DNS服务的正常运行。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 

更改主机名

hostnamectl set-hostname gitlab.ai

安装DNS服务

yum -y install bind*

编辑主配置文件

vim /etc/named.conf

//
// named.conf
//
// Provided by Red Hat bind package to configure the ISC BIND named(8) DNS
// server as a caching only nameserver (as a localhost DNS resolver only).
//
// See /usr/share/doc/bind*/sample/ for example named configuration files.
//

options {
	directory 	"/var/named";
	allow-recursion { 192.168.0.0/24; };
};

zone "." IN {
	type hint;
	file "named.ca";
};

zone "localhost" IN {
	type master;
	file "named.localhost";
	allow-transfer { none; };
};

zone "0.0.127.in-addr.arpa" IN {
	type master;
	file "named.loopback";
	allow-transfer { none; };
};

zone "oa.ai" IN {
	type master;
	file "oa.ai.zone";
	allow-transfer { 192.168.0.200; };
};

/*zone "0.168.192.in-addr.arpa" IN {
	type master;
	file "0.168.192.in-addr";
	allow-transfer { 192.168.0.200; };
};*/

zone "gitlab.ai" IN {
	type master;
	file "gitlab.ai.zone";
	allow-transfer { 192.168.0.200; };
};

/*zone "100.168.192.in-addr.arpa" IN {
	type master;
	file "100.168.192.in-addr";
	allow-transfer { 192.168.0.200; };
};*/

 

编辑子配置文件

cd /var/named/

vim 100.168.192.in-addr

$TTL    86400
@               IN      SOA     ns.oa.ai.   root.oa.ai. (
                        2019012201
                        2H
                        5M
                        1D
                        6H)
                IN      NS      ns.gitlab.ai.
254             IN      PTR     www.oa.ai.

vim oa.ai.zone

$TTL    86400
@               IN      SOA     ns.oa.ai.       root.oa.ai. (
                        2019012202
                        2H
                        5M
                        1D
                        6H)
                IN      NS      ns.gitlab.ai.
                IN      MX  10  mail
mail            IN      A       192.168.100.254
www             IN      A       192.168.100.254
oa.ai.          IN      A       192.168.100.254
*.oa.ai.        IN      A       192.168.100.254
ftp             IN      CNAME   www

 vim 0.168.192.in-addr

$TTL    86400
@               IN      SOA     ns.gitlab.ai   root.gitlab.ai. (
                        2019012201
                        2H
                        5M
                        1D
                        6H)
                IN      NS      ns.gitlab.ai.
200             IN      PTR     www.gitlab.ai.

 

 vim gitlab.ai.zone

$TTL    86400
@               IN      SOA     ns.gitlab.ai.   root.gitlab.ai. (
                        2019012202
                        2H
                        5M
                        1D
                        6H)
                IN      NS      ns.gitlab.ai.
                IN      MX  10  mail
mail            IN      A       192.168.0.200
www             IN      A       192.168.0.200
gitlab.ai.      IN      A       192.168.0.200
*.gitlab.ai.    IN      A       192.168.0.200
ftp             IN      CNAME   www

 

chown named.named /var/named/named.ca 
chown named.named /var/named/oa.ai.zone 
chown named.named /var/named/gitlab.ai.zone 
systemctl enable named
systemctl start named

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值