Setting up a classless DNS with Bind9 on Ubuntu and Red Hat Linux flavors

Setting up a classless DNS is critical if you are setting up a mail server on your classless set of IPs. For instance, when my mail users send e-mails to Comcast, Cox, or Time-Warner, my mail is rejected with the following message between the stars:


Subject: Undelivered Mail Returned to Sender

This is the mail system at host

I’m sorry to have to inform you that your message could not be delivered to one or more recipients. It’s attached below.

For further assistance, please send mail to postmaster.

If you do so, please include this problem report. You can delete your own text from the attached returned message.

                   The mail system

<>: host[] refused to talk to me: 421 4.7.1 – Connection refused.  Cannot resolve PTR record for


In order to resolve this issue, you must ask your hosting provider to forward reverse DNS queries to your DNS server. Then, you can set up the reverse DNS for your classless range of IPs. Start by editing your named.conf file (/etc/bind/named.conf on Ubuntu, /var/named/chroot/etc/named.conf on Red Hat flavors). Add the following lines–>

zone “96/” {
 type master;
 file “/etc/bind/96-”;

In my case, my provider assigned me the range of This is a /28 set of addresses. Notice how we reverse the zone entry. The Class D first, followed by a /, followed by the .Class C.Class B.Class The filename roughly matches this as well. I called the file 96- Just put this file in your /etc/bind directory on Ubuntu, or /var/named/chroot/var/named on Red Hat Linux flavors (RH5, CentOS, Fedora Core, etc.)

Now for the actual file 96- contents between the stars –>


$ttl 38400
@       1D      IN      SOA ddietrich.localhost. (
                        38400 )
100     PTR
101     PTR
102     PTR
103     PTR
104     PTR
105     PTR
106     PTR
107     PTR
108     PTR
109     PTR
110     PTR

Restart bind9 and you should now have a happy reverse DNS to the rest of the world, and especially those pesky mail servers that check for everything.

Linux overwrites DNS resolver /etc/resolv.conf

Linux will overwrite your /etc/resolv.conf in 3 cases. If you have:

  1. Network Manager enabled.
    Disable the Network Manager by turning it off with the following commands:
    >service NetworkManager stop
    >chkconfig NetworkManager off        

  2. DHCP enabled.
    dhcpd will overwrite your /etc/resolv.conf when it acquires an IP address. Convert to a static IP if you are in control of the network.
  3. DNS1, DNS2 or any other DNS# entries in any of your network interface configurations.
    If you are the administrator of this machine, check every file matching the following pattern:
    >find /etc/sysconfig/network-scripts/ifcfg-*
    and look for any DNS# entries in every matching file. If you find any DNS# lines, and if you are root, remark the lines by inserting a # sign at the beginning of the DNS# line.
    Save the file(s) lipitor cost.
    Then run –>
    >service network restart

Once you’ve gone through these 3 items, you should be able to now edit and save your /etc/resolv.conf file. Verify that the file no longer is being overwritten. Just execute >cat /etc/resolv.conf a few times for a few minutes and verify the file is no longer changing. Also >reboot the machine to be extra sure nothing changes in the /etc/resolv.conf file.