XenServer 6: Problems Starting a New Ubuntu 14.04 VM

Currently XenServer has a problem starting a new Ubuntu 14.04 image. There is a problem with one of the Python scripts it uses to start machines. This should be fixed by an update soon, but for now it’s a really easy fix to perform real quick. Thanks to http://virantha.com/2014/05/21/ubuntu-14-04-trusty-on-xenserver-62/ for the quick instructions.

In XenCenter, head over to the console of the server and log in.

Edit the file in question to fix the line:

vi /usr/lib/python2.4/site-packages/grub/GrubConf.py

In vi, head down to line 428. You can do this quickly by typing “:428” and pressing enter. Then press “i” or the insert key to start editing.

Change this line:

if arg.strip() == "${saved_entry}":

to say:

if arg.strip() == "${saved_entry}" or arg.strip() == "${next_entry}":

Save and quit (Press ESC and type “:wq”), and you’re done. The Ubuntu 14.04 machine should now start.

Ubuntu: Auto Login Securely From Windows

I log into my various home Linux servers a lot (I know, geek, right?), so being able to auto log in to the servers helps a lot. Having a weak password or trying to disable password logins entirely is dangerous and insecure. After just a little setup, you can easily do it safely.

This assumes you are using SSH. If you are using Telnet to remotely manage your server, stop now and uninstall Telnet. Telnet sends all of your data, including password in plain text.

Most of these instructions were taken from: http://www.howtoforge.com/ssh_key_based_logins_putty, however I do deviate a little bit as I keep the key bits at 2048. I also don’t have all of the pretty screenshots.

At a certain point you will be asked to make a passphrase (password) for your private key. You can choose not to, however that means anyone can use the keys if they get a hold of them. If you do use a passphrase which is way more secure, when you log in, you will still have to enter a password. There is another program that can be used to store and use the password automatically however on the Windows side called Pageant. Since I’m in a private network with not a lot of outside access, I do it without. I like to live dangerously.

Set up:

  1. Download PuTTY and PuTTYGen (Pageant too if you want to use a passphrase with your key).
  2. Create a profile with the server IP Address, make sure to choose SSH as the protocol. Also in Connection -> Data, specify the user to auto log in as.
  3. Be sure to save the profile after changes are made, it doesn’t do it automatically!
  4. Connect to the server. If it is the first time, it will ask to accept the server’s host key. Press Yes.

Key generation:
Windows Side:

  1. Open PuTTYGen
  2. Click “Generate” to generate a key. Move the mouse around the blank area to make it really random.
  3. After generation, it provides a few more fields. You can change the comment if you would like. Since I’m the only one who uses my personal network, I kept everything default.
  4. Create the passphrase if you have chosen to go that route.
  5. Click on “Save private key” and “Save public key”, and save them both somewhere safe and where PuTTY can get to them. The public key must end in .txt and the private key must end in .ppk.

For example, I created a folder called “Keys” in my c:\users\username directory and save them both there.
Highlight and copy the entire key (remember to scroll down/drag down if needed). You can also open the text file and copy from there.

Linux side:
In your home directory (~), create a .ssh directory and change permissions to secure the directory:

mkdir ~/.ssh
chmod 700 ~/.ssh

Now create a new file to paste your public key in, then change permissions to secure the key:

vi ~/.ssh/authorized_keys2
chmod 600 authorized_keys2

Note: The file should look similar to below, one line only (just wrapped):

ssh-rsa AACAB3NzC[............]HmYqsZLTdiGlQ4tqKTaRuGbQ== rsa-key-20141004

Quick vi how-to:

Press i (or insert key) to start insert mode.
Right click in the PuTTY window to paste.
Press ESC key to exit insert mode.
Press : (colon) to enter command mode.
Type wg to both write and quit.

Back to Windows:

  1. Close out your putty session (running “exit” in Ubuntu will close your session on the server and exit PuTTY).
  2. Re-launch PuTTY and load the profile made earlier, but don’t connect.
  3. Go over to Connection -> SSH -> Auth and browse for your private key.
  4. Remember to go back to “Session” and click Save!
  5. Now click Open and you should log in automatically!

If you decided to use a pass phrase, you can use Pageant (part of the PuTTY suite) to provide the passphrase automatically. Pageant runs in the tray and waits to enter the passphrase when requested. For setup, just open Pageant and click “Add Key”. Browse to the same private key and enter the passphrase.

XenServer 6: An Easy Way to Apply Patches Manually

If you are setting up XenServer for the first time, or you have had an installation for a while but need to update it and aren’t paying for a license, you can’t apply updates via a pretty GUI in XenCenter. You can however do it manually in the command line.

1. Put the server into Maintenance Mode. This will require Pausing/Shutting down all of the VM’s. This way nothing gets corrupted or messed up by any chance.

2. Take a look at the system alerts that’s telling you what updates are missing. Thankfully for each patch you click on you can click on the “Go to Web Page…” button to go directly to the download. These patches are pretty big so it might take some time to get them all downloaded.

Note: As of this writing I am doing a brand new installation of XenServer, and I ended up needing 16 updates. That sounds like a lot, but one of them is Service Pack 1, which is a roll-up and takes care of a good chunk of those. Look for a service pack update first, something like “XS62ESP1”. Download that one first and apply it before downloading the rest. After that service pack, I only needed to download 7 more (which really ended up only being 5, see note below).

Note 2: In my case, even after XS62ESP1, It said I had 2 pre-SP1 updates to install, 14 and 15. I tried to install these afterwards but they would not work. After applying the rest of the post-SP1 updates however, the need for the pre-SP1 14 and 15 patches went away.

3. Download the update in question, and unzip it. You will need to upload the file ending in .xsupdate. The other files in the zip can be ignored.

4. Use a program like Filezilla to create an sftp connection to your server. You will log in as root and your password. Upload the file, it will upload to your home directory.

5. Switch over to the console tab on the XenServer itself in XenCenter. You should be logged in as root and at your home directory (~).

6. Run this command to add the update to the pool:
xe patch-upload file-name=nameofupdate.xsupdate
For example: xe patch-upload file-name=XS62ESP1.xsupdate

7. Hightlight and copy (right-click) the resulting UUID. You will need this next.
Example: 0850b186-4d47-11e3-a720-001b2151a503

8. (Optional) You can run the following to see if the patch actually uploaded:
xe patch-list

9. Run the patch to actually apply:
xe patch-pool-apply uuid=(previous ssid)
Example: xe patch-pool-apply uuid=0850b186-4d47-11e3-a720-001b2151a503

10. After it applies successfully, it just drops back down to a command line. Use XenCenter to reboot the server for the patch to take effect.

Done! Soon you will be an expert and these steps will fly by! You can remove the .xsupdate files afterwards to free up space.

Bored? Stats!

Every year that you are signed up with Jetpack (with WordPress), you get a report at the end of the year with several interesting (to me) statistics about your site. Because of the various server hackings that went on in the year 2012, the last report didn’t go so well, this one however worked great! Anyway, if you are really bored and looking for something to do, check it out below! It’s all pretty and everything.

Jetpack Annual Report – 2013

Anyway, happy new year!

Electronics Projects: VFD Informatron 2000

After looking at various very cool and vary old display technologies on eBay, I ran across a 4 line dot matrix VFD display. It was one of 4 left, so I decided to order it and build a project similar to this one that an IRC friend linked me to: http://www.pyrofersprojects.com/blog/vfd-clock-with-snmp-and-ntp/. I originally was going to go down the similar route of a Arduino or Arduino clone and an Ethernet shield, but after looking at what the cost would be, the Raspberry Pi made a lot more sense. The Raspberry Pi itself is only $25 or $35 for the B model, and wifi module for $10. Since I didn’t have any of this equipment, I ended up getting a really nice kit from Adafruit (Click here to see it) to get started. I also purchased some discreet electronics and other parts from Newark (Element 14) to build a RasPi UART to TTL converter (You can also do this with a MAX232 chip, which I haven’t tried yet) as I thought I would need it, which turned out not to be the case with the particular VFD module I got. Keep in mind however that the RasPi is 3.3v UART, not +5 TTL. That circuit will convert the two with 4 1k resistors and 2 2N222 transistors.

Here is most of the kit after I took everything out of the box and set some of it up:


After plugging it in, it was simple enough to download the NOOBS software kit from Raspberri’s site and unzip the contents onto the microSD card through the microSD card reader that both came in the kit (tiny USB connector as seen in the picture). Sliding the card into the adapter and into the pi and turning it on brought it right up to a really nice and simple installation interface where you got to choose your OS to install. Since it seems to be the most popular and most supported, I went with the default, Raspbian.


The install took a while, but completed without any issues (sorry about the flash glare and quality of picture).

Unfortunately I totally didn’t take ANY pictures during the build. Not much was missed though. First I went straight to building the TTL conversion circuit, which promptly didn’t work. I took the “big risk” and plugged the display directly into the pi and it came to life! It was actually pretty simple. The 3 pin connector on the VFD module has +5 volt, Serial Data, and GND. All 3 pins went straight to the pi. The Serial Data pin is connected to pin 8 of the pi header which is the UART transmit, 5v got connected to pin 2, and GND to pin 6. You can probably picture it in your head, there’s no components inbetween.

After that initial success, it was just down to software; so I decided to build a case. Since I had never done this before, I was hoping to make just a simple, easy to put together case with a couple pieces of Lexan (plexiglass, etc). Thankfully my local hardware store had smaller pieces but thick enough for just under $4 each, so I got 3. Two extras just in case (and I needed them). I spent hours trying to cut and drill holes correctly. Wasted many a piece of Lexan. I ended up with this!

vfdcase_1st_attempt_front vfdcase_1st_attempt_back

As you can see I used 3 molex connectors and a piece of old ribbon cable to go between the pi and the VFD module. There was barely enough room for it all. It’s actually a little more tight than I really would want it to be. That is the “B” version of the PI, and will eventually be replaced with the cheaper and less powerful “A” version, since it’s not doing much. Then I can use the “B” for other projects.

I’m still developing the script, but here is what I have as of at the time of this writing. Before you look at it, remember that this project was the first time I had ever touched Python, so the writing is going to be laughable to you experts.

#!/usr/bin/env python

import serial, urllib2, time
from time import localtime, strftime
from lxml import etree

ser = serial.Serial('/dev/ttyAMA0', 19200, parity=serial.PARITY_EVEN)
var = 1
global lastcheckhour
lastcheckhour = 0

def gettimedate():
       ser.write(strftime(" %I:%M %p", localtime()))
       ser.write(strftime(" %b %d, %Y", localtime()))

def getweather(lastcheckhour):
       if strftime("%H") != lastcheckhour:
              url = 'http://w1.weather.gov/xml/current_obs/KABQ.xml'
              fp = urllib2.urlopen(url)
              doc = etree.parse(fp)
              global temp
              temp = doc.xpath("//current_observation/temp_f")[0].text
              global weather
              weather = doc.xpath("//current_observation/weather")[0].text
              lastcheckhour = strftime("%H")
              ser.write(temp[:-2] + "F " + weather )
       return lastcheckhour

while var == 1:
       lastcheckhour = getweather(lastcheckhour)


This script has a few bugs and problems. If there is no working internet connection, it hangs when updating the weather, so you have to kill it and restart the script when an internet connection is available again. This particular display module is a little strange in that it is set up as 19200 8E1, instead of the normal 9600 7N1. The script sets up the serial connection to the display, initializes a couple variables, then goes into an infinite loop. Every minute it cycles through the loop, first clearing the display, then repositioning the cursor to the top left. It then calls the function to display the time and date, and the weather. The weather function is programmed to only actually grab the current weather every hour, as to not needlessly load up the site and get the IP address banned from it requesting every minute. The script will be a continual work in progress while I continue to learn Python and add features.
This is the end result of the script in action:


The display is very blue and looks a lot better in this picture than in real life. This display is very tired as the “pixels” in real life are mostly dim, and very uneven in brightness. I believe it’s the camera flash that makes it look blue, but in reality, it’s green. See my other posts about the other parts of programming for this project for more info.



Several weeks later the project failed, and it was an important lesson type of failure. The raspberry pi ran pretty warm the whole time, but not knowing what was “normal” I didn’t think much of it, other than thinking that I should get some heatsinks on it. Well, by then it was too late. One day the display was blank. Both the pi and the display were toast. Looking at it then revealed that I was probably pulling too much amperage through the poor little pi. The lesson? Watch the power draw! In the future anything eternal outside of an LED in my projects will have it’s own power supply. Unfortunately I couldn’t breathe any life into the pi or the display. Lost to the beginners lessons of time forever.

Raspbian: Run a Program at Startup

There are many directions out there that don’t work on Raspbian. Specifically the “upstart” scripts, as Raspbian doesn’t come with upstart, and will mess things up greatly if you install it. Raspbian uses init.d. It’s fairly simple to get things going since a nice script was provided at the link below, mirrored here.

Create script in /etc/init.d

sudo nano /etc/init.d/NameOfYourScript

The following is an example based on starting up the no-ip service [/usr/local/bin/noip], but change the name of the script and the command to start and stop it and it would work for any command.

#! /bin/sh
# /etc/init.d/noip

# Provides: noip
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Simple script to start a program at boot
# Description: A simple script from www.stuffaboutcode.com which will start / stop a program a boot / shutdown.

# If you want a command to always run, put it here

# Carry out specific functions when asked to by the system
case "$1" in
echo "Starting noip"
# run application you want to start
echo "Stopping noip"
# kill application you want to stop
killall noip2
echo "Usage: /etc/init.d/noip {start|stop}"
exit 1

exit 0

Warning – Its important you test your script first and make sure it doesn’t need a user to provide a response, press “y” or similar, because you may find it hangs the raspberry pi on boot waiting for a user (who’s not there) to do something!

Make script executable

sudo chmod 755 /etc/init.d/NameOfYourScript

Test starting the program

sudo /etc/init.d/NameOfYourScript start

Test stopping the program

sudo /etc/init.d/NameOfYourScript stop

Register script to be run at start-up
To register your script to be run at start-up and shutdown, run the following command:

sudo update-rc.d NameOfYourScript defaults

Note – The header at the start is to make the script LSB compliant and provides details about the start up script and you should only need to change the name. If you want to know more about creating LSB scripts for managing services, see http://wiki.debian.org/LSBInitScripts

If you ever want to remove the script from start-up, run the following command:

sudo update-rc.d -f NameOfYourScript remove

Credit: Big huge thanks to: http://www.stuffaboutcode.com/2012/06/raspberry-pi-run-program-at-start-up.html. The words above are his.

Big note from me:
In my case I needed my script to wait for the network to become available, so I modified the script to say:

Required-Start: $network $syslog

For more variables you could use, see: https://wiki.debian.org/LSBInitScripts

Raspbian: Wifi Going to Sleep

It seemed like I couldn’t contact my Pi after a while (and my SSH session would end seemingly for no reason). I would start a ping and it would time out for the first few times before it would start responding. At first I thought the Pi itself was, or the USB ports were going to sleep, but the Pi has no power saving functions. I finally came across the answer. In my case it was the USB wifi adapter itself that was going to “sleep” or low power mode. This works with Realtek 8192cu chipset (very common).

First, see if this is the cause:

cat /sys/module/8192cu/parameters/rtw_power_mgnt

If it can’t find the file, you aren’t using the module, and your wifi probably uses a different chip.
If it’s 0, power management is disabled.
If it’s 1, power management is enabled.

To disable power management, create a new file:

sudo nano /etc/modprobe.d/8192cu.conf

Put the following in:

# Disable power management
options 8192cu rtw_power_mgnt=0

Save, exit, and then reboot. All done.
Credit: http://raspberrypi.stackexchange.com/questions/1384/how-do-i-disable-suspend-mode

Python: Parsing Online XML The Easy Way

On my Raspberry Pi VFD project, I needed a way to download the XML feed from weather.gov to display the weather. After hours of searching Google and trying different things, I finally came across a way that actually works, using lxml and urllib2. I am still very new at Python, so I don’t completely understand it yet. Here is the code I used that works for me, hopefully will work for you too:

#!/usr/bin/env python
from lxml import etree
import urllib2
url = 'http://w1.weather.gov/xml/current_obs/KABQ.xml'
fp = urllib2.urlopen(url)
doc = etree.parse(fp)
temp = doc.xpath("//current_observation/temp_f")[0].text
temp = temp[:-2]
print temp

Of course, this just returns the temperature in Fahrenheit. If you look at the xml itself you can see that the section I was interested in was “temp_f” under “current_observation”. Another interesting Python trick is “temp[:-2]“. This removes the right 2 characters from the string, changing 37.6 to 37. I also later made a variable for weather which returns things like “overcast”. That line looks like weather = doc.xpath("//current_observation/weather")[0].text. Hopefully this much simpler example than what I could find on Google will make things a little clearer for everyone.

To use this, make sure you install lxml:

sudo apt-get install python3-lxml

Note: I lost the URL to the code I ended up using, so I can’t give proper credit, sorry!

Ubuntu Server 13: Nagios 4

Installing Nagios on Ubuntu (or any Debian) isn’t smooth or easy; and the instructions that are on Nagios’s site don’t work. Through much trial and error and Googling I have finally managed to get a good installation working. I had the same issues with Nagios 3.5, and while there are older packages you can install from apt-get, they seem to be broken, or set up in some weird way I can’t fathom. I prefer to install from scratch as much as possible, both for compiling to my environment and for learning. This should probably still work on Ubuntu Server 12.x and Nagios 3.5 also.

Note: As usual I use vim (vi type editor, but easier to use), and in this case we are going to make ourselves root since there are so many commands, using sudo over and over again will be too much work. I also recommend starting from a fresh but completely updated box.

Here we go! Do the following commands:

sudo -i
apt-get install build-essential apache2 php5-gd libgd2-xpm libgd2-xpm-dev libapache2-mod-php5 sendmail-bin libssl-dev
cd /tmp
wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-4.0.0.tar.gz
wget https://www.nagios-plugins.org/download/nagios-plugins-1.5.tar.gz
useradd nagios
groupadd nagcmd
usermod -a -G nagcmd nagios
tar zxvf nagios-3.4.1.tar.gz
tar zxvf nagios-plugins-1.4.15.tar.gz
cd nagios
./configure --with-nagios-group=nagios --with-command-group=nagcmd -–with-mail=/usr/bin/sendmail
make all
make install
make install-init
make install-config
make install-commandmode
make install-webconf
cp -R contrib/eventhandlers/ /usr/local/nagios/libexec/
chown -R nagios:nagios /usr/local/nagios/libexec/eventhandlers
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

If everything goes ok and there are no config errors, continue on:

cd /tmp/nagios-plugins-1.4.15
./configure --with-nagios-user=nagios --with-nagios-group=nagios
make install
replace /etc/init.d/nagios with (one provided)
htpasswd –c /usr/local/nagios/etc/htpasswd.users nagiosadmin

Now, the init script that comes with Nagios does not work in Debian. It was made for RedHat/CentOS. Someone kindly uploaded an older script for Nagios that does work for Debian. Do the following to replace the broken script easily:

First, delete the old file:

rm /etc/init.d/nagios

Then, make a new file:

vim /etc/init.d/nagios

and paste the contents below:

# chkconfig: 345 99 01
# description: Nagios network monitor
# File : nagios
# Original Author : Jorge Sanchez Aymar (jsanchez@lanchile.cl)
# Description: Starts and stops the Nagios monitor
#              used to provide network services status.

# Load any extra environment variables for Nagios and its plugins
if test -f /etc/sysconfig/nagios; then
   . /etc/sysconfig/nagios

status_nagios ()

   if test -x $NagiosCGI/daemonchk.cgi; then
      if $NagiosCGI/daemonchk.cgi -l $NagiosRunFile; then
              return 0
         return 1
      if ps -p $NagiosPID > /dev/null 2>&1; then
              return 0
         return 1

   return 1


   if status_nagios $1 $2; then
      echo "nagios (pid $NagiosPID) is running..."
      echo "nagios is not running"

killproc_nagios ()

   kill $2 $NagiosPID


pid_nagios ()

   if test ! -f $NagiosRunFile; then
      echo "No lock file found in $NagiosRunFile"
      exit 1

   NagiosPID=`head -n 1 $NagiosRunFile`

# Source function library
# Solaris doesn't have an rc.d directory, so do a test first
if [ -f /etc/rc.d/init.d/functions ]; then
   . /etc/rc.d/init.d/functions
elif [ -f /etc/init.d/functions ]; then
   . /etc/init.d/functions


# Check that nagios exists.
if [ ! -f $NagiosBin ]; then
    echo "Executable file $NagiosBin not found.  Exiting."
    exit 1

# Check that nagios.cfg exists.
if [ ! -f $NagiosCfgFile ]; then
    echo "Configuration file $NagiosCfgFile not found.  Exiting."
    exit 1

# See how we were called.
case "$1" in

      echo -n "Starting nagios:"
      $NagiosBin -v $NagiosCfgFile > /dev/null 2>&1;
      if [ $? -eq 0 ]; then
         su - $NagiosUser -c "touch $NagiosVarDir/nagios.log $NagiosRetentionFile"
         rm -f $NagiosCommandFile
         touch $NagiosRunFile
         chown $NagiosUser:$NagiosGroup $NagiosRunFile
         $NagiosBin -d $NagiosCfgFile
         if [ -d $NagiosLockDir ]; then touch $NagiosLockDir/$NagiosLockFile; fi
         echo " done."
         exit 0
         echo "CONFIG ERROR!  Start aborted.  Check your Nagios configuration."
         exit 1

      echo -n "Stopping nagios: "

      killproc_nagios nagios

      # now we have to wait for nagios to exit and remove its
      # own NagiosRunFile, otherwise a following "start" could
      # happen, and then the exiting nagios will remove the
      # new NagiosRunFile, allowing multiple nagios daemons
      # to (sooner or later) run - John Sellens
      #echo -n 'Waiting for nagios to exit .'
      for i in 1 2 3 4 5 6 7 8 9 10 ; do
          if status_nagios > /dev/null; then
         echo -n '.'
         sleep 1
      if status_nagios > /dev/null; then
          echo ''
          echo 'Warning - nagios did not exit in a timely manner'
          echo 'done.'

      rm -f $NagiosStatusFile $NagiosRunFile $NagiosLockDir/$NagiosLockFile $NagiosCommandFile

      printstatus_nagios nagios

      printf "Running configuration check..."
      $NagiosBin -v $NagiosCfgFile > /dev/null 2>&1;
      if [ $? -eq 0 ]; then
         echo " OK."
         echo " CONFIG ERROR!  Check your Nagios configuration."
         exit 1

      printf "Running configuration check..."
      $NagiosBin -v $NagiosCfgFile > /dev/null 2>&1;
      if [ $? -eq 0 ]; then
         echo "done."
         $0 stop
         $0 start
         echo " CONFIG ERROR!  Restart aborted.  Check your Nagios configuration."
         exit 1

      printf "Running configuration check..."
      $NagiosBin -v $NagiosCfgFile > /dev/null 2>&1;
      if [ $? -eq 0 ]; then
         echo "done."
         if test ! -f $NagiosRunFile; then
            $0 start
            if status_nagios > /dev/null; then
               printf "Reloading nagios configuration..."
               killproc_nagios nagios -HUP
               echo "done"
               $0 stop
               $0 start
         echo " CONFIG ERROR!  Reload aborted.  Check your Nagios configuration."
         exit 1

      echo "Usage: nagios {start|stop|restart|reload|force-reload|status|checkconfig}"
      exit 1


# End of this script

Save and exit.
Note: If you are in VIM through ssh/putty, you can just right-click and it pastes in perfectly.

Next, make the file executable:

chmod a+x /etc/init.d/nagios

Finally, start the Nagios service and restart Apache2:

service nagios start
service apache2 restart

At this point you will have seen another error when apache2 restarts. See this post to fix the Apache2 Fully Qualified Name Error.

Now, you should be able to go to your machine in a web browser. Go to http://yourmachineipornamehere/nagios.

Optional but recommended:
If you would like the service to start up automatically on boot (which is recommended), just add it to rc.d:

sudo update-rc.d minidlna defaults

Ubuntu 14.04+: Changing to Static IP

Whenever you make an Ubuntu Server box, it’s standard to make it a static IP. There are many other pages out there that say different things on how to do this, but most of them miss the whole DNS part of it, or they have you go through extra steps that aren’t necessary anymore.

First, edit /etc/network/interfaces:

sudo vim /etc/network/interfaces

Then change:

iface eth0 inet dhcp


iface eth0 inet static

Then, add the following lines:

address your.ip.address.here
netmask your.netmask.here
gateway your.gateway.here
dns-nameservers your.dns.nameserver.here optional.second.server.here

Here is an example of a completed static entry:


Save and exit.Then run the following to disable DHCP client for next reboot:

sudo update-rc.d -f dhcp3-server remove

Finally, restart the interface (or just reboot):

sudo ifdown eth0
sudo ifup eth0

That’s it! You can test by pinging Google/Yahoo/etc. The command ifconfig will show you the current configuration of network interfaces.