192.168.122.20<\/code><\/td>Client Server<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n In all the servers, we have to install BIND packages before we proceed with configurations;<\/p>\n\n\n\n yum install -y bind bind-utils<\/code><\/pre>\n\n\n\nOnce the package is installed, let us get to work.<\/p>\n\n\n\n Create DNS Access Control List (ACL)<\/h4>\n\n\n\nWe would want to allow specific hosts to access the DNS server. Therefore, we will create an Access Control List called allowed<\/strong> containing IP addresses of the hosts to be allowed to query our DNS servers before the options<\/strong> sections in the configuration file, \/etc\/named.conf<\/strong><\/code>;<\/p>\n\n\n\nBefore you can proceed, this is the default \/etc\/named.conf<\/code><\/strong> configurations;<\/p>\n\n\n\ncat \/etc\/named.conf<\/code><\/pre>\n\n\n\n\n\/\/\n\/\/ named.conf\n\/\/\n\/\/ Provided by Red Hat bind package to configure the ISC BIND named(8) DNS\n\/\/ server as a caching only nameserver (as a localhost DNS resolver only).\n\/\/\n\/\/ See \/usr\/share\/doc\/bind*\/sample\/ for example named configuration files.\n\/\/\n\/\/ See the BIND Administrator's Reference Manual (ARM) for details about the\n\/\/ configuration located in \/usr\/share\/doc\/bind-{version}\/Bv9ARM.html\n\noptions {\n\tlisten-on port 53 { 127.0.0.1; };\n\tlisten-on-v6 port 53 { ::1; };\n\tdirectory \t\"\/var\/named\";\n\tdump-file \t\"\/var\/named\/data\/cache_dump.db\";\n\tstatistics-file \"\/var\/named\/data\/named_stats.txt\";\n\tmemstatistics-file \"\/var\/named\/data\/named_mem_stats.txt\";\n\trecursing-file \"\/var\/named\/data\/named.recursing\";\n\tsecroots-file \"\/var\/named\/data\/named.secroots\";\n\tallow-query { localhost; };\n\n\t\/* \n\t - If you are building an AUTHORITATIVE DNS server, do NOT enable recursion.\n\t - If you are building a RECURSIVE (caching) DNS server, you need to enable \n\t recursion. \n\t - If your recursive DNS server has a public IP address, you MUST enable access \n\t control to limit queries to your legitimate users. Failing to do so will\n\t cause your server to become part of large scale DNS amplification \n\t attacks. Implementing BCP38 within your network would greatly\n\t reduce such attack surface \n\t*\/\n\trecursion yes;\n\n\tdnssec-enable yes;\n\tdnssec-validation yes;\n\n\t\/* Path to ISC DLV key *\/\n\tbindkeys-file \"\/etc\/named.root.key\";\n\n\tmanaged-keys-directory \"\/var\/named\/dynamic\";\n\n\tpid-file \"\/run\/named\/named.pid\";\n\tsession-keyfile \"\/run\/named\/session.key\";\n};\n\nlogging {\n channel default_debug {\n file \"data\/named.run\";\n severity dynamic;\n };\n};\n\nzone \".\" IN {\n\ttype hint;\n\tfile \"named.ca\";\n};\n\ninclude \"\/etc\/named.rfc1912.zones\";\ninclude \"\/etc\/named.root.key\";\n<\/code><\/pre>\n\n\n\nThus, let’s begin by creating an ACL;<\/p>\n\n\n\n vim \/etc\/named.conf<\/code><\/pre>\n\n\n\n\n\/\/\n\/\/ named.conf\n\/\/\n\/\/ Provided by Red Hat bind package to configure the ISC BIND named(8) DNS\n\/\/ server as a caching only nameserver (as a localhost DNS resolver only).\n\/\/\n\/\/ See \/usr\/share\/doc\/bind*\/sample\/ for example named configuration files.\n\/\/\n\/\/ See the BIND Administrator's Reference Manual (ARM) for details about the\n\/\/ configuration located in \/usr\/share\/doc\/bind-{version}\/Bv9ARM.html\n\n# Create an access control list called allowed \nacl \"allowed\" {\n 192.168.122.10;\n 192.168.122.11;\n 192.168.122.20;\n};<\/strong>\noptions {\n listen-on port 53 ...\n<\/code><\/pre>\n\n\n\nIn the above, we have only limited access to DNS queries to three hosts.<\/p>\n\n\n\n Apart from defining the allowed system IP addresses, there are default BIND ACLs that you can use if it suit your needs;<\/p>\n\n\n\n \nnone<\/code>: Matches no hosts.<\/li>\n\n\n\nany<\/code>: Matches all hosts.<\/li>\n\n\n\nlocalhost<\/code>: Matches the loopback addresses 127.0.0.1<\/code> and ::1<\/code>, as well as the IP addresses of all interfaces on the server that runs BIND.<\/li>\n\n\n\nlocalnets<\/code>: Matches the loopback addresses 127.0.0.1<\/code> and ::1<\/code>, as well as all subnets the server that runs BIND is directly connected to.<\/li>\n<\/ul>\n\n\n\nDefine DNS Server Global Options<\/h4>\n\n\n\nThe “options” section in the BIND configuration file (named.conf<\/code>) specifies global options for the DNS server.<\/p>\n\n\n\n\n\n# Create an access control list called allowed \nacl \"allowed\" {\n 192.168.122.10;\n 192.168.122.11;\n 192.168.122.20;\n};\noptions {\n listen-on port 53 { 127.0.0.1; 192.168.122.10; };\n directory \"\/var\/named\";\n dump-file \"\/var\/named\/data\/cache_dump.db\";\n statistics-file \"\/var\/named\/data\/named_stats.txt\";\n memstatistics-file \"\/var\/named\/data\/named_mem_stats.txt\";\n recursing-file \"\/var\/named\/data\/named.recursing\";\n secroots-file \"\/var\/named\/data\/named.secroots\";\n allow-query { localhost; allowed; };\n allow-transfer { 192.168.122.11; };\n recursion yes;\n dnssec-enable yes;\n dnssec-validation yes;\n bindkeys-file \"\/etc\/named.root.key\";\n managed-keys-directory \"\/var\/named\/dynamic\";\n pid-file \"\/run\/named\/named.pid\";\n session-keyfile \"\/run\/named\/session.key\";\n};<\/strong>\n<\/code><\/pre>\n\n\n\nThese options are explained below;<\/p>\n\n\n\n \nlisten-on<\/code>: Specifies the IP address(es) and port number(s) that the DNS server should listen on for incoming requests. The default port for DNS is 53.<\/li>\n\n\n\ndirectory<\/code>: Specifies the directory where the DNS server should store its zone files, key files, and other data.<\/li>\n\n\n\ndump-file<\/code>: Specifies the file where the DNS server should dump its cache database when it shuts down.<\/li>\n\n\n\nstatistics-file<\/code>: Specifies the file where the DNS server should log statistics about its performance and activity.<\/li>\n\n\n\nmemstatistics-file<\/code>: Specifies the file where the DNS server should log detailed memory usage statistics.<\/li>\n\n\n\nrecursing-file<\/code>: Specifies the file where the DNS server should log queries that it has forwarded to other DNS servers when performing recursive lookups.<\/li>\n\n\n\nsecroots-file<\/code>: Specifies the file where the DNS server should store trusted DNSSEC root keys.<\/li>\n\n\n\nallow-query<\/code>: Specifies which hosts are allowed to query the DNS server. By default, the DNS server will only allow queries from localhost.<\/li>\n\n\n\nallow-transfer<\/code>: Specifies which hosts are allowed to transfer zone data from the DNS server. By default, zone transfers are not allowed.<\/li>\n\n\n\nrecursion<\/code>: Enables or disables recursion. Recursion is the process by which a DNS server queries other DNS servers to resolve a DNS query.<\/li>\n\n\n\ndnssec-enable<\/code>: Enables or disables DNSSEC validation. DNSSEC is a security protocol that is used to verify the authenticity of DNS data.<\/li>\n\n\n\ndnssec-validation<\/code>: Enables or disables DNSSEC validation.<\/li>\n\n\n\nbindkeys-file<\/code>: Specifies the file where the DNS server should look for the DNSSEC root key.<\/li>\n\n\n\nmanaged-keys-directory<\/code>: Specifies the directory where the DNS server should store managed keys.<\/li>\n\n\n\npid-file<\/code>: Specifies the file where the DNS server should write its process ID.<\/li>\n\n\n\nsession-keyfile<\/code>: Specifies the file where the DNS server should store session keys.<\/li>\n<\/ul>\n\n\n\nCreate Forward and Reverse Zone Statements<\/h4>\n\n\n\nCreate zone statements for both forward and reverse DNS lookups.<\/p>\n\n\n\n \n# Zone statement for forward DNS lookup\nzone \"kifarunix-demo.com\" IN {\n type master; # type of zone\n file \"\/var\/named\/forward.kifarunix-demo.com\"; # location of forward zone file\n allow-update { none; };\n};\n# Zone statement for reverse DNS lookup\nzone \"122.168.192.in-addr.arpa\" IN {\n type master; \n file \"\/var\/named\/reverse.kifarunix-demo.com\"; # location of reverse zone file\n allow-update { none; };\n};\n<\/code><\/pre>\n\n\n\nAfter that, save the configuration file and exit.<\/p>\n\n\n\n \n- The first zone statement defines the forward zone for the domain kifarunix-demo.com<\/li>\n\n\n\n
- The “
type master<\/code><\/strong>” specifies that this DNS server is the master server for this zone, meaning that it is the authoritative source for the DNS records in this zone.<\/li>\n\n\n\n- The “
file<\/code><\/strong>” parameter specifies the location of the zone file that contains the DNS records for this zone. In this case, the file is “\/var\/named\/forward.example.com”.<\/li>\n\n\n\n- The “
allow-update<\/code><\/strong>” parameter specifies who is allowed to update the DNS records in this zone. In this case, the value “none” means that no one is allowed to update the DNS records in these zones. This is a common setting for master DNS servers that do not allow dynamic updates from clients.<\/li>\n<\/ul>\n\n\n\nThis is the named.conf file with no comment lines;<\/p>\n\n\n\n grep -vE '^\/\/|^$' \/etc\/named.conf<\/code><\/pre>\n\n\n\n\nacl \"allowed\" {\n 192.168.122.10;\n 192.168.122.11;\n 192.168.122.20;\n};\noptions {\n listen-on port 53 { 127.0.0.1; 192.168.122.10; };\n directory \"\/var\/named\";\n dump-file \"\/var\/named\/data\/cache_dump.db\";\n statistics-file \"\/var\/named\/data\/named_stats.txt\";\n memstatistics-file \"\/var\/named\/data\/named_mem_stats.txt\";\n recursing-file \"\/var\/named\/data\/named.recursing\";\n secroots-file \"\/var\/named\/data\/named.secroots\";\n allow-query { localhost; allowed; };\n allow-transfer { 192.168.122.11; };\n recursion yes;\n dnssec-enable yes;\n dnssec-validation yes;\n bindkeys-file \"\/etc\/named.root.key\";\n managed-keys-directory \"\/var\/named\/dynamic\";\n pid-file \"\/run\/named\/named.pid\";\n session-keyfile \"\/run\/named\/session.key\";\n};\nlogging {\n channel default_debug {\n file \"data\/named.run\";\n severity dynamic;\n };\n};\n# Zone statement for forward DNS lookup\nzone \"kifarunix-demo.com\" IN {\n type master; # type of zone\n file \"\/var\/named\/forward.kifarunix-demo.com\"; # location of forward zone file\n allow-update { none; };\n};\n# Zone statement for reverse DNS lookup\nzone \"122.168.192.in-addr.arpa\" IN {\n type master; \n file \"\/var\/named\/reverse.kifarunix-demo.com\"; # location of reverse zone file\n allow-update { none; };\n};\ninclude \"\/etc\/named.rfc1912.zones\";\ninclude \"\/etc\/named.root.key\";\n<\/code><\/pre>\n\n\n\nNext, create Zone files for both the forward and reverse zone statements created in the \/etc\/named.conf<\/strong><\/p>\n\n\n\nCreate Forward zone file<\/h4>\n\n\n\nAs specified in the zone statement in the \/etc\/named.conf file, forward zone file is located \/var\/named\/forward.kifarunix-demo.com<\/strong>. Open the file and edit it as follows;<\/p>\n\n\n\nvim \/var\/named\/forward.kifarunix-demo.com<\/code><\/pre>\n\n\n\n\n$ORIGIN kifarunix-demo.com.\n$TTL 86400\n@ IN SOA ns1.kifarunix-demo.com. admin.kifarunix-demo.com. (\n 2023051301 ; serial\n 3600 ; refresh\n 1800 ; retry\n 604800 ; expire\n 86400 ) ; minimum TTL\n;\n; define nameservers\n IN NS ns1.kifarunix-demo.com.\n IN NS ns2.kifarunix-demo.com.\n;\n; IP addresses and hostnames\nns1 IN A 192.168.122.10\nns2 IN A 192.168.122.11\n;\n; client records\nfileserver IN A 192.168.122.20\n<\/code><\/pre>\n\n\n\nSave the file and exit the editor.<\/p>\n\n\n\n Explanation of some options used;<\/p>\n\n\n\n \n$ORIGIN<\/code> is a directive in a DNS zone file that sets the base domain name for relative domain names defined in the file. It specifies the domain name that will be appended to any domain name that does not end with a trailing period. This directive is usually used at the beginning of a zone file to simplify the specification of domain names within the zone file.<\/li>\n\n\n\n$TTL 86400<\/code>: Sets the default TTL (time-to-live) value to 86400 seconds (1 day).<\/li>\n\n\n\n- The SOA line defines the Start of Authority (SOA) record for the zone. It specifies the primary name server
ns1.kifarunix-demo.com<\/code> and the email address of the responsible person admin.kifarunix-demo.com<\/code>. The numbers in parentheses are the;\n\n- serial number,<\/li>\n\n\n\n
- refresh time,<\/li>\n\n\n\n
- retry time,<\/li>\n\n\n\n
- expiry time,<\/li>\n\n\n\n
- minimum TTL value for the zone, respectively.<\/li>\n<\/ul>\n<\/li>\n\n\n\n
- The
\"IN NS\"<\/code><\/strong> specifies the nameservers for the zone, using the NS<\/code> resource record type. These records indicate which nameservers are authoritative for the zone.<\/li>\n\n\n\n- The
\"IN A\"<\/code><\/strong> define the A records that maps domain names\/hostnames to IP addresses.<\/li>\n<\/ul>\n\n\n\nCreate Reverse Zone file<\/h4>\n\n\n\nvim \/var\/named\/reverse.kifarunix-demo.com<\/code><\/pre>\n\n\n\n\n$ORIGIN 122.168.192.in-addr.arpa.\n$TTL 86400\n@ IN SOA ns1.kifarunix-demo.com. admin.kifarunix-demo.com. (\n 2017020402 ; serial\n 3600 ; refresh\n 1800 ; retry\n 604800 ; expire\n 86400 ) ; minimum TTL\n;\n;nameservers\n IN NS ns1.kifarunix-demo.com.\n IN NS ns2.kifarunix-demo.com.\n;\n;nameserver IP addresses\n IN A 192.168.122.10\n IN A 192.168.122.11\n;\n; client IP Address\n IN A 192.168.122.20\n; nameserver PTR records\n10 IN PTR ns1.kifarunix-demo.com.\n11 IN PTR ns2.kifarunix-demo.com.\n;\n; client PTR records\n20 IN PTR fileserver.kifarunix-demo.com.\n<\/code><\/pre>\n\n\n\nSave the file and exit the editor.<\/p>\n\n\n\n Explanation of some options;<\/p>\n\n\n\n \n$ORIGIN 122.168.192.in-addr.arpa.<\/code>: sets the default origin for the zone to 122.168.192.in-addr.arpa<\/code>. This means that any hostname without a trailing dot will be assumed to be relative to this origin.<\/li>\n\n\n\n- The
\"IN PTR\"<\/code><\/strong> specifies the reverse DNS lookup records for the nameservers, using the PTR<\/code> (pointer) resource record type. These records map each IP address to its corresponding hostname.<\/li>\n<\/ul>\n\n\n\nCheck BIND Configuration for Syntax Errors<\/h4>\n\n\n\nBefore starting BIND i.e named service<\/strong>, check that there are no syntactic errors in your configuration files using the following command;<\/p>\n\n\n\n
|