Configuring BIND and Zimbra
on the same machine is a hot topic over in the forums. Zimbra checks to make sure that you have the correct MX an A records. In this Administrator’s PowerTip, we’ll discuss how to install and setup BIND and Zimbra on the same machine.
Administrator’s PowerTip
#3: June 20, 2007
Zimbra Forums – Zimbra wiki – Zimbra
Blog
Introduction
Because we will be dealing with MX and A records, performing this tutorial will result in downtime for
your server.
This tutorial has been tested on CentOS 4 using Zimbra Collaboration Suite 4.5.5 on i386 architecture. Although the installation of BIND may very from system to system, the basic configuration remains the same across platforms.
Due to the nature of DNS, it is highly recommended that you test before implementing. If you have difficulty, please feel free to stop by the Zimbra forums: http://www.zimbra.com/forums
Part 1 : Installing BIND
You’ll need the following packages to have a nicely running DNS Server:
bind
bind-devel
bind-utils
caching-nameserver
Let’s see if everything we need is already installed:
COMMAND:
rpm -qa | grep -i bind
rpm -qa | grep -i caching
As you can see, not all of the needed packages are installed. I need “bind-devel”
and “caching-nameserver”.
COMMAND:
yum install bind-devel*
COMMAND:
yum install caching-nameserver*
Now, let’s turn it on on for runlevels 3 and 5 at startup:
COMMAND:
chkconfig –levels 25 named on
Chkconfig –list | grep –I named
Time to start BIND, and make sure it’s running:
Part 2 : Configuring BIND
In this tutorial, the domain we’ll be creating is yourowndomain.com. You can replace this with your own domain name.
We’ll also be using vim as our editor. It really doesn’t matter which editor you use, as long as it uses UNIX carriage returns.
Now we will configure BIND to be a primary name server for a single zone. (Don’t know what a Zone is?) We will add the hostnames www and mail. We will also have BIND respond if no hostname is specified in a query (i.e. yourowndomain.com).
BIND stores its configuration data in named.conf which is located in the /etc directory. The zone data files are stored by default at /var/named (unless you have chroot. See below).
COMMAND:
vim /etc/named.conf
Scroll through the file and take a look at the contents. Locate the localhost zone:
zone "localhost" IN {
type master;
file "localhost.zone";
allow-update { none; };
};
Move the cursor on the blank like below the }; and press the i key. The i key puts vim in insert mode (you should see — INSERT — at the bottom of vim). Press the enter key once then type in the following. Note: the spacing in front of type, file, and allow-update are tabs, so press the tab key on each of those lines.
zone "yourowndomain.com" IN {
type master;
file "yourowndomain.com.zone";
allow-update { none; };
};
We have told BIND that we handle the yourowndomain.com domain and the zone data is in the yourowndomain.com.zone file located at /var/named. Now we have to create the yourowndomain.com.zone file.
Switch over to /var/named and make a copy of the localhost.zone file and save it as yourowndomain.com.zone. This will give us a template to work with so we don’t have to type as much. It also saves us from changing the file’s owner, group, and permissions.
We’re going to use localhost.zone as our template:
COMMAND:
cd /var/named
cp localhost.zone yourowndomain.com.zone
Make sure that yourowndomain.com.zone is owned by named, not root.
This is the point where a lot of administrators run into trouble. How you configure this is 100% up to you; however, there are some caveats.
Most administrators have an internal DNS server that serves their clients inside their network only. This means that your DNS server only has authority for your LOCAL zone. You cannot alter internet zones such as yahoo.com.
If you intend on changing your hosts file/ip address, I highly recommend that you run in terminal only mode. The x server does not like it when you change them while x is running. The x server may become unresponsive. Because DNS servers are queried by IP address, and not hostname, it is recommended that you have a static IP address.
You’ll need to adapt this tutorial for your own network. If your DNS server is internal, you will need to modify your outside DNS server adding Host A and MX records. However, because the Zimbra server will resolve locally, the system will not warn you that you cannot receive mail from the outside world. As far as Zimbra is concerned, it cannot tell the difference between an internet DNS server, and a local DNS server.
Put vim in insert mode and alter the zone file so it looks like the data below. Use tabs between items. Where I use 10.211.55.6 you should replace with your public IP address (or private NATted address if your running internal only).
**NOTE: 192.xxx.xxx.xxx and 10.xxx.xxx.xxx IP Addresses are NOT routable beyond your gateway. If this is a public DNS Server, you cannot have one of those IP addresses in your DNS Setup.
If you have installed bind-chroot
(COMMAND: rpm –qa | grep bind*), then you will be creating your domain zone file in /var/named/chroot/var/named/ directory, and then you will make a symlink to the /var/named/ directory, but if you didn’t install this chroot package, then you are going to create the zone file directly in the /var/named/ directory.
Now the following command works fine, if you have bind-chroot:
COMMAND:
vim /var/named/chroot/var/named/yourowndomain.com.zone
OR (if bind-chroot is not installed)
COMMAND:
vim /var/named/yourowndomain.com.org.zone
COMMAND:
vim /var/named/yourowndomain.com.zone
"mail.yourowndomain.com." is the name server responsible for yourowndomain.com. It is also going to be our mail server. When you register a domain name the registrar asks you for the name servers names and IP’s. We have given our name server the name ns1 (i.e. name server 1 and or mail). So if we were to register yourowndomain.com, we would use mail.yourowndomain.com for the name and the IP address of the machine we have designated as our DNS server.
With "IN MX 10 mail.yourowndomain.com." we are declaring a mail exchange (or mail server) with a priority of 10. Since we only use one mail server the priority has no effect.
The "IN A 10.211.55.6" means we are declaring a host (with no hostname, so it means yourowndomain.com) and its IP is 10.211.55.6. Any queries on just yourowndomain.com will resolve to 10.211.55.6. This is is useful when you configure your web server to work on yourowndomain.com or www.yourowndomain.com. If we had a different machine holding our website, we would enter the corresponding host a record and IP address.
The rest of the entries mean we are declaring hosts mail and www (mail.yourowndomain.com, www.yourowndomain.com).
The server does not update as you change the zone file(s). You’ll need to restart the server by running:
COMMAND:
service named reload
Part 3 : Other Configurations
Now that bind is all set up, we need to set it up to point to itself.
COMMAND:
vim /etc/resolv.conf
This should be a big red flag. You can see by my resolv.conf, I have DHCP turned
on. I later turned it off, as it caused lots of trouble. :)
10.211.55.6 is the IP address of our nameserver (mail.yourowndomain.com)
We also have to give the computer the correct hostname
COMMAND:
hostname mail.yourowndomain.com
And set up our hosts file:
COMMAND:
vim /etc/hosts
This ensures that if the system needs to reach mail.yourowndomain.com, it will find it on 10.211.55.6
Part 4 : Resolving Your Domain
To find out if our nameserver is resolving correctly, let’s run a dig on our server:
COMMAND:
dig mx yourowndomain.com
COMMAND:
dig a mail.yourowndomain.com
Part 5 : Installing Zimbra Collaboration Suite
This part is pretty straightforward. If you server is operating correctly, the installation process will show you that it queried for dns records, and was successful:
In this case, I got an error. That’s because the Zimbra server will query for the MX record of its hostname. I did not create an mx record for mail.yourowndomain.com. I created an MX record for yourowndomain.com. Why? Because my e-mail addresses will be “name@yourowndomain.com” not “name@mail.yourowndomain.com”.
The installer asked if I wanted to change my domain name, I said yes, and changed it to yourowndomain.com. The installer went flawlessly, and I could send and receive mail.
Troubleshooting Tips
If you can’t resolve your domain, you may want to check the following:
Are you using DHCP? If so, try making your address static
Do you have your named.conf pointing to your correct zone/host file? Are the locations correct?
Do you have chroot installed?
Are the permissions correct?
They cannot be owned by root. They should be owned by named.
Is your own server pointing to itself as a resovler? Check /etc/resolv.conf
Try restarting named
and/or checking the status (service named status)
More Help
Zimbra Wikipeida – DNS
Zimbra Forums – DNS
In a Nutshell
Administrator’s PowerTip
#3 – Handout
Download(PDF)
howto install bind on Ubuntu
Thank.