Linux: Install DNS Resolver for Private Use – The Simplest Way

DNS resolver is really needed in order to help resolving domain name to IP address. The most popular public DNS resolver should be Google resolver 8.8.8.8 and 8.8.4.4.

For some cases, if you have web server in DMZ, your web server IP should be different when pinging from internal network or external network. This situation has lead me to run our own private DNS resolver since the development team need to have the development server run with domain name (due to URL binding and some programming stuff requirement). The domain name that I will use to resolve locally is myserver.net, while other domains will resolve correctly same as public DNS resolver.

I will show you how I do that with most simplest way, using yumBind and Webmin. Variables as follow:

OS: CentOS 6 64bit
IP: 192.168.0.200
Hostname: dns.local
Internal web server IP: 192.168.0.202
DNS Zone:  myserver.net

1. Install Bind using yum:

yum install bind* -y

2. Download Webmin so we can easily manage the zone via web-based interface:

echo "[Webmin]" > /etc/yum.repos.d/webmin.repo

echo "name=Webmin Distribution Neutral" >> /etc/yum.repos.d/webmin.repo

echo "#baseurl=http://download.webmin.com/download/yum" >> /etc/yum.repos.d/webmin.repo

echo "mirrorlist=http://download.webmin.com/download/yum/mirrorlist" >> /etc/yum.repos.d/webmin.repo

echo "enabled=1" >> /etc/yum.repos.d/webmin.repo

cd /tmp

wget http://www.webmin.com/jcameron-key.asc

rpm --import jcameron-key.asc

yum -y install webmin

3. Start the Webmin service:

service webmin start

4. Allow port 10000 in IPtables. Open /etc/sysconfig/iptables via text editor and add following line BEFORE any “-j REJECT” word:

-A INPUT -p tcp -m tcp --dport 10000 -j ACCEPT

5. Restart the IPtables:

service iptables restart

6. Access the Webmin interface via http://192.168.0.200:10000 and login user root with the root password. We are going to use Webmin from now on. Lets initialize BIND DNS server first. After login go to Servers > BIND DNS Server > Select “Setup as an internet name server, and download root server information” > Click “Create Primary Configuration File and Start Nameserver” :

7. Configuration done. Lets create our domain myserver.net to be resolved locally. Go to “Create master zone” and enter required information. Example as below:

8. Now we lets add required A record information. Go to “Address” and enter the host value with IP address as example below:

9. Once host record complete, we need to click “Apply Zone” at top corner of the page to reload the DNS zone with new value. To double check, you can click “Edit Records File” and view the complete list of DNS records.

10. DNS resolver completed. You just need to point your DNS resolver in your PC to 192.168.0.200 and everything will happen as what we expected. Dont forget to flush dns cache “ipconfig /flushdns” for Windows PC.

To check, you can ping to yahoo.com or google.com as usual and in the same time you can ping your domain and get resolved to local IP as what we defined in DNS zone of our resolver

Was this answer helpful?

 Print this Article

Also Read

Understanding Linux CPU Load - when should you be worried?

You might be familiar with Linux load averages already. Load averages are the three numbers shown...

How do I reduce memory usage?

If your server or VPS is frequently running out of memory this article should be of great...

How do I install Perl?

via SSH and enter the following:yum -y install perl

Ubuntu: Install Windows Application using Winetricks

Ubuntu is surely good for end-user operating system but sometimes we still need to have...

Installing Java 1.6 in CentOS 6 – The Simplest Way

Default repository in CentOS 6 will give you Java 1.5 JRE and SDK packages. I will show you on...

Powered by WHMCompleteSolution