How to Setup a DNS Server in Ubuntu

Overview
Would you like to setup a DNS Server in Ubuntu? How about setting up a private internal domain name at home? Well, you’ve come to the right place. There are number of tutorials on the internet showing you how to setup a DNS Server with Ubuntu using Bind 9. So, why another how-to document? That’s a good question. I’ve decided I needed to write a simple tutorial that anyone with a little bit of Linux knowledge would be able to follow. In the process, I hope readers are also able to learn how DNS works. Ok, let’s jump right to it!

What is DNS?

First of all, let’s cover the basics. What is DNS? DNS stands for Domain Name Server. It’s a service that runs on a server that translates humanly recognizable domain names such as www.yahoo.com or www.google.com into its assigned IP addresses. If the DNS server does not recognize the domain name being requested, it will forward the domain name request to another DNS server and so on until the name is resolved.

A typical DNS request is when someone is accessing a website. Let’s use the www.yahoo.com domain as an example. When a user clicks a Yahoo link or types the Yahoo URL on the address bar of the browser, the DNS server processes the domain request. If it doesn’t find www.yahoo.com on its DNS table, it will forward the request to another DNS server with a higher authority and so on until it finds a server with the URL entry. The IP address information is then sent back to the user’s browser. If the domain name is not found, a “server not found” message is displayed on the browser.

Assumptions

Enough with the DNS background. Let’s now start configuring our own DNS server. Let’s assume that we have the following: we want to create a private internal domain name called mydomain.com, our private internal network is 192.168.0.x and our router and gateway is set at 192.168.0.1. Let’s assume all devices are going to be configured with static IP addresses. Normally, most computer systems nowadays are configured to automatically obtain IP addresses from the DHCP server/router. In this example, we will use static IP addresses to show how DNS works. Finally, we have 3 computers connected to our network:

  • Ubuntu Server, the DNS server – 192.168.0.9
  • Ubuntu Desktop – 192.168.0.10
  • PC – 192.168.0.11

Instructions

1. To install the DNS server, we need to install Bind 9.

sudo apt-get install bind9

2. Let’s configure Bind. We need to touch 5 files.

We will edit 3 files.

  • /etc/bind/named.conf.local
  • /etc/bind/named.conf.options
  • /etc/resolv.conf

We will create 2 files.

  • /etc/bind/zones/mydomain.com.db
  • /etc/bind/zones/rev.0.168.192.in-addr.arpa

A. First step. Lets add our domain zone – mydomain.com.

sudo vi /etc/bind/named.conf.local
# Our domain zone
zone "mydomain.com" {
   type master;
   file "/etc/bind/zones/mydomain.com.db";
};
 
# For reverse DNS 
zone "0.168.192.in-addr.arpa" {
   type master;
   file "/etc/bind/zones/rev.0.168.192.in-addr.arpa";
};

Save file. Exit.

We just created a new domain. Please note: later we will create two files named mydomain.com.db and rev.0.168.192.in-addr.arpa files. Also, notice the reverse IP address sequence in the reverse DNS section.

B. Let’s add the DNS servers from your ISP. In my case, I’m using Comcast DNS servers. You can place the primary and secondary DNS servers here separated by semicolons.

sudo vi /etc/bind/named.conf.options
forwarders {
   68.87.76.178;
};

Save file. Exit.

C. Now, let’s modify the resolv.conf file found in /etc and place the IP address of our DNS server which is set to 192.168.0.9.

$ sudo vi /etc/resolv.conf
search mydomain.com.
nameserver 192.168.0.9

D. Now, let’s define the zones.

sudo mkdir /etc/bind/zones
sudo vi /etc/bind/zones/mydomain.com.db
$TTL 3D
@ IN SOA ns.mydomain.com. admin.mydomain.com. (
   2007062001
   28800
   3600
   604800
   38400
);
mydomain.com.  IN      NS         ns.mydomain.com.
ubuntudesktop  IN      A          192.168.0.10
www            IN      CNAME      ubuntudesktop
pc             IN      A          192.168.0.11
gw             IN      A          192.168.0.1
                       TXT        "Network Gateway"

The TTL or time to live is set for 3 days
The ns.mydomain.com nameserver is defined
ubuntudesktop, pc and gateway are entered as an A record
An alias of www is assigned to ubuntudesktop using CNAME

E. Let’s create a “rev.0.168.192.in-addr.arpa” file for reverse lookup.

sudo vi /etc/bind/zones/rev.0.168.192.in-addr.arpa
$TTL 3D
@       IN      SOA     ns.mydomain.com. admin.mydomain.com. (
                2007062001
                28800
                604800
                604800
                86400
)
        IN      NS      ns.mydomain.com.
1       IN      PTR     gw.mydomain.com.
10      IN      PTR     ubuntudesktop.mydomain.com.
11      IN      PTR     pc.mydomain.com.

3. Let’s restart Bind to activate our latest changes.

sudo /etc/init.d/bind9 restart

4. Finally, let’s test our new domain and DNS entries.

Dig

$ dig mydomain.com

Nslookup

nslookup gw

5. That’s it.

Driving My Ubuntu Desktop

Pictured above is how I drive my Ubuntu Desktop. It’s clean, fast and it’s brown all over. That’s Ubuntu for sure. Some people don’t really care for the earthy tones, but I don’t mind. My screen resolution is set to 1280 x 1024 pixels. I’ve decided to use this background for a bit of a change. By the way, the Compiz Fusion Desktop Effects are super. I love the applications: OpenOffice, Gimp, MoviePlayer, Rythymbox Music Player and the Bluefish Editor are just a few. The only thing I miss in Windows are the games. It may be time for some virtualization using VMWare. That’s my next project.

Compiz Fusion Keyboard Shortcuts

For Linux users who are fortunate enough to be playing with the Desktop Effects on their favorite Linux distribution – mine is Ubuntu, here’s a list of keyboard shortcuts for the Compiz Fusion Desktop Effects that you may have been looking for. I have put together a list mainly because I’ve had a hard time finding a comprehensive list from a single location. I may have missed something, so please let me know. One more thing, the Super key is the Windows key in case you are wondering. Here are the shortcuts.

Desktop Effects1 Keyboard Shortcuts
Rotate Cube Mousewheel on Desktop
Switcher2 Alt + Tab
Shift Switcher3 Super + Tab (2 modes: flip and cover)
Ring Switcher Super + Tab – overrides Shift Switcher
Expo Super + E (toggle)
Film Effect Ctrl + Alt + Down Arrow4
Rotate Cube Manually Ctrl + Alt + Left Mouse Button
Scale Windows Alt + Shift + Up Arrow
Show/Clear Desktop Ctrl + Alt + D (toggle)
Snapping Windows Move a window across workspaces5
Screenshot Super + Left Mouse Button
Zoom In/Out Super + Mousewheel
Transparent Window Alt + Mousewheel
Resize Window Alt + F8
Move Window Alt + F7
Add Helper Super + P
Widget Layer F9 (toggle)
Water Effects Shift + F9 (toggle)
Fire Effects: On Super + Shift + Left Mouse Button
Fire Effects: Clear Super + Shift + C
Annotate: Draw Super + Left Mouse Button
Annotate: Start Super + 1
Annotate: End Super + 3
Group: Select Window(s) Super + S
Group: Group Windows Super + T
Group: Ungroup Windows Super + U
Group: Flip Windows Super + Right or Left Arrow

1 Effects have to be enabled to see results.
2 To see the full effect, have multiple windows or programs open.
3 To configure: Go to Advanced Desktop Effects Settings.
4 Use left and right arrow thereafter to move to workspaces.
5 Disables Wobbly Windows.

Make sure the effects are enabled to see results. You can do so by going to System – Preferences – Advanced Desktop Effects Settings. Some effects will disable others. For example, the Desktop Wall will disable the Desktop Cube, Snapping Windows will disable Wobbly Windows and many more. Please let me know if I missed something, so I can add more effects to the list.

Ubuntu 7.10

I recently upgraded my Linux desktop to Ubuntu 7.10. The upgrade process took a little over an hour considering the number of packages that were being downloaded and installed. Moving from Ubuntu 7.04 Fiesty Fawn to 7.10 Gutsy Gibbon as they are known to the Ubuntu community, is an extremely easy process. All it takes is a handful of clicks. I suggest that you go for a coffee break while the system is downloading. The download can last up to an hour and that is with a fast internet connection.

Ubuntu 7.10 Gutsy Gibbon’s features include: the latest Gnome 2.20, a “fast user switching” utility allowing easy switching of users between sessions, a “NTFS writing” capability allowing Ubuntu users to write to a Windows NTFS file system – a first in Ubuntu, a “desktop search” utility and the “fully automatic printer configuration” just to name a few.

The inclusion of the Compiz Desktop Effects in my opinion is the biggest draw to Ubuntu 7.10. It’s the eye candy. Unfortunately, the Desktop Effects didn’t work for me from the outset. It was somehow disabled due to my restricted ATI graphic drivers which were not included on Ubuntu’s whitelist. There is no cause for concern. After scouring the forums, I installed the xserver-xgl, compiz and the compiz settings manager to make Desktop Effects work again. Here’s the command if you are interested.

#sudo apt-get install xserver-xgl compiz compizconfig-settings-manager

I’m quite impressed with the Compiz Desktop Effects although the documentation is very skimpy. I had to scour the internet to find some keyboards shortcuts that I badly needed. I hope Ubuntu fixes the issues with the ATI drivers because leaving the Desktop Effects uninstalled is not what I expected with Ubuntu 7.10.

Evolution vs Thunderbird

It didn’t take time for me to throw out the Evolution email client from my Ubuntu platform. Instead, I installed Mozilla’s Thunderbird, an email client which I’m very familiar with. What caused the switch? Well, I was trying to configure an email account running on an IMAP server. I had a terrible time in getting it to work. After so many unsuccessful tries, it was time for me to kiss the Evolution package goodbye. I’m glad it’s gone because Thunderbird is working just fine in Ubuntu.

To remove Evolution package:
#sudo apt-get remove evolution

To Install Mozilla Thunderbird
#sudo apt-get install mozilla-thunderbird

Dell Picks Ubuntu Linux

Dell has decided to ship Ubuntu Linux on its desktop and notebook computers. The decision to offer the free open-source operating system to its customers was a result of a program called IdeaStorm. Ubuntu recently released version 7.04 code named Fiesty Fawn. For laptop users, the wireless laptop drivers are very important. It better be included in the release and distribution.

Bucking the Popularity

I recently had the urge to replace my Linux desktop from Fedora to Ubuntu mostly because of the popularity of the Ubuntu desktop among Linux users. I gave Ubuntu a try using Ubuntu’s Live CD. After a few hours of playing around with the desktop, I’ve decided to stick with Fedora Core 5. It’s not about the drabby brown color of the Ubuntu desktop, although I prefer the dark blue colors of Fedora. It’s all about the tools I’m familiar with in Fedora. I feel really comfortable with Fedora. I feel lost in Ubuntu. It’s ok to buck popularity for now. Maybe, in the future I can revisit Ubuntu.

Favorite Desktop Linux

What’s the most popular Linux desktop? It’s Ubuntu, according to a recent DesktopLinux.com survey conducted on 15,000 Linux desktop users. I happen to use the Fedora Redhat desktop which came in at 5th place at just 7%. So, why Ubuntu? Is it hype or a cult following? Ease of use and commitment to regular releases and updates every 6 months is their main selling point. I tried Ubuntu more than a year ago, but I didn’t see anything special from this popular desktop. Maybe, it’s time to revisit Mr. Ubuntu.

Popular Linux Desktops

Continue reading

Sudo

I’ve learned something new today, Sudo. Sudo is a Unix command that allows system administrators to give certain users the ability to run some or all commands as root. Why? Well, I have this program called Bluefish which I use as a HTML editor. I have to run Bluefish as root to modify my webroot directory. I could have ran Bluefish as a regular user, but I didn’t want to use my home directory to shuttle back and forth the modified web pages.

Continue reading