The Domain Name System (DNS) is the phonebook of the Internet. Humans access information online through domain names, like nytimes.com or espn.com. Web browsers interact through Internet Protocol (IP) addresses. DNS translates domain names to IP addresses so browsers can load Internet resources.
Each device connected to the Internet has a unique IP address which other machines use to find the device. DNS servers eliminate the need for humans to memorize IP addresses such as 192.168.1.1 (in IPv4)
How does DNS Work
The process of DNS resolution involves converting a hostname (such as www.example.com) into a computer-friendly IP address (such as 192.168.1.1). An IP address is given to each device on the Internet, and that address is necessary to find the appropriate Internet device - like a street address is used to find a particular home. When a user wants to load a webpage, a translation must occur between what a user types into their web browser (example.com) and the machine-friendly address necessary to locate the example.com webpage.
In order to understand the process behind the DNS resolution, it’s important to learn about the different hardware components a DNS query must pass between. For the web browser, the DNS lookup occurs "behind the scenes" and requires no interaction from the user’s computer apart from the initial request.
Configuration
DNS Server
Install Package
sudo yum install bind bind-utils -y
Configure DNS
sudo vi /etc/named.conf
## Add on line 12
options {
listen-on port 53 { 127.0.0.1; 192.168.8.100; }; ## your ip address
listen-on-v6 port 53 { ::1; };
directory "/var/named";
dump-file "/var/named/data/cache_dump.db";
statistics-file "/var/named/data/named_stats.txt";
memstatistics-file "/var/named/data/named_mem_stats.txt";
recursing-file "/var/named/data/named.recursing";
secroots-file "/var/named/data/named.secroots";
allow-query { localhost; 192.168.8.100;}; ## your ip address
## Add on line 43
pid-file "/run/named/named.pid";
session-keyfile "/run/named/session.key";
forwarders {
192.168.8.1; ## your gateway
8.8.8.8;
8.8.4.4;
};
## Add on line 64
zone "centosrizwan.com" IN {
type master;
file "/var/named/db.centosrizwan.com"; ## your db.file
allow-update { none; };
};
zone "100.8.168.in-addr.arpa" IN {
type master;
file "/var/named/db.100.8.168"; ## your db.file
allow-update { none; };
};
Create DB File for DNS Forward
db.domain
sudo vi /var/named/db.(your-domain)
;
; BIND data file for local loopback interface
;
$TTL 604800
@ IN SOA centosrizwan.com. root.centosrizwan.com. (
2 ; Serial
604800 ; Refresh
86400 ; Retry
2419200 ; Expire
604800 ) ; Negative Cache TTL
;
@ IN NS centosrizwan.com.
@ IN A 192.168.8.100
@ IN MX 0 192.168.8.100
mail IN A 192.168.8.100
www IN A 192.168.8.100
php IN A 192.168.8.100
wordpress IN A 192.168.8.100
phpmyadmin IN A 192.168.8.100
db.ipaddr
sudo vi /var/named/db.(your-ip)
;
; BIND reverse data file for local loopback interface
;
$TTL 604800
@ IN SOA centosrizwan.com. root.centosrizwan.com. (
1 ; Serial
604800 ; Refresh
86400 ; Retry
2419200 ; Expire
604800 ) ; Negative Cache TTL
;
@ IN NS centosrizwan.com.
100 IN PTR centosrizwan.com.
100 IN PTR www.centosrizwan.com.
100 IN PTR mail.centosrizwan.com.
100 IN PTR php.centosrizwan.com.
100 IN PTR wordpress.centosrizwan.com.
100 IN PTR phpmyadmin.centosrizwan.com.
Edit Resolv File
sudo vi /etc/resolv.conf
search centosrizwan.com ## your domain
nameserver 192.168.8.100 ## your ip address
nameserver 192.168.8.1 ## your gateway
Enable and Restart DNS Service
sudo systemctl start named
sudo systemctl enable named