Whatever it may be, you should go with what works for you and your organization. In the grand scheme of things, you have to be convinced about the value you are getting for the money you are spending...

Home » Archives » February 2011

Linux caching only dns server

February 19, 2011

ok, i made the shortcut to make caching name server work in less time.

1. First step is to check the tools installed:

Caching nameserver

Fortunately, setting up a caching nameserver is easy using RHEL ( Fedora RPMs or CentOS. The following RPMs need to be installed on the machine acting as the nameserver (use rpm -qa to determine if these packages are installed):

  • bind (includes DNS server, named)

  • bind-utils (utilities for querying DNS servers about host information)

  • bind-libs (libraries used by the bind server and utils package)

  • bind-chroot (tree of files which can be used as a chroot jail for bind)

  • caching-nameserver (config files for a simple caching nameserver)

2. A caching nameserver forwards queries to an upstream nameserver and caches the results. Open the file /var/named/chroot/etc/named.conf and add the following lines to the global options section:

 

     forwarders { xxx.xxx.xxx.xxx; xxx.xxx.xxx.xxx; }; #IP of upstream ISP nameserver(s)

     forward only; #rely completely on our upstream nameservers
 

The block above will cause the caching name server to forward DNS requests it can’t resolve to your ISP nameserver. Save the named.conf file and then assign 644 permissions:
chmod 644 named.conf
Check the syntax using the named-checkconf utility provided by the bind RPM:
named-checkconf named.conf
Correct any syntax errors (watch those semicolons) named-checkconf reports. Monitoring the /var/log/messages file may also be helpful in debugging any errors.
We now need to set the local resolver to point to itself for DNS resolution. Modify the /etc/resolv.conf file to the following:

nameserver 127.0.0.1

If you are running a DHCP server on your router make sure your /etc/resolv.conf file does not get overwritten whenever your DHCP lease is renewed. To prevent this from happening, modify /etc/sysconfig/network-scripts/ifcfg-eth0 (replace eth0 with your network interface if different) and make sure the following settings are set:

BOOTPROTO=dhcp
PEERDNS=no
TYPE=Ethernet

Go ahead and start the nameserver as root and configure to start in runlevels 2-5:
service named start
chkconfig named on

 3. 

Testing

The bind-utils RPM contains tools we can use to test our caching nameserver. Test your nameserver using host or dig and querying redhat.com:

dig redhat.com . . ;; Query time: 42 msec ;; SERVER: 127.0.0.1#53(127.0.0.1)

From the above dig query you can see it took 42 msec to receive the DNS request. Now test out the caching ability of your nameserver by running dig again on the redhat.com domain:

dig redhat.com . . ;; Query time: 1 msec ;; SERVER: 127.0.0.1#53(127.0.0.1)

We dropped from 42 msec to 1 msec after the previous DNS query was cached. Caching is working! Let’s now put the cache to work by configuring the clients to use the new caching nameserver.

Client Configuration

For Linux and Windows clients you may have a couple of options for your resolver configuration depending on your network environment:

  1. If you have a router and your client’s IP address is assigned via DHCP from the router, then you can use the router to assign the primary nameserver during the DHCP lease requested from the client. Log in to your router and make sure your primary nameserver points to your caching nameserver IP address in the router DHCP settings.

  2. For Linux clients, you can set up the resolver in the same procedure as the nameserver by modifying the /etc/resolv.conf file. For Windows clients you will need to set the nameserver IP address in the Control Panel -> Network Connections -> TCP/IP -> Properties -> Use the DNS Server Address option. NOTE: The Windows DNS server option may vary depending on your version.

Test your new client configuration(s) using dig. You can use the nslookup command for Windows clients. Your DNS requests should have similar response times as we saw earlier when testing the nameserver directly.

NOTE: If you are running a firewall on the nameserver system, make sure clients have access to port 53. An example iptables rule for the 192.168.15.0/24 subnet would be:

iptables -A INPUT -s 192.168.15.0/24 -p udp –dport 53 -j ACCEPT
service iptables save

DONE!!

 

 

Posted by linux at 3:15 pm | permalink | Add comment

Easisest way of changing Linux (CentOS, Fedora, RedHat) Hostname

Use the echo command to replace the contents of /proc/sys/kernel/hostname with your new host name.

# echo hostname.com > /proc/sys/kernel/hostname

Then restart the network interfaces:

# /etc/init.d/network restart Shutting down interface venet0:  [  OK  ] Shutting down loopback interface:  [  OK  ] Bringing up loopback interface:  [  OK  ] Bringing up interface venet0: RTNETLINK answers: File exists RTNETLINK answers: File exists [  OK  ]

Now you can use the hostname command to verify that it has changed.

 Be it known that it will not touch or changed any thing in /etc/hosts use it at your own Descretion =)

Posted by linux at 12:08 pm | permalink | Add comment