Linux:DNS Configuration

Name to IP resolution & IP to name.

to find the IP we use : nslookup <website name>

nslookup www.google.com

Forward and Reverse Lookup Query

When a client queries for IP address called Forward and query for name of host called reverse lookup query.

nslookup google.com --->forward

nslookup 192.168.1.101 ---->reverse

/etc/resolv.conf

It translates domain names to IP addresses by querying the Domain Name Server (DNS). The /etc/resolv. conf file is the file that configures the domain name resolver.

The DNS Name Space

hierarchy(tree structure)

1)Root Domain, 2)Top Level, 3)Second Level, 4) Subdomain and 5) Machines

Root Servers

There are 13 root servers on the internet .i.e. name A to M (called Masters servers of internet),if one of the server down nobody can access the websites.

Example F Server contain 46 physical machines (all analytical).

domains(top level domain,sub domain)

Domains - Dealintech ®

top level domain

What Is a Top Level Domain (TLD)? Top Level Domains Explained

fully qualified domain name(machine_name.domain_name)

A fully qualified domain name (FQDN) is the complete address of an internet host or computer. It provides its exact location within the domain name system (DNS) by specifying the hostname, domain name and top-level domain (TLD).

dns zones

A DNS zone is a portion of the DNS namespace that is managed by a specific organization or administrator. A DNS zone is an administrative space which allows for more granular control of DNS components, such as authoritative nameservers.

What is a DNS Zone? Primary and Secondary DNS Zone and how ...

dns records

Different types of DNS records are as follows:

  • Name Server (NS) Record: Describes a name server for the domain that permits DNS lookups within several zones.You can list all your name servers for your DNS zone in distinct NS records.

  • Mail Exchange (MX) Record: Permits mail to be sent to the right mail servers located in the domain. Other than IP addresses, MX records include fully-qualified domain names.

  • glue A record: maps the name of an NS record to an ip address.

  • Address (A) Record: /host record-contain ipv4 add of computer.AAAA is same but contain ipv6 address.

  • Canonical Name (CNAME) Record: Can be used to set an alias for the host name

  • Text (TXT) Record: Permits the insertion of arbitrary text into a DNS record. These records add SPF records into a domain.

  • Time-to-Live (TTL) Record: Sets the period of data, which is ideal when a recursive DNS server queries the domain name information

  • Start of Authority (SOA) Record: Contain meta information of zone itself.

  • Pointer (PTR) Record:(reverse of a record) IP address to the host name in order to do reverse lookups.

caching only servers

dns server connect o other dns server over a zone to collect the information

Configuration of DNS

hostnamectl set-hostname dns.goutam.server
cp /etc/named.conf /etc/named.bak
vim named.conf
        comment first two line v4,v6 port 53
        allow-query{localhost;192.168.0.0/24;}

         <come to the end of the page>
        //forward zone 
        zone "goutam.local" IN{
        type master;
        file "goutam.local.db";
        allow-update{nane;};
        allow-query{any;};
        }
        //backward zone
        zone "0.168.192.in-addr-arpa"IN{
        type master;
        file "goutam.local.rev";
        allow-update{nane;};
        allow-query{any;};
        }
cd /var/named
ll

cat named.localhost

cat named.loopback

//forward zone file
vim /var/named/goutam.local.db
        $TTL 86400
        @ IN SOA dns.goutam.server. admin.goutam.server. (
                    2020011800 ;Serial
                    3600 ;Refresh
                    1800 ;Retry
                    604800 ;Expire
                    86400 ;Minimum TTL
        )
        ;Name Server Information
        @ IN NS dns.goutam.server.
        ;IP Address for Name Server 
        dns IN A 192.168.0.143
        ;Mail Server MX (Mail exchanger) Record
        goutam.server. IN MX mail.goutam.server.
        ;A record for the following host name
        WWW IN A 192.168.0.50
        mail IN A 192.168.0.60
        ;CNAME Record
        ftp IN CNAME www.goutam.server.
//reverse zone
vim /var/named/goutam.local.rev
        $TTL 86400
        @ IN SOA dns.goutam.server. admin.goutam.server. (
                    2020011800 ;Serial
                    3600 ;Refresh
                    1800 ;Retry
                    604800 ;Expire
                    86400 ;Minimum TTL
        )
        ;Name Server Information
        @ IN NS dns.goutam.server.
        ;IP Address for Name Server 
        dns IN A 192.168.0.143
        ;Reverse lookup for Name Server
        143 IN PTR dns.goutam.server.
        ;PTR record IP address to host name
        50 IN PTR www.goutam.server.
        60 IN PTR www.goutam.server.


save
ll(verify)
change the owner of file
chown named:named /var/named/goutam.server.db
chown named:named /var/named/goutam.server.rev
named-checkzone <domain_name> goutam.server /var/named/goutam.server.db
ok
named-checkzone 192.168.0.143 /var/named/goutam.server.rev
ok
systemctl restart named
firewall-cmd --add-service=dns --zone=public --permanent 
firewall-cmd --reload
firewall-cmd --list-all

after that verify with nslookup