DNS configuration – Ubuntu Server with Static IP

I was trying to install Ubuntu Server 12.10 on my shiny new HP ProLiant Microserver. The installation went smoothly with a couple of hiccups that are as follows:

First of all, beware of the tiny grey rectangle that shows at the bottom left of your screen when you boot from a USB disk.

I was looking at it wondering why this is happening, is it a hardware issue, a disk issue? I created the Ubuntu Server 12.10 image on multiple disks, tested it on multiple machines, then did the same with Ubuntu Server 12.04 LTE. However, every time I boot from the USB disk, all I see is the small grey rectangle at the bottom left of the screen. A bit of Googling helped and I realised that all you need to do is to leave the grey rectangle on the screen for a couple of minutes, then press “Enter”, then leave the next screen for a couple of minutes, and press “Enter” again, and magically the Ubuntu server installation screen would be in front of you. Ubuntu installation used to be easier than this, and to be fair, the rest of the installation was a breeze.

Secondly, as with most server installations, I wanted to assign my machine a static IP. One can do this by modifying the /etc/network/interfaces file. For my em1 interface, the configuration is as follows:

auto em1
iface em1 inet static
    address 192.168.0.8
    netmask 255.255.255.0
    network 192.168.0.1
    broadcast 192.168.0.255
    gateway 192.168.0.1

where my router is on 192.168.0.1 and the static IP that I have assigned is: 192.168.0.8.

However, this configuration made my DNS resolution to fail. The reason I knew the DNS was failing is because I was able to ping www.yahoo.com or www.google.co.uk by their IP addresses. After a bit of more Googling, I found that you will need to explicitly specify DNS nameservers to provide DNS resolution. I chose to use Google’s nameservers here which are:

8.8.8.8 (google-public-dns-a.google.com)
8.8.4.4 (google-public-dns-b.google.com)

To use these name servers, modify the /etc/network/interfaces file and add the following line after the em1 configuration:

dns-nameservers 8.8.8.8 8.8.4.4

The full file now looks like:

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto em1
iface em1 inet static
    address 192.168.0.8
    netmask 255.255.255.0
    network 192.168.0.1
    broadcast 192.168.0.255
    gateway 192.168.0.1

dns-nameservers 8.8.8.8 8.8.4.4

Now just restart your networking service by using the following command:

sudo service networking restart

and all should be good.

Leave a reply:

Your email address will not be published.

Site Footer

Sliding Sidebar

About Me

About Me

Strategy, Leadership, Innovation and Code Monkeyism

Social Profiles

Latest Tweets