# The Method of Optimizing DNS Configuration 

## Step 1  Configure Redundant DNS Server Address

This can prevent the situation that the domain name cannot be resolved after the single point of failure of DNS Server.

Take CentOS as an example:

Open the /etc/resolv.conf file on the host,

If only 1 IP is configured in the file, replace it with 2 IPs according to the following list:

| Data Center/Availability Zone| IP                         |
| ---------------------------- | -------------------------- |
| Beijing 2 Zone B               | 10.9.255.1, 10.9.255.2    |
| Beijing 2 Zone C               | 10.10.255.1, 10.10.255.2  |
| Beijing 2 Zone D               | 10.19.255.1, 10.19.255.2  |
| Beijing 2 Zone E               | 10.42.255.1, 10.42.255.2  |
| Ulanqab Zone A               | 100.65.128.2, 100.65.128.3 |
| Guangdong Zone B             | 10.13.255.1, 10.13.255.2  |
| Hong Kong Zone A and B       | 10.8.255.1, 10.8.255.2    |
| US(Los Angeles) Zone A           | 10.11.255.1, 10.11.255.2  |
| Singapore Zone B             | 10.35.224.212, 10.35.250.52|
| Singapore Zone A             | 10.35.255.1, 10.35.255.2  |
| TH(Bangkok), Thailand Zone A     | 10.31.255.1, 10.31.255.2  |
| US(Washington) Zone A            | 10.27.255.1, 10.27.255.2  |
| DE(Frankfurt), Germany Zone A    | 10.29.255.1, 10.29.255.2  |
| KR(Seoul), South Korea Zone A    | 10.33.255.1, 10.33.255.2  |
| RU(Moscow), Russia Zone A        | 10.39.255.1, 10.39.255.2  |
| JP(Tokyo), Japan Zone A          | 10.40.255.1,10.40.255.2   |
| Taiwan(Taipei), Taiwan Zone A        | 10.41.255.1,10.41.255.2   |
| AE(Dubai), UAE Zone A            | 10.44.255.1,10.44.255.2   |
| ID(Jakarta), Indonesia Zone A    | 10.45.255.1,10.45.255.2   |
| IN(Mumbai), India Zone A         | 10.47.255.1,10.47.255.2   |
| BR(Sao Paulo), Brazil Zone A     | 10.49.255.1,10.49.255.2   |
| GB(London), UK Zone A            | 10.50.255.1,10.50.255.2   |
| PH(Manila) Zone A                | 100.64.48.2,100.64.48.3   |
| TH(Bangkok), Thailand Zone B     | 10.31.255.11,10.31.255.10 |
| NG(Lagos) Zone A                 | 10.52.255.1,10.52.255.2   |
| Ho Chi Minh, Vietnam Zone A  | 100.64.0.2,100.64.0.3     |
| East China(Shanghai2) Zone B              | 10.23.255.1,10.23.255.2   |


## Step 2  Enable NSCD Service

Enabling the NSCD service in Linux can cache DNS resolution results locally. Within the TTL period, there is no need to repeatedly resolve through the DNS server, which accelerates DNS resolution speed and reduces the load on the DNS server.

Take CentOS as an example:

### 1、Install

    yum install nscd

### 2、Add configuration file /etc/nscd.conf

Content is as follows:

```markdown
#
# /etc/nscd.conf
#
# An example Name Service Cache config file. This file is needed by nscd.
#
# Legal entries are:
#
#       logfile                 <file>
#       debug-level             <level>
#       threads                 <initial #threads to use>
#       max-threads             <maximum #threads to use>
#       server-user             <user to run server as instead of root>
#               server-user is ignored if nscd is started with -S parameters
#       stat-user               <user who is allowed to request statistics>
#       reload-count            unlimited|<number>
#       paranoia                <yes|no>
#       restart-interval        <time in seconds>
#
#       enable-cache            <service> <yes|no>
#       positive-time-to-live   <service> <time in seconds>
#       negative-time-to-live   <service> <time in seconds>
#       suggested-size          <service> <prime number>
#       check-files             <service> <yes|no>
#       persistent              <service> <yes|no>
#       shared                  <service> <yes|no>
#       max-db-size             <service> <number bytes>
#       auto-propagate          <service> <yes|no>
#
# Currently supported cache names (services): passwd, group, hosts, services
#
#   logfile                 /var/log/nscd.log
    threads                 4
    max-threads             32
    server-user             nscd
    stat-user               somebody
    debug-level             5
    reload-count            5
    paranoia                no
    restart-interval        3600


    enable-cache            hosts           yes
    enable-cache            passwd          no
    enable-cache            group           no
    enable-cache            services        no
    positive-time-to-live   hosts           5
    negative-time-to-live   hosts           20
    suggested-size          hosts           211
    check-files             hosts           yes
    persistent              hosts           yes
    shared                  hosts           yes
    max-db-size             hosts           33554432
```markdown

### 3、Start service

    service nscd start

### 4、Add to startup

    chkconfig nscd on

### 5、If you need to stop the service

    service nscd stop
