Technology

apt-get upgrade Confusion

While performing some regular maintenance on one of my Ubuntu machines I was getting a bit confused between all of the upgrade commands, so I investigated further.  I’ve listed below the basic differences between each:

sudo apt-get upgrade

install newest versions of packages on machine

sudo apt-get dist-upgrade

upgrades all packages on system, handle dependency changes (remove obsolete packages).  This command prepares the system for upgrade but since /etc/sources.list is not changed to the sources for the newer distribution it will not actually upgrade to the newest version.

To actually perform a distribution upgrade the following command should be used (ensure you have a backup before issuing this command.  The upgrade could make your system unstable):

First, check which version you are currently running using the following:

lsb_release -a

Next, you can download the newest update manager and issue the upgrade command:

sudo apt-get install update-manager-core
sudo do-release-upgrade

All of these commands should be used with caution as you are directly affecting your software packages installed on the system.

This site was very helpful in my initial investigation of the differences of this command.

BIND Tip – Dumping The Cache

Thought it would be useful to document a useful command while learning how to operate BIND.  I set BIND9 up on my print server and was trying to examine how much resources it was consuming.  I found the following command helpful – it dumps the current BIND9 database from memory to /var/cache/bind (by default):

sudo rndc dumpdb –all

After that I simply navigated to /var/cache/bind and issued the command

ls –lah

and was shown that it consumes 649K in memory from the output of the command above:

-rw-r--r--  1 bind bind 649K 2010-05-02 08:15 named_dump.db

I’m not a BIND expert and am actually stumbling around with some custom zone settings but I thought this was worth mentioning.  I’m also assuming this is quite small for a db size since this was only setup for testing for a 1 user network.  Nevertheless, it would be useful to check that you have adequate memory to handle the database size if you are deploying a DNS server for your network. I believe you can also limit the cache size if needed, but I don’t think I’ll be needing that option added to my config anytime soon.

If you haven’t already, read up on the rndc command – because it’s quite powerful.  In addition, make sure you are using the latest stable version of BIND to (as well as other benefits) protect against cache poisoning.

WordPress 3.0 Upgrade Error Fix

I was recently upgrading the version of WordPress on one of the sites I run and encountered the following error: “Fatal error:

Call to a member function on a non-object in  *SITEHERE*/taxonomy.php  on line 289".

It took me a little looking around to find a solution but there was someone nice enough to look into it in the wordpress forums and posted a solution.  Hopefully this article can save those of you with a similar issue some time in getting things running again.

The problem occurs due to an error in the “Podcasting Plugin by TSG”.  The fix is actually pretty simple and requires a few quick steps:

1. Manually deactivate all plugins.  The procedure to do so when you can’t access the administration menu is located here.

2. Edit the file SITEROOT/plugins/podcasting/podcasting.php – On line 15 replace the code:

register_taxonomy('podcast_format', 'custom_field');

to

function build_taxonomies() {
register_taxonomy('podcast_format', 'custom_field');
}
add_action( 'init', 'build_taxonomies', 0 );

3. Re-enable your plugins and test your site – if this was the issue, things should be working properly now.

4. Upgrade the Podcast plugin in the Plugins menu.  I upgraded to Version 2.3.10.

Thanks to wordpress forum user ddarby14 for posting the solution.  Source thread.

I checked out this plugin and the offending line I found was line 15 in /plugins/podcasting/podcasting.php

register_taxonomy('podcast_format', 'custom_field');

I changed this to a function call

function build_taxonomies() {
	register_taxonomy('podcast_format', 'custom_field');
  }
  add_action( 'init', 'build_taxonomies', 0 );

Boot To USB Without BIOS USB Boot Support

On any new machine I purchase I ensure to thoroughly run all hardware with the various diagnostic applications available on the Ultimate Boot CD.  I have the UBCD setup on a USB drive which allows me to ditch the CD wallet.  Problem is, even in this day and age, there are still machines I encounter that are not compatible with USB boot.  Most of the time I’ll burn an ISO to CD and hook up a spare CD-ROM drive, but recently I was determined to get the computer to boot to USB.  No BIOS update was available and I searched every inch of the BIOS menus looking for a USB boot option with no success.  So, after some browsing around I found PLoP.  PLoP is a Boot Manager that will (among other things) allow a machine to boot to USB even without BIOS support.  It’s actually quite an easy solution but does require you to make either a floppy or CD.  Since the machines I was working with were previously used in a cluster they had no CD-ROM drives but they did contain a floppy drive.  To create a PLoP boot disk using another Ubuntu machine I completed the following:

wget http://download.plop.at/files/bootmngr/plpbt-5.0.10.zip

sudo apt-get install unzip

unzip plpbt-5.0.1.0.zip

cd phpbt-5.0.10/

Insert the floppy to write to into the drive.  I’m assuming it’s located at /dev/fd0.

fdformat /dev/fd0

dd if=plpbt.img of=/dev/fd0 bs=1440k

Once you complete this you have created the bootable floppy and can now boot the machine to the floppy which contains the boot manager.  You will need to ensure that the installed floppy drive is listed on the boot list.  Note that the ISO is also included in the downloaded package if you would rather create a CD.

After you boot into PLoP there is a list of available boot options.  USB should be an option in the list and you simply select that as the boot option, press Enter, and your USB bootable drive can now be accessed!  Note:  Once booted to USB I could *only* use PS/2 keyboard and mouse with the machine.

Reassign NIC Identifiers In Ubuntu

I swapped out some NICs recently on a few of my lab machines.  These machines had a working install of Ubuntu Server 9.04.  After installing the NICs and rebooting, ifconfig showed nothing but lo details.  The first thing I did was ensured that the cards were seen by the OS by typing:

lspci | grep Ethernet

to which I received the output:

02:04.0 Ethernet controller: Intel Corporation 82557/8/9/0/1 Ethernet Pro 100 (rev 08) 

02:05.0 Ethernet controller: Intel Corporation 82557/8/9/0/1 Ethernet Pro 100 (rev 08)

This was correct as my new NIC was a dual Intel NIC.  From there I issued the command:

sudo mv /etc/udev/rules.d/70-persistent-net.rules /etc/udev/rules.d/70-persistent-net.rules.old

I reboot the system and all NICs were re-assigned to the correct Eth* interface.  Note that that the 70-persistent-net.rules.old will contain the old configuration should I choose this new NIC doesn’t work out for the system.

Where I originally found the re-assignment command.

Differential Backup Using Rsync

Rsync is a well known tool for many who work in Linux regularly.  Quite some time ago I put together a short script that uses Rsync and logs the result nicely. The first task Rsync performs is to send an incremental file list which contains any differences between the source and destination drive, then makes changes to the destination drive accordingly.    Because of that last part extreme caution should be used when executing such a script because you run the risk of overwriting information on the destination drive you may not want removed.  I have a dedicated drive for DV backups mounted in /media/dv-backup.  To use this script just change the variables accordingly:

#!/bin/bash

#dv backup script

src=/media/dv 

dest=/media/dv-backup

log=/var/log/backup/dv-backup.log

echo "---" $date "-------------------" >> $log

rsync -t -r -v --delete $src $dest >> $log

echo "--------------- END ---------------" >> $log

I have my backups log in /var/log/backup/ and they merely append the file each time Rsync runs.  I’m aware this is quite a simple script and could even be consolidated to one line.  However, I found that breaking this up makes it easy to read and change.  Also, who wants to remember every Rsync switch they want each time they want to perform a differential backup?

One quick change you could make to make it require less manually editing is replace the variables to take the terminal arguments.  Such a revision is listed below:

src=$1

dest=$2

log=$3

echo "---" $date "-------------------" >> $log

rsync -t -r -v --delete $src $dest >> $log

echo "--------------- END ---------------" >> $log

Usage to achieve same result as original:

./backup.sh /media/dv /media/dv-backup /var/log/backup/dv-backup.log

Both script revisions are attached:  backup.sh backup2.sh Use at your own risk.. don’t blame me if you incorrectly wipe a drive!

Setup Link Aggregation in Ubuntu

Link aggregation is something that has greatly interested me the last few months and I’ve been anxious to play with it on my own network setup.  For those not familiar with link aggregation there is a lot of good documentation on Wikipedia to get caught up to speed.  In my lab I wanted to setup link aggregation on a box with a NC3134 which is a dual NIC (2x 10/100 full duplex ports).  I couldn’t do proper 802.3ad because I don’t have a switch which supports it…yet.  However, since I am running Ubuntu server I found I could still set it up using a different mode.  The mode I decided to configure the bond as is mode 0 otherwise known as the round-robin bond mode.  This type is described as “Round-robin policy: Transmit packets in sequential order from the first available slave through the last.  This mode provides load balancing and fault tolerance.” (Linux Horizon)

The setup for bonding the NICs is actually quite simple.

sudo apt-get install ifenslave
sudo nano /etc/network/interfaces

Comment out your current configuration lines using the “#” before all lines.  The following was my setup for the bond address configuration:

auto bond0
iface bond0 inet static
     address 192.168.2.200
     netmask 255.255.255.0
     broadcast 192.168.2.255
     gateway 192.168.2.1
slaves all
bond-mode 0
bond-miimon 100

This configuration will use all of my network devices in the bond (which in this case is just 2) and give the IP address 192.168.2.200.  Note that I specified bond-mode 0.  There are several other bond types (some of which require a 802.3ad capable switch) and it would be worth your while to read up on them to find which would be best for you.

Another thing to note in this configuration is that I used bond-miimon 100.  This means that the links will be checked for failures every 100 milliseconds.  Setting this value to 0 disables checking for link failure.

Save and exit the configuration file.  From here you can take the interfaces down by issuing:

sudo ifdown eth0
sudo ifdown eth1

At this point I connected the 2nd Ethernet cable and restarted the networking services

/etc/init.d/networking restart

Simply type ifconfig and you should see bond0 in the list and listed as UP BROADCAST RUNNING MASTER MULTICAST and all others as UP BROADCAST RUNNING SLAVE MULTICAST.  Next we will test performance of the connection to ensure that the bond is functioning as it should.

Using iperf I can test the bandwidth utilized between the server and client in memory (which takes the drive write bottleneck out of the equation).  To setup iperf see my previous article on using iperf.

I have 192.168.2.101 setup as the server and 192.168.2.200 (the bonded NICs) as the client.  I issue the following command to test my connection:

Iperf –c 192.168.2.101 –i 2

The output was as follows:

------------------------------------------------------------
Client connecting to 192.168.2.101, TCP port 5001
TCP window size: 16.0 KByte (default)
------------------------------------------------------------
[  3] local 192.168.2.200 port 33878 connected with 192.168.2.101 port 5001
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0- 2.0 sec  44.8 MBytes    188 Mbits/sec
[  3]  2.0- 4.0 sec  44.9 MBytes    188 Mbits/sec
[  3]  4.0- 6.0 sec  44.9 MBytes    188 Mbits/sec
[  3]  6.0- 8.0 sec  43.9 MBytes    184 Mbits/sec
[  3]  8.0-10.0 sec  44.8 MBytes    188 Mbits/sec
[  3]  0.0-10.0 sec    223 MBytes    187 Mbits/sec

You can see that now the connection is reaching ~188Mbits out of the theoretical 200Mbits that the bond provides (remember we are using 2x 100mbit lines).  This is exactly the result we want.

Next, I wanted to test the fault of one line.  I disconnected one one of the cables from the dual NIC and ran the iperf connection test again.

------------------------------------------------------------
Client connecting to 192.168.2.101, TCP port 5001
TCP window size: 16.0 KByte (default)
------------------------------------------------------------
[  3] local 192.168.2.200 port 33879 connected with 192.168.2.101 port 5001
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0- 2.0 sec  22.5 MBytes  94.4 Mbits/sec
[  3]  2.0- 4.0 sec  22.4 MBytes  94.1 Mbits/sec
[  3]  4.0- 6.0 sec  22.4 MBytes  94.0 Mbits/sec
[  3]  6.0- 8.0 sec  22.5 MBytes  94.2 Mbits/sec
[  3]  8.0-10.0 sec  22.4 MBytes  94.0 Mbits/sec
[  3]  0.0-10.0 sec    112 MBytes  94.2 Mbits/sec

You can see that the bandwidth has fallen back down to 94Mbits but the line still worked correctly without any traffic loss.

That’s it!  Pretty simple to setup and test the bond.   If you are creating a bond purely for the bandwidth increase keep in mind that system bottlenecks can still hinder performance – your hard drive write speed being the most likely.

With such a simple setup for this networking task it shows another benefit Linux servers can provide in comparison to Windows servers which (to my knowledge) do not natively support link aggregation.

The question I asked myself after this setup was: How does the 802.3ad configuration (mode 4) differ from mode 0 which doesn’t require switches with 802.ad support?  After some further research I found that while mode 0 uses sequential transmission, it can often receive packets out of order which creates the need for segment retransmission (as mentioned here).  It seems that mode 4 is able to receive all packets in order which produces an overall increase in efficiency.  I would be curious to see some performance benchmarks between the two and plan to do so once I have a managed switch – so stay tuned!

Cisco PIX 501 Quick Setup

I inherited a Cisco Pix 501 firewall recently and have to say I’m not near as educated on Cisco equipment yet as I feel I should be.  After a good amount of searching along the way I started getting the hang of things.  I had worked in Cisco’s Pix Device Manager (PDM) and found it to be more of a pain trying to navigate than to setup through command line.  So, for this tutorial I will focus only on the CLI for setup of the device.

pix501

Here is how I was able to get things setup.  Note that this is just a basic setup using the CLI with the following:

WAN: DHCP

LAN: Enable NAT, and enable DHCP

After configuration the firewall will be accessible at 192.168.3.1 (and netmask 255.255.255.0) and DHCP leases available will be 192.168.3.50 – 192.168.3.80.  You can change these accordingly while going through the commands.

First of all, you need to connect to the device using your Cisco console cable which is an RJ45 to DB9.  Connect the RJ45 end to the 501, and the DB9 end to a machine with the connector.  In my case this was a Linux machine running Ubuntu.  If you are on a Windows machine you can simply use HyperTerminal to connect. I issued the following commands to get connected to the 501:

Sudo apt-get install cu
cu -l  /dev/ttyS0 -s 9600

ttyS0 was what worked for me, but yours may need to be changed to ttyS1, etc. depending on your setup.

Once things are connected I issued the following commands:

First press no to the guided install (if you plan to follow the tutorial below).

enable

You will be prompted here for a password.  The Enter key is the default password.

config t

This will allow access to the configuration menu.  Press “?” to find all commands available.

username  USER password ***** privilege 15

enable  password ******

passwd  ******

Replace USER with the username you wish to create.  This allows you to create an administrator account for the system.

interface  ethernet0 auto

interface  ethernet1 100full

ip address  outside dhcp

Make sure your WAN connection is live when issuing the command above.  It will try to assign a DHCP address when it’s issued.

ip address  inside 192.168.3.1 255.255.255.0

show ip  address

The above command just shows the current setup.  I used it to double check I entered everything properly.

ip address  outside dhcp setroute

nat  (inside) 1 192.168.3.1 255.255.255.0

global  (outside) 1 interface

telnet  192.168.3.50

This was an optional command.  This allowed telnet access to the client at 192.168.3.50.  This was added so I didn’t need the console cable connected after the initial setup, and could merely telnet in from the client as needed.

no banner  exec

no banner  login

no banner  motd

The banner commands are also optional.  I wanted to cut out any extra information at logins.  You can leave these, or change them as you desire.

hostname  YOURHOST

Replace YOURHOST with the hostname you wish to give the 501.

domain  local

dhcpd  address 192.168.3.50-192.168.3.80 inside

dhcpd dns  4.2.2.1 4.2.2.2

These were test DNS servers I used during setup.  I believe they are Level3’s, and they are rather stable.  You can change to your local ISP’s DNS servers or others as desired.

dhcpd  lease 3600

dhcpd  ping_timeout 750

dhcpd  enable inside

The above command assigns the 501 as the DHCP server for the inside interface (LAN).  If you wish to use a different DHCP server or don’t care to enable DHCP, simply disregard this command.

access-list  ping_acl permit icmp any any

access-group  ping_acl in interface outside

These two commands are added to allow ping requests.  Ping is disabled by default on the 501 and annoyed me when trying to run diagnostics.  These are optional.

wr mem

This finalizes your setup by writing all changes to memory.
These are the commands I found to work for me – and don’t have this in production.  I don’t claim for this method of setup to be secure for your environment and highly recommend you study up on the device more before placing it in a production environment.  If anyone has some modifications or additions to this guide please feel free to contact me.  Hopefully this tutorial can serve as a first step in becoming familiar with setup for the Pix 501, thanks for reading.

Source Image: cisco.com

Steam Error: “Fatal Error: Failed to load Platform Modules” Fix

Recently Started Steam on my gaming machine and was greeted by a “Fatal Error: Failed to load Platform Modules”.  I first checked out Steam’s official issue page regarding the issue: http://supportwiki.steampowered.com/wiki/Steam_Error:_Fatal_Error:_Failed_to_load_platform_modules but didn’t seem like much help because the registry entry they requested changing was already correct.  After a little searching around I found that all that was needed was to remove “Steam.dll” in C:\Program Files\Steam”.  Removal of this file forced Steam to update on next startup.  This resolved any issues I was having.  Hopefully this is helpful for others having the issue.

HP Laserjet P1006 CUPS Fix

Frustrating issue today with a fairly common printer I purchased for school use. An HP Laserjet P1006. CUPS seemed like the logical solution for network printing. Set the printer up in the guided setup (System > Administration > Printing) in Ubuntu 8.04. It detected it immediately and then found a driver for it. All seemed well but when I hit the “Print test page” option nothing happened. The print job stated that it was completed around a minute later. No errors were found in CUPS logs. After some searching I found a tutorial to manually install the correct driver (http://foo2xqx.rkkda.com/). The problem with this is that you have to remove the printer entry you created previously before continuing with this step-by-step tutorial. I tried just deleting the printer I had added, but it didn’t work. I started fresh and removed CUPS, then re-installed:

sudo apt-get remove cupsys cupsys-client

sudo apt-get install cupsys cupsys-client

I also removed the printer configuration:

sudo rm /etc/cups/printers.conf

sudo rm /etc/cups/printer.conf.O

This may have been overkill and I had no previous printers configured, so you may not need to (or want to) remove those files.

After those removal steps I continued with the tutorial once again foo2xqx.rkkda.com and all worked correctly. I chose the option NOT suggested by Ubuntu when drivers were being chosen. Test print was successful. Quite frustrating that such a common printer is having issues with CUPS. Hopefully this can save someone else the trouble I went through figuring this out.

EDIT:

Thought I would add the step-by-step directions when completing this through terminal (with gnome not installed).

Since the localhost has no GUI, the easiest way to add the printer is through the web GUI remotely from another machine.  To successfully do this you need to allow permissions to the remote machine (by default CUPS will only listen for connection from the localhost.)

sudo nano /etc/cups/cupsd.conf

Find the line starting with “Listen” and change it to “Listen 0.0.0.0:631″ .

You also need to allow access to the web configuration.  Because this was for a temporary setup I just added “Allow @LOCAL” within all of the restriction fields.  Note that this is just a quick fix, and priveleges were removed soon after.  Setting to allow local for everything permanently would be a *very* bad idea.

After changing permissions accordingly, restart cupsd

sudo /etc/init.d/cups restart

The following are the instructions per foo2xqx.rkkda.com for the P1006:

wget -O foo2zjs.tar.gz http://foo2zjs.rkkda.com/foo2zjs.tar.gz

tar zxf foo2zjs.tar.gz

cd foo2zjs

./getweb P1006

sudo make install

sudo make install-hotplug

Now Unplug and re-plug the USB printer.

sudo make cups

If all went well you can now login to the cups GUI using the url (substituting cupshostip with the IP of your CUPS host):

http://cupshostip:631

If you get permission denied errors you have not edited the permissions properly in the cupsd.conf file.  If you are not able to connect at all double that the “Listen” line was edited properly.

Once you are in the CUPS web GUI adding the printer is fairly straight forward.  Just click “Administration” tab at the top, then click on “Find New Printers”.  This should detect your P1006.  The correct driver should be selected by default here: “HP LaserJet P1006 Foomatic/foo2xqx (recommended)”.  Now you can add the printer and all should work correctly.  Don’t forget to remove the permissions added in cupsd.conf to a more secure permanent setup.