CentOS7 set up DNS server

Step 1: Install
[root @ localhost ~] # yum install the bind
[root @ localhost ~] # systemctl STOP firewalld // disable the firewall
[root @ localhost ~] # setenforce 0 // Close selinux
Step 2: Edit the configuration file
- . ---- 1 edit master configuration file ------
[the root @ localhost ~] # VI /etc/named.conf
Options {
the listen-Port 53 is ON {192.168.80.10;}; // server into their own of the IP
the listen-ON-V6 {Port 53 is ::. 1;};
Directory "/ var / the named";
the dump-File "/var/named/data/cache_dump.db";
statistics-File "/ var / the named / Data /named_stats.txt ";
memstatistics-file" /var/named/data/named_mem_stats.txt ";
the allow the any-Query {;}; // anyone can access the
save and exit
----- 2 edit the zone configuration file. -------
[root @ localhost ~] # vi /etc/named.rfc1912.zones
..................
// forward zone configuration
Zone "hello.com" {the IN
type Master;
File "hello.com.zone";
the allow-Update {none;};
};
// reverse zone configuration
zone "80.168.192.in-addr.arpa" IN {
Master of the type;
file "hello.com.local";
the allow-Update {none;};
};
// others do not move
to save and exit
. --------3 forward zone data editing configuration files ---- ----
[the root @ localhost ~] # CD / var / the named
[the root @ localhost the named] -p named.localhost hello.com.zone CP #
[the named the root @ localhost] # VI hello.com.zone
$ the TTL 1D
the IN rname.invalid the SOA @ @ (.
0; Serial
1D; Refresh
IH; the retry
1W; The expire
3H); Minimum
the NS @
A // this server address 192.168.80.10
www IN A 192.168.80.10 //www.hello.com corresponding address
ftp IN A 192.168.80.10 //ftp.hello.com address corresponding
mail IN CNAME www //mail.hello.com is a www.hello.com another name

  • IN A 192.168.80.2 // If the suffix is hello.com but the previous contents of the record does not return when this address 192.168.80.2 to query the host
    to save and exit
    --------- 4. Edit configuration data reverse zone file ------------
    [root @ localhost named] # cp -p hello.com.zone hello.com.local
    [root @ localhost named] # vi hello.com.local
    $ TTL 1D
    @ the SOA @ rname.invalid the IN (.
    0; Serial
    1D; Refresh
    IH; the retry
    1W; The expire
    3H); Minimum
    the NS @
    A 192.168.80.10
    10 the IN www.hello.com the PTR.
    save and exit
    step: start service
    [root @ named localhost] # systemctl Start named
    [root @ localhost named] # netstat -anpu | grep name // View service running state, UDP 53 ports in listening
    fourth step: testing, validation
    [root @ localhost named] # vi / etc / resolv.conf
    nameserver 192.168.80.10
    save and exit
    [root @ localhost ~] # yum provides nslookup // query installation nslookup command
    [root @ localhost ~] # yum -y install the bind-utils
    [root @ localhost ~] # nslookup www.hello.com
    successful show:
    Server: 192.168. 80.10
    Address: 192.168.80.10 # 53

The Name: www.hello.com
Address: 192.168.80.10
[root @ localhost ~] # nslookup 192.168.80.10
successful show:
Server: 192.168.80.10
Address: 192.168.80.10 # 53

10.80.168.192.in-addr.arpa name = www.hello.com.

The main building, the domain name server from the
first step: set up a main (master configuration) from the synchronization server
[the root @ localhost ~] # VI /etc/named.rfc1912.zones
Zone "hello.com" {the IN
type Master;
File " hello.com.zone ";
the allow-Update {192.168.80.20;}; // IP address from the server configured
Also {-Notify 192.168.80.20;};
};
save and exit
the second step: the configuration server (from the server configuration)
-------- 1. DNS server -------- structures (refer to the above configuration)
// edit the main configuration file
[the root @ localhost ~] # VI /etc/named.conf
Options {
listen-on port 53 {192.168.80.20; }; // to listening server IP (master address)
the listen-ON-V6 {Port 53 is ::. 1;};
Directory "/ var / the named";
dump- File "/var/named/data/cache_dump.db";
statistics-File "/var/named/data/named_stats.txt";
File-memstatistics "/var/named/data/named_mem_stats.txt";
the allow the any-Query {;}; // anyone can access the
save and exit
-------- 2 Setting master-slave synchronization server (from. configuration server) ----------
[the root @ localhost ~] # VI /etc/named.rfc1912.zones
// forward zone arranged
zone "hello.com" {the IN
type Slave;
Masters {192.168 .80.10;};
File "slaves / hello.com.zone";
the allow-Notify {192.168.80.10;};
};
// reverse zone arranged
zone "80.168.192.in-addr.arpa" {the IN
type Slave ;
{192.168.80.10;}; Masters
File "slaves / hello.com.local";
the allow-the Notify {192.168.80.10;};
};
save and exit
step Three: start services
[root @ localhost named] # systemctl start named
[root @ localhost named] # netstat -anpu | grep name // View service running state, UDP 53 ports in listening
successful show:
netstat -anpu | grep name
Proto Recv-Q the Send-Q Local Address Foreign Address State PID / Program name
0 0 192.168.80.20:53 0.0.0.0 UDP: 1102 / the named
udp6, 0 :: 0. 1: 53 is :::
1102 / the named
[the root @ localhost ~] # CD / var / the named / slaves /
[the root @ localhost slaves] # ls
successful show:
hello.com.local hello.com.zone
[root @ localhost slaves] # yum install the bind-utils
[root @ localhost ~] # nslookup www.hello.com
successful show:
Server: 1 ::
Address: # 1 :: 53

Name: www.hello.com
the Address: 192.168.80.10
Step Four: test validation
----- master server to modify the configuration -----
[the root @ localhost ~] # VI /var/named/hello.com.zone
the TTL 1D $
@ @ the IN rname.invalid the SOA. (
. 1; SEQ ID NO serial // modify, edit up
1D; Refresh
IH; the retry
1W; The expire
3H); Minimum
the NS @
A 192.168.80.10
WWW the IN A 192.168.80.10
FTP IN A 192.168.80.20 // ftp modified address, to verify
mail IN CNAME www

  • IN A 192.168.80.2
    save and exit
    [root @ localhost ~] # systemctl restart named // restart dns service
    [root @ localhost ~] # nslookup ftp.hello.com // ftp address parsing
    successful show
    Server: 192.168.80.10
    Address: 192.168 .80.10 # 53

The Name: ftp.hello.com
Address: 192.168.80.20
-------- from the server to verify ---------
[root @ localhost ~] # nslookup ftp.hello.com
successful show:
Server: 1 ::
Address: 1 :: 53 #

The Name: ftp.hello.com
Address: 192.168.80.20
// test success

Guess you like

Origin blog.51cto.com/14519331/2438639