29 Oct 2015

How to Configure BIND DNS on Linux for Office 365

Posted By

I recently moved my Office 365 DNS records that I had hosted at Namecheap to my own BIND DNS running on a Microsoft Azure powered CentOS LAMP server. Being a Windows guy, I was kind of lost on how to configure all of the required Office 365 DNS records on a Linux box, but I eventually fumbled my way through it successfully.

Hopefully, others who are in the same boat (or who want to manage their own DNS) can find some value out of my struggles. Truthfully, the entire process was very easy, and would likely have taken a Linux expert a few minutes to complete. If you have any trouble or hit any snags, comment below and I’ll be happy to help!

NOTE: If you host your DNS at a major domain provider, review the official Office 365 online help for how best to configure your DNS for Office 365.

Configure Bind DNS for Office 365

  1. Connect to the Linux server via SSH. Most Windows users, utilize Putty
  2. Once connected via SSH, install several packages via Yum
    1. Install BIND, the BIND utilities and BIND libraries
      yum -y install bind bind-utils bind-libs
    2. Install Nano, a console text editor
      yum -y install nano
  3. Configure BIND to run at startup
    chkconfig named on
  4. Query the firewall rules for UDP port 53 access
    iptables -vnL | grep 53
  5. Add Firewall exceptions for the required ports, which are TCP and UDP port 53
    iptables -I INPUT 3 –proto udp –dport 53 -j ACCEPT
    iptables -I INPUT 4 –proto tcp –dport 53 -j ACCEPT
  6. Add the required entries to the /etc/named.conf using Nano (Nano video tutorial)
    1. Open and edit named.conf
      nano /etc/named.conf
    2. Allow queries from outsides sources
      allow-query { all; };
    3. Add additional forwarders (these are Google’s DNS servers)
      forwarders {;; };
    4. Enable recursion
      recursion yes;
    5. Add a URI/pointer to your domain’s zone file
      zone “yourdomain.com” {type master; file “/home/youruser/conf/dns/yourdomain.com.db”;};
    6. Save and close /etc/named.conf with CTRL+O (save) and CTRL+X (close)
  7. The final /etc/named.conf should look similar to the following:
  8. Use Nano to create the zone file
    nano /home/youruser/conf/dns/yourdomain.com.db
  9. Add the required records to the zone file using the proper formatting and syntaxService.Proto.Name TTL Class SRV Priority Weight Port Target 
    1. The MX record you create will be specific to your domain, view your Domain Edit Page for full details
  10. The final format should look similar to the following:
    1. The class is the same for all records (IN, which denotes “internet“)
    2. Save and close the DNS zone file with CTRL+O (save) and CTRL+X (close)
  11. Verify that you receive an OK when checking the new zone file
    named-checkzone microsoftfanboys.com. /home/user/conf/dns/microsoftfanboys.com.db
  12. Restart the DNS service
    service named restart
  13. Log in to your Office 365 Admin Center and verify that your domain and DNS are setup correctly

And that’s it! Please note that your mileage may vary depending on your web host and Linux distro or version, but with the latest version of CentOS on Azure, it works like a charm. Hopefully this tutorial provides some value to some Office 365 and Linux users out there. If you’ve never tried Office 365, you can give it a whirl for free for 30 days.by clicking here. Let us know if this post helped you in the comments below, or if you’d like to discuss further check out our new Office 365 forum.

Loading Facebook Comments ...