Common DNS Configuration

Source: Internet
Author: User
Tags domain server mx record

In the previous article we built a master-slave DNS, but in the actual application, only build up is not enough, the DNS to add a variety of records is the daily maintenance of DNS more common problems, such as the addition of a records, cname,mx,ptr and so on.

Add a record

In the master-slave configuration, the primary DNS is typically modified to synchronize the primary DNS data from DNS.

Edit the Zone profile of the master node to add a row of records directly at the end, with the serial value + 1:

2001; Serial # Change the serial value of the original 2000 to 2001, making the slave synchronous
$ORIGIN a a a a # Add a row of records

The rndc Reload is executed to make the configuration file effective, and the zone file on the slave is also updated.

Validation results:

[Email protected] ~]# host domain server:name: has address

Add a CNAME record

As with the add a record, a row of records is appended to the end of the file:

Tryingstuff CNAME # at the end of the "." Cannot be ignored

Will serial +1

Execute RNDC Reload to make the configuration file effective.

Validation results:

[Email protected] ~]# host domain server:name: is a alias for have address

Add MX record

Similarly, modify the zone configuration file, serial +1, the zone file at the end of adding a row of results:

# vim/var/named/chroot/etc/ MX 3 # 3 indicates priority, lower number, higher priority

Perform RNDC reload, test results:

[Email protected] ~]# host domain server:name: Mail is handled by 3

adding PTR records

In many scenarios it is necessary to use PTR reverse parsing, where the PTR record is added on the original basis:

Edit the View profile on master to include the PTR zone:

[[email protected] etc]# cat view.conf view  "View-test"  { zone  " " {    type master;    file " ";     allow-transfer {;};   notify yes;  also-notify {;};}; zone  ""  {  #  here is the added reverse resolution domain name, which represents resolving 192.168 segments of the host          type    master;         file     "";  # zone  file name          allow-transfer {       ;        };         notify  yes;        also-notify {       ;        };   };};

After you have added a domain with PTR, you need to specify the resolved content in the specified file:

[[email protected] etc]# cat  $TTL  3600        ; 1 hour@                  IN SOA  (                                  2000        ; serial                                 900         ; refresh  (15 minutes)                                   600        ; retry  (10  minutes)                                  86400       ; expire  (1 day)                                   3600       ; minimum  (1 hour)                                  )                           NS   in   ptr .  #  added reverse parse record, corresponding IP is

Modify the properties of the PTR zone file on master:

Chown named.named Rndc Reload

When the node on slave is not synchronizing the PTR zone file on master, the zone configuration file needs to be set first.

Modify the configuration of the slave node/var/named/chroot/etc/view.confg to increase the zone configuration of PTR:

Zone "" {type slave;       Masters {;};       Masterfile-format Text; File "";};

Execute RNDC Reload, synchronize ptr zone file, at this time, you can see slave synchronized files on slave.

[Email protected] ~]# cat/var/named/chroot/etc/ $ORIGIN. $TTL 3600; 1 in SOA (2001; serial900; refresh (minutes); retry (minutes) 86400; Expire (1 D ay) 3600; Minimum (1 hour)) NS $ORIGIN PTR

Test parsing results:

[Email protected] ~]# host domain server:name: domain name pointer #返回的结果正确

Using DNS to implement load balancing for services

In the case of multiple IPs for a domain name, DNS polls multiple IPs, which enables the load balancing function. DNS polls only according to its own configuration information and does not detect whether the backend service nodes are available.

Add an A record directly on the zone profile on master, serial The value +1.

[Email protected] etc]# host domain server:name: has address # back two lines of information has address

Configure DNS view (smart DNS)

Intelligent DNS refers to the best service site that is returned to the user by judging the source of the user. The simple thing is to allow the different users of Unicom and telecom to visit the same site, respectively, to resolve the request to the same server as the user network to enhance the user experience. Only DNS can also detect the running state of the backend node, and if a node failure is found on the backend, the request is sent to a host that can provide a normal service.

Configure smart DNS to modify the/etc/named.conf file on master:

ACL group1 {# adds two group configurations to the original base, plus 192.168 before include. 1.10; # Two different DNS servers were specified in two group.}; ACL group2 {;}; Include "/var/named/chroot/etc/view.conf";

Edit the view.conf file on the master node, add group, and empty the previous view.conf file:

[email protected] etc]# cat View.confview "GROUP1" {match-clients {group1;};      Zone "" {type master; File "";};};     View "GROUP2" {match-clients {group2;};     Zone "" {type master; File "";};};

Create two specified zone files, respectively:

[[email protected] ~]# cat /var/named/chroot/etc/  $ORIGIN &NBSP, $TTL  3600 ; 1  IN SOA  (          2007 ; serial           900       ;  refresh   (15 minutes)           600        ; retry  (10 minutes)            86400     ; expire  (1 day)            3600      ; minimum  (1  hour)           )      NS$ORIGIN    A       a
[[email protected] ~]# cat /var/named/chroot/etc/  $ORIGIN &NBSP, $TTL  3600 ; 1  IN SOA  (          2007 ; serial           900       ;  refresh   (15 minutes)           600        ; retry  (10 minutes)            86400     ; expire  (1 day)            3600      ; minimum  (1  hour)           )      NS$ORIGIN    A       a

The specified resolved IP of two files is different.

Change the permissions for two files and restart named:

Chown named.named group* systemctl Restart named

The test results, with as the client, initiate a parse request to DNS:

[Email protected] ~]# host domain server:name: has address

With as the client, the DNS initiates the parse request:

[Email protected] ~]# host domain server:name: has address

Different client parsing results are not the same, so that we can meet the requirements.

The process of intelligent DNS parsing:

1, in the named.conf file defines two group,group1 contains the client, group2 contains the of the client. The two group differentiates the source IP, and the source IP of the different group is parsed using a different zone file.

2, when the request to parse on (11), found this IP belongs to group1 (group2), so go to view/var/named/chroot/etc/view.conf this file.

3, in the view.conf file, respectively specify the resolution GROUP1 and group2 need to parse the zone file, so the system will automatically select its corresponding zone file according to the source IP.

4, in the zone file of Group1 and group2, respectively, corresponding parsing records are specified, respectively, and The system reads the corresponding zone file, returning the client with different parsing results.


The synchronization configuration of the view.conf file is emptied here, and the synchronization parameters can be added in the original way. Synchronize settings for each defined domain.

This article is from the "Trying" blog, make sure to keep this source

Common DNS Configuration

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.