[root@localhost ~]# yum install -y bind*
[root@localhost ~]# systemctl start named
#dns开机启动
[root@localhost ~]# systemctl enable named
Created symlink from /etc/systemd/system/multi-user.target.wants/named.service to /usr/lib/systemd/system/named.service.
[root@localhost named]# cat /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.
//
// 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 { any; }; //修改点
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";
recursing-file "/var/named/data/named.recursing";
secroots-file "/var/named/data/named.secroots";
allow-query { any; }; //修改点
#forwarders { 192.168.50.1; 114.114.114.114; };
/*
- 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.root.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";
[root@localhost named]# cat /etc/named.rfc1912.zones
// 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 "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; };
};
zone "elocal-999.com" IN {
type master;
file "/etc/named/elocal-999.com.zone";
allow-update { none; };
};
zone "50.168.192.in-addr.arpa" IN {
type master;
file "/etc/named/elocal-999.com.local";
allow-update { none; };
};
[root@localhost named]# cat /etc/named/elocal-999.com.zone
$TTL 1D
@ IN SOA @ rname.invalid. (
0 ; serial
1H ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS @
A 192.168.50.198 //DNS地址
www IN A 192.168.50.198 //www.elocal-999.com 指向的地址(实际情况可能与DNS地址不同)
[root@localhost named]# cat /etc/named/elocal-999.com.local
$TTL 1D
@ IN SOA @ rname.invalid. (
0 ; serial
1H ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS @
A 192.168.50.198 //DNS地址
198 IN PTR www.elocal-999.com. //192.168.50.198 指向的域名,反向查找
[root@localhost named]# systemctl restart named
[root@localhost etc]# chgrp named elocal-999.com.zone
[root@localhost etc]# chgrp named elocal-999.com.local
//TODO 网关主机192.168.50.1 ,DNS服务器再同网段(192.168.50.198)这样不好用?