搭建自己的域名解析服务器
安装
yum -y install bind
然后就要更改配置文件,linux的服务依靠配置文件的读取,你怎么写配置文件,他就怎么来
现在说一下修改配置文件的思路;
1.首先肯定要修改主配置文件(named.conf)(擒贼先擒王),在里面要告诉他你有哪些要求,还有需要的其他配置文件的位置,(named.rfc1912.zones)就是这个文件;然后当然就要改这个文件了;这个是区声明文件,告诉主配置文件解析的数据库文件的位置,我们的目的是从ip到域名(类似于www.baidu.com格式),也要能从域名到ip,所以我们要告诉计算机那些能够被解析
所以就用到了name.43.168.192(反向)和gaoqi.com.zone(正向)这两个文件;并且要知道他们位置在哪;
文件关系为:主配置文件(named.conf)–>区声明文件(named.rfc1912.zones)->正向解析(gaoqi.com.zone)+反向解析(name.43.168.192);
然后重启就ok;
这里要记得更改一下权限;我的改了,不改启动不了,修改解析库文件所属组,改成named组chgrp named
例如:
chgrp named name.43.1687.192
权限问题自己看着改,也可能不改就行,也可能要改成root,每个人的操作不太一样。
配置文件的修改
1.named.conf
位置/etc/
//
// 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.
//
// See the BIND Administrator's Reference Manual (ARM) for details about the
// configuration located in /usr/share/doc/bind-{version}/Bv9ARM.html
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; };
/*
- If you are building an AUTHORITATIVE DNS server, do NOT enable recursion.
- If you are building a RECURSIVE (caching) DNS server, you need to enable
recursion.
- If your recursive DNS server has a public IP address, you MUST enable access
control to limit queries to your legitimate users. Failing to do so will
cause your server to become part of large scale DNS amplification
attacks. Implementing BCP38 within your network would greatly
reduce such attack surface
*/
recursion yes;
dnssec-enable yes;
dnssec-validation yes;
/* Path to ISC DLV key */
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";
};
*/
include "/etc/named.rfc1912.zones";
include "/etc/named.root.key";
2.named.rfc1912.zones
位置/etc/
// named.rfc1912.zones:
//
// Provided by Red Hat caching-nameserver package
//
// ISC BIND named zone configuration for zones recommended by
// RFC 1912 section 4.1 : localhost TLDs and address zones
// and http://www.ietf.org/internet-drafts/draft-ietf-dnsop-default-local-zones-02.txt
// (c)2007 R W Franks
//
// See /usr/share/doc/bind*/sample/ for example named configuration files.
//
zone "gaoqi.com" IN{
type master;
file "gaoqi.com.zone";
allow-update { none; };
};
zone "43.168.192.in-addr.arpa" IN{
type master;
file "name.43.168.192";
allow-update { none; };
};
/*
zone "localhost.localdomain" IN {
type master;
file "named.localhost";
allow-update { none; };
};
zone "localhost" IN {
type master;
file "named.localhost";
allow-update { none; };
};
zone "1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa" IN {
type master;
file "named.loopback";
allow-update { none; };
};
zone "1.0.0.127.in-addr.arpa" IN {
type master;
file "named.loopback";
allow-update { none; };
};
zone "0.in-addr.arpa" IN {
type master;
file "named.empty";
allow-update { none; };
};
*/
3.name.43.168.192
位置/var/named/
$TTL 1D
@ IN SOA gao.gaoqi.com. root.gao.gaoqi.com. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
IN NS gao.gaoqi.com.
IN NS g.gaoqi.com.
250 IN PTR ftp.gaoqi.com.
250 IN PTR gao.gaoqi.com.
251 IN PTR g.gaoqi.com.
252 IN PTR mail.gaoqi.com.
4.gaoqi.com.zone
/var/named/
$TTL 1D
@ IN SOA gao.gaoqi.com. root.gao.gaoqi.com. (
0 ; serial
1D ; refresssh
1H ; retry
1W ; expire
3H ) ; minimum
IN A 192.168.43.250
IN NS gao.gaoqi.com.
IN NS g.gaoqi.com.
IN MX 5 mail.gaoqi.com.
ftp IN A 192.168.43.250
gao IN A 192.168.43.250
g IN A 192.168.43.251
mail IN A 192.168.43.252
最后,我把防火墙直接关了,也省着开端口了,还有seliunx也要关掉;
systemctl stop firewalld
setenforce 0
systemctl restart named