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 melon.skky.net.

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

<mailto:ddietrich@@socal.rr.com>: host hrndva-smtpin02.mail.rr.com[71.74.56.244] refused to talk to me: 421 4.7.1 – Connection refused.  Cannot resolve PTR record for 216.23.169.107

********************

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/28.169.23.216.in-addr.arpa” {
 type master;
 file “/etc/bind/96-28.169.23.216.rev”;
};

In my case, my provider assigned me the range of 216.23.169.23.96-216.23.169.110. 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 A.in-addr.arpa. The filename roughly matches this as well. I called the file 96-28.169.23.216.rev. 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-28.169.23.216.rev contents between the stars –>

****************************

$ttl 38400
$ORIGIN 96/28.169.23.216.in-addr.arpa.
@       1D      IN      SOA     ns1.wiretoss.com. ddietrich.localhost. (
                        1172404866
                        10800
                        3600
                        604800
                        38400 )
        NS      ns1.wiretoss.com.
        NS      ns2.wiretoss.com.
100     PTR     ns1.vitaven.com.
101     PTR     101.wiretoss.com.
102     PTR     102.wiretoss.com.
103     PTR     103.wiretoss.com.
104     PTR     104.wiretoss.com.
105     PTR     105.wiretoss.com.
106     PTR     106.wiretoss.com.
107     PTR     ns1.wiretoss.com.
108     PTR     108.wiretoss.com.
109     PTR     109.wiretoss.com.
110     PTR     110.wiretoss.com.
****************************

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.