> CentOS > CentOS入门 >

CentOS 7 DNS 服务器设置

vim /etc/sysconfig/network-scripts/ifcfg-eno16777736
DNS1=192.168.1.100
 
vim /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=lin01.example.local
 
vim /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
 
vim /etc/resolv.conf
nameserver 192.168.1.100
 
systemctl restart network.service
 
yum install bind bind-utils
service named start
cp /etc/named.conf /etc/named.conf.bak
vim /etc/named.conf
options {
        listen-on port 53 { 127.0.0.1; 192.168.1.100; }; #need change
        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     { localhost; 192.168.1.0/24;}; #need change
        recursion yes;
 
        dnssec-enable yes;
        dnssec-validation yes;
        dnssec-lookaside auto;
 
        /* 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";
#add following
zone "example.local" IN {
        type master;
        file "example.zone";
};
zone "1.168.192.in-addr.arpa" IN {
        type master;
        file "192.168.1.zone";
 
cp /var/named/named.localhost /var/named/example.zone
vim /var/named/example.zone
$TTL 1D
@       IN      SOA     lin01.example.local. root.example.local. (
                0       ; serial
                1D      ; refresh
                1H      ; retry
                1W      ; expire
                3H )    ; minimum
@       IN      NS      lin01.example.local.
@       IN      A       192.168.1.100
@       IN      A       192.168.1.91
@       IN      A       192.168.1.92
lin01   IN      A       192.168.1.100
lin10   IN      A       192.168.1.91
lin09   IN      A       192.168.1.92
 
cp /var/named/named.localhost /var/named/192.168.1.zone
vim /var/named/192.168.1.zone
$TTL 1D
@       IN      SOA     lin01.example.local. root.example.local. (
                0       ; serial
                1D      ; refresh
                1H      ; retry
                1W      ; expire
                3H )    ; minimum
@       IN      NS      lin01.example.local.
@       IN      PTR     example.local.
lin01   IN      A       192.168.1.100
lin09   IN      A       192.168.1.92
lin10   IN      A       192.168.1.91
100     IN      PTR     lin01.example.local.
91      IN      PTR     lin10.example.local.
92      IN      PTR     lin09.example.local.
 
systemctl start named.service
systemctl status named.service
systemctl restart named.service
systemctl enable named

 
(责任编辑:IT)