linux builds DNS server 3

1. For the installation of bind 9, it is assumed that bind 9 has been installed through apt get

2. Enter the directory / etc/bind

3. Create a zone record file (similar to db.xxx): Here I create db.testlyhh.com

4. Edit the named.conf.default-zones file and add the following:

  1. zone "testlyhh.com" {  
  2.         type master;  
  3.         file "/etc/bind/db.testlyhh.com";    #Indicates the location of the zone record file
  4. };  
5. Edit our region record file db.testlyhh.com as follows:

[before that, we should first popularize a little knowledge: the complete domain name of www.baidu.com should be like this, www.baidu.com. Finally, another small dot stands for the root domain name:

baidu.com. Represents the domain

WWW is actually a host in baidu.com. Domain. Its name is www

So the following configuration aaa, bbb and ccc are all hosts. We have specified the alias of ccc host, which is also called bbb

For details, please refer to the above: DNS resolution process

]

  1. $TTL    604800  
  2. @       IN      SOA     testlyhh.com. root.localhost. (  
  3.                               1         ; Serial  
  4.                          604800         ; Refresh  
  5.                           86400         ; Retry  
  6.                         2419200         ; Expire  
  7.                          604800 )       ; Negative Cache TTL  
  8. ;  
  9. @       IN      NS      localhost.  
  10. testlyhh.com IN      NS      192.168.1.108  
  11.   
  12. aaa     IN      A       192.168.1.108  
  13. bbb     IN      A       192.168.1.108  
  14. ccc     IN      CNAME   bbb  
6. Edit the file named.conf.options to provide dns services for other machines in the LAN (modify the listen on statement of option):
  1. //acl "trusted" {  
  2. //        127.0.0.1;    # ns1 - can be set to localhost  
  3. //        192.168.1.108;    # ns2  
  4. //};  
  5.   
  6. options {  
  7.         directory "/var/cache/bind";  
  8.   
  9.         //Recursion yes; enable recursion addressing
  10.         //Allow recursion {trusted;}; ා allow "trusted" list to recursively address
  11.         listen-on port 53 {127.0.0.1;192.168.1.108; };   #Fill in the intranet IP address of ns1 here. Monitor on Intranet only
  12.         allow-transfer { none; };      #zone transfer is disabled by default
  13.   
  14.         // If there is a firewall between you and nameservers you want  
  15.         // to talk to, you may need to fix the firewall to allow multiple  
  16.         // ports to talk.  See http://www.kb.cert.org/vuls/id/800113  
  17.   
  18.         // If your ISP provided one or more IP addresses for stable  
  19.         // nameservers, you probably want to use them as forwarders.  
  20.         // Uncomment the following block, and insert the addresses replacing  
  21.         // the all-0's placeholder.  
  22.   
  23.         // forwarders {  
  24.         //      0.0.0.0;  
  25.         // };  
  26.   
  27.         //========================================================================  
  28.         // If BIND logs error messages about the root key being expired,  
  29.         // you will need to update your keys.  See https://www.isc.org/bind-keys  
  30.         //========================================================================  
  31.         dnssec-validation auto;  
  32.   
  33.         auth-nxdomain no;    # conform to RFC1035  
  34.         listen-on-v6 { any; };  
  35. };  
After configuration, restart the service:
  1. service bind9 restart  
Show me the contents of my / etc/bind Directory:



7. Next, let's see if the DNS configuration is effective. First, indicate our bind9 server address on the ubuntu local machine:

You need to edit the file / etc/resolv.conf, and add a line before the beginning of nameserver to indicate the domain name:

  1. # Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)  
  2. #     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN  
  3. nameserver 192.168.1.108  
  4. #nameserver 127.0.1.1  
  5. search DHCP HOST  

Next, ping aaa.testlyhh.com:


Configuration of this domain name succeeded.


Reprinted at: http://blog.csdn.net/lyhDream/article/details/77620932

Keywords: DNS firewall Ubuntu glibc

Added by jack_wetson on Tue, 31 Mar 2020 16:08:01 +0300