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 [2017/08/01 14:47] 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>
  
Line 14: Line 13:
 <code bash> <code bash>
 forwarders { forwarders {
- // Academia Sinica 
- 140.109.13.10; 
- 140.109.1.10; 
  // Google  // Google
  8.8.8.8;  8.8.8.8;
Line 25: Line 21:
 ==== Logging ==== ==== Logging ====
  
-add the following code to ''/etc/bind/named.conf.options'':+add the following code to ''/etc/bind/named.conf.local'':
 <code bash> <code bash>
-logging +logging { 
-+ channel default-log { 
-    channel default-log { + file "/var/log/named/default.log" size 100m; 
-        file "/var/log/bind/default.log" size 100m; + severity info; 
-        severity info; + print-time yes; 
-        print-time yes; + }; 
-    }; + channel lamer-log { 
-    channel lamer-log { + file"/var/log/named/lamer.log" size 100m; 
-        file"/var/log/bind/lamer.log" size 100m; + severity info; 
-        severity info; + print-severity yes;  
-        print-severity yes;  + print-time yes; 
-        print-time yes; + print-category yes; 
-        print-category yes; + }; 
-    }; + channel query-log { 
-    channel query-log { + file "/var/log/named/query.log" size 1000m; 
-        file "/var/log/bind/query.log" size 1000m; + severity info; 
-        severity info; + print-time yes; 
-        print-time yes; +  }; 
-     }; + channel security-log { 
-    channel security-log { + file"/var/log/named/security.log" size 100m; 
-        file"/var/log/bind/security.log" size 100m; + severity info; 
-        severity info; + print-severity yes; 
-        print-severity yes; + print-time yes; 
-        print-time yes; + print-category yes; 
-        print-category yes; + }; 
-    }; + category default { default-log;}; 
-    category default { default-log;}; + category lame-servers { lamer-log; }; 
-    category lame-servers { lamer-log; }; + category queries { query-log;}; 
-    category queries { query-log;}; + category security { security-log;};
-    category security { security-log;};+
 }; };
 </code> </code>
Line 62: Line 57:
 prepare log directory: prepare log directory:
 <code bash> <code bash>
-sudo mkdir -p /var/log/bind +sudo mkdir -p /var/log/named 
-sudo chown bind:bind /var/log/bind+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> </code>
  
-===== Activation ===== +To set BIND as the default resolver, edit ''/etc/systemd/resolved.conf'' 
-To start/stop/restart the service:+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 123: 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.1501570022.txt.gz · Last modified: 2017/08/01 14:47 by chkuo