Thursday, May 19, 2016

fast way to setup dns server

dnsmasq is a lightweight DNS, TFTP, PXE, router advertisement and DHCP server. And it is very easy and fast to setup those services up and running.

1- install dnsmasq on the system
$ sudo apt-get install dnsmasq

2- create a file /etc/resolv.dnsmasq.conf with the following content (list the dns server for dns forwarder in dnsmasq)
nameserver 8.8.8.8
nameserver 8.8.4.4



3- modify the dnsmasq configuration file /etc/dnsmasq.conf as below

address=/mydomain.com/192.168.202.1
address=/www.mydomain.com/192.168.202.1
cname=a.mydomain.com,www.mydomain.com
cname=mail.mydomain.com,www.mydomain.com
mx-host=mydomain.com,mail.mydomain.com,50
resolv-file=/etc/resolv.dnsmasq.conf


4- to start the dnsmasq service just run the dnsmasq with root permission,
$ sudo dnsmasq

5- to stop the service just kill its process with killall
$ sudo killall dnsmasq

6- and we can modify our /etc/resolv.conf file ot use with out newly setup dns as below
nameserver 127.0.0.1

now with those configuration of setup 3 we got
- address as a record
- cname as cname record
- mx-host as mx record

7- test resolve name using host command
$ host mydomain.com
mydomain.com has address 192.168.202.1
mydomain.com mail is handled by 50 mail.mydomain.com.

No comments:

Post a Comment