User Tools

Site Tools


computers:dns_server_configuration

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
computers:dns_server_configuration [2012/06/13 12:16] – [Configuration] chkuocomputers:dns_server_configuration [2020/08/16 01:53] (current) chkuo
Line 4: Line 4:
 Download and install the packages Download and install the packages
 <code bash> <code bash>
-sudo apt-get install bind9 +sudo apt install bind9 bind9utils bind9-doc bind9-host dnsutils
-sudo apt-get install dnsutils+
 </code> </code>
  
 ===== Configuration ===== ===== Configuration =====
-To setup a caching nameserver, add the IP addresses of the ISP's (e.g., Academia Sinica) DNS servers. Uncomment and edit the following in ''/etc/bind/named.conf.options'': 
  
 +==== DNS Forwarders ====
 +To setup a caching nameserver, add the IP addresses of the ISP's (e.g., Academia Sinica) DNS servers. Uncomment and edit the following in ''/etc/bind/named.conf.options'':
 <code bash> <code bash>
 forwarders { forwarders {
Line 16: Line 16:
  8.8.8.8;  8.8.8.8;
  8.8.4.4;  8.8.4.4;
- // Academia Sinica 
- 140.109.13.10; 
- 140.109.1.10; 
            };            };
 </code> </code>
  
-===== Activation ===== +==== Logging ==== 
-To start/stop/restart the service:+ 
 +add the following code to ''/etc/bind/named.conf.local'': 
 +<code bash> 
 +logging { 
 + channel default-log { 
 + file "/var/log/named/default.log" size 100m; 
 + severity info; 
 + print-time yes; 
 + }; 
 + channel lamer-log { 
 + file"/var/log/named/lamer.log" size 100m; 
 + severity info; 
 + print-severity yes;  
 + print-time yes; 
 + print-category yes; 
 + }; 
 + channel query-log { 
 + file "/var/log/named/query.log" size 1000m; 
 + severity info; 
 + print-time yes; 
 + }; 
 + channel security-log { 
 + file"/var/log/named/security.log" size 100m; 
 + severity info; 
 + print-severity yes; 
 + print-time yes; 
 + print-category yes; 
 + }; 
 + category default { default-log;}; 
 + category lame-servers { lamer-log; }; 
 + category queries { query-log;}; 
 + category security { security-log;}; 
 +}; 
 +</code> 
 + 
 +prepare log directory: 
 +<code bash> 
 +sudo mkdir -p /var/log/named 
 +sudo chown bind:bind /var/log/named 
 +</code> 
 +note: 
 +the log directory "/var/log/named" is hard-coded in ''/etc/apparmor.d/usr.sbin.named'' 
 +<code bash> 
 +  # some people like to put logs in /var/log/named/ instead of having 
 +  # syslog do the heavy lifting. 
 +  /var/log/named/** rw, 
 +  /var/log/named/ rw, 
 +</code> 
 +this part would need to be changed if a custom log directory is used. 
 + 
 + 
 +start service 
 +<code bash> 
 +# enable auto start at boot time: 
 +sudo systemctl enable named 
 +# start 
 +sudo systemctl start named 
 +</code> 
 + 
 +check status 
 +<code bash> 
 +systemctl status named 
 +</code> 
 + 
 +check the "Current DNS Server" 
 +<code bash> 
 +systemd-resolve --status 
 +</code> 
 + 
 +To set BIND as the default resolver, edit ''/etc/systemd/resolved.conf'' 
 +In the [Resolve] section, add ''DNS=127.0.0.1''
 <code bash> <code bash>
-sudo /etc/init.d/bind9 start +# restart and check again 
-sudo /etc/init.d/bind9 stop +sudo systemctl restart systemd-resolved 
-sudo /etc/init.d/bind9 restart+systemd-resolve --status
 </code> </code>
  
Line 79: Line 146:
 ===== References ===== ===== References =====
   * [[https://help.ubuntu.com/10.04/serverguide/C/dns.html]]   * [[https://help.ubuntu.com/10.04/serverguide/C/dns.html]]
 +  * [[https://www.linuxbabe.com/ubuntu/set-up-local-dns-resolver-ubuntu-20-04-bind9]]
  
  
computers/dns_server_configuration.1339560981.txt.gz · Last modified: 2012/06/13 12:16 by chkuo