Pranaam to all Bhai ji _/\_
Today we will discuss about DNS server aka bind server which helps in mapping domain name to IP and vice versa
means , whenever we want to connect to any domain by typing ip its name , machine needs to map that name to ip so that it can connect to that ip and serve user request.
for example , a user want to connect to google.com and for that user's machine needs ip address of google.com . for domain name to ip mapping we require DNS server.
DNS server has for domain name and when a client comes to it for domain name mapping , it give ip of domain to client and after that client connect to domain by using that ip address .
so when user tried to connect to google.com, first of all request forwarded to DNS server for ip mapping
once DNS server replied, user will connect to google.com by using that ip address.
user machine will store ip mapped by DNS server of domain in cache for further use.
DNS server also perform ip to domain name mapping, means it resolve domain name from IP
lets start with DNS server setup 8-)
Installation:-
for DNS server setup , we use bind package .
we can install bind package using yum
command is yum install bind
After installing bind package , we need to configure other server settings i.e
1.Hostname
2.Assign static IP to machine which will behave as DNS server
3.DNS server IP entry in /etc/resolv.conf file
setting Hostname
hostname setup is done in 2 ways ,
temporary (by using command hostname new_hostname)
Permanent (by editing /etc/sysconfig/network file )
i am going for second one :) because we need to setup hostname permanently
open file /etc/sysconfig/network either in vi editor or nano text editor
type hostname in line, where HOSTNAME= is written
hostname should have format like
something.domain.top-level.domain
for example i am using hostname ica.indishell.in
here
ica=something
indishell=domain
in = top level domain
top level domains are .com .org .edu
configure hostname and restart your system for reflecting changes
ok now we need to change our DNS sever ip in static one
open file /etc/sysconfig/network-scripts/infcfg-eth0
and type your static IP in field IPADDR=server_ip
i am using ip 192.168.0.211 , so in my case, its IPADDR=192.168.0.211
ok now open /etc/resolv.conf , define DNS server ip here by typing
nameserver server_ip
for example, in my case my DNS server ip is 192.168.0.211 so i am defining it in /etc/resolv.conf file
okkkkkkk, lets move to bind configuration ;)
bind config file is /etc/named.conf
we need to specify entries in /etc/named.conf file for domain ip resolution by DNS server
i am going to setup DNS server for domain hardeep-and-ar-bhai-ji.rocks
open /etc/named.conf file and define following entries
1. DNS server ip
2. record for domain 'forward zone file'(domain to IP mapping file) and 'reverse zone file' (ip to domain
resolution file)
again.... my DNS server ip is 192.168.0.211 and i am going to setup DNS server for domain hardeep-and-ar-bhai-ji.rocks
define DNS server ip in /etc/named.conf file by editing following lines
define zone record related info just below lines where following code is written in /etc/named.conf file
zone "." IN {
type hint;
file "/var/named/named.ca";
};
Forward zone record
forward zone record is for mapping domain name to IP .
Mainly it contains domain name and its forward zone file location.
code for hardeep-and-ar-bhai-ji.rocks domain will be like this
zone "hardeep-and-ar-bhai-ji.rocks" IN {
type master;
file "forward.zone";
allow-update { none; };
};
here
zone "hardeep-and-ar-bhai-ji.rocks" IN { is showing , for which domain we are creating entry
if you are creating entry for domain having name domain.com, this line will be like this
zone "domain.com" IN {
type master; is showing that we are configuring master DNS server .
file "/var/named/forward.zone"; is for defining the location of the file which stores the info of domain for which which we are creating entry
i am creating entry for domain hardeep-and-ar-bhai-ji.rocks , so info(subdomain names, mail server ns server and domain ip) for this domain will be stored in this file
allow-update { none; }; is showing that who can update zone record for domain .
Reverse zone record
this is for IP to domain name mapping purpose
this is record contains revere zone file location and special name for reverse zone record i.e
"reverse of DNS server ip 3 octet ".in-addr.arpa
reverse zone record name starts with "reverse of DNS server ip 3 octet" , for example my DNS server ip is
192.168.0.211 , first 3 octet of this ip is 192.168.0 and reverse of this is 0.168.192
now add .in-addr.arpa with reverse of DNS server ip 3 octet
and it will be like this
0.168.192.in-addr.arpa
file "reverse.zone"; represent that file for zone record 0.168.192.in-addr.arpa is reverse.zone
note:- location for zone files is /var/named folder.
forward zone file (forward.zone):-
ok lets configure forward zone file for a domain so that whenever client request to DNS server for map domain to an IP , DNS server can reply back with proper information about that domain :)
structure of forward zone file is like this one
for forward zone file creation , you can do one thing , generate copy of /var/named/named.localhost with name forward.zone in folder /var/named
now edit it for your domain
ok again i want to clear few things
i am using DNS server having hostname ica.indishell.in and its IP is 192.168.0.211
i am setting up DNS server for resoling domain hardeep-and-ar-bhai-ji.rocks
so line number 2 ( @ IN SOA @ rname.invali. ( )will be like this
@ IN SOA ica.indishell.in. root.hardeep-and-ar-bhai-ji.rocks. (
here
SOA - Start of Authority. This is the record and that this server is authorative for the specified domain.
ica.indishell.in. is the fully qualifed domain name of DNS (Hostname).
fully qualified domain name ends with.
root.hardeep-and-ar-bhai-ji.rocks. is the FQDN of domain for which we are setting up forward zone file
my domain name is hardeep-and-ar-bhai-ji.rocks , if you are setting up this file for domain having name ica.in it would be root.ica.in.
line
IN NS ica.indihsell.in
this is for name server (hostname )
my DNS hostname is ica.indishell.in
if your DNS name is some.domain.com modify this line as IN NS some.domain.com
line
IN A 192.168.0.211
this is for domain IP i.e domain hardeep-and-ar-bhai-ji.rocks will be mapped to IP 192.168.0.211 by DNS server
line
ica IN A 192.168.0.211
this is indicating that domain hardeep-and-ar-bhai-ji.rocks has subdomain ica and that subdomain (ica.hardeep-and-ar-bhai-ji.rocks) will be mapped to 192.168.0.211
Reverse zone file:-
this zone file is use to map IP to domain name
if we query to DNS with IP , it will map ip to domain name using this zone file
to create reverse zone file , copy named.loopback file to name that you entered in named.conf file in reverse zone record (in mine case it was reverse.zone)
example reverse zone file
i am setting up reverse zone file for domain
hardeep-and-ar-bhai-ji.rocks
when someone will query to DNS server for IP 192.168.0.211 , DNS server will reply with domin info on this ip
after editing, reverse.zone file will be like this
line
@ IN SOA ica.indishell.in. root.hardeep-and-ar-bhai-ji.rocks. (
here
ica.indishell.in. is the fully qualified hostname of DNS
root.hardeep-and-ar-bhai-ji.rocks. is the email for domain hardeep-and-ar-bhai-ji.rocks
line
IN NS ica.indishell.in.
is the name server i.e DNS hostname
line
211 IN PTR hardeep-and-ar-bhai-ji.rocks
this is important line which help DNS sever to map an IP to domain name
how?
lets have a close look
211 is the last octet of IP 192.168.0.211 (zone "0.168.192.in-addr.arpa")
PTR points ip 192.168.0.211 to domain hardeep-and-ar-bhai-ji.rocks
for example if you want to map ip 192.168.0.219 to domain my-domain.com
line will be like this
219 IN PTR my-domain.com
thats it :)
save the file and exit
okkkkkkkk , bind has been configured
lets restart service network and bind server ad check whether server is working properly or not ;)
restart network service by issuing command
service network restart
restart bind using command
service named restart
now lets check whether DNS server is mapping domain to ip and vice versa
DNS server is replying back :D
have a look on above Pic on answer and authority section ;)
test with nslookup command too
:D working ...........
lets try for IP to domain mapping using nslookup command
XD
chaal gya , jamaa jee sa aa gya bhaiyu =))
This was short intro on installing and configuring Master DNS server
Thank you
Greetz to:-
Zero cool, Team INDISHELL , Mannu, Viki , Hardeep and AR AR bhai ji <3
spelling mistake is there in reversezone record::: in that first line "
ReplyDeletethis is for IP ot domain name mapping purpose
sorry for that bhai ji :)
ReplyDeletei have corrected it and thank you for spotting mistake