Setting Up Raspberry Pi with Wifi and a Static IP on a Hidden SSID

There are a lot of posts out there on this topic but unfortunately they all contain incorrect information and don’t work. After several hours and much head banging I finally got it. So I’m going to settle this once and for all. Here is my setup. I have a Raspberry Pi model B running Raspbian, a BUFFALO AirStation HighPower N150 Wireless USB Adapter – WLI-UC-GNHP, and a hidden SSID. lsusb reports this as
Bus 001 Device 004: ID 0411:0158 BUFFALO INC. (formerly MelCo., Inc.) WLI-UC-GNHP Wireless LAN Adapter
Before I continue, yes I know the usual lecture about using a hidden SSID so you can save your breath. I’m using one anyway, deal with it.
First, set up the wireless with DHCP to make sure it works with your set up. Then you can change it to static.
Now, on the Pi, open /etc/network/interfaces 
You should see something like
auto lo
iface lo inet loopback
iface eth0 inet dhcp
iface default inet dhcp
We’re going to make it look like this
auto lo
iface lo inet loopback
iface eth0 inet dhcp
auto wlan0
allow-hotplug wlan0
iface wlan0 inet dhcp
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp
I’ve added or modified the parts in bold. I’ve seen some sources say to add a pre-up command here to run wpa_supplicant. This is incorrect. wpa_supplicant will get run automatically, we don’t need to do it. Besides, the command that I’ve seen mentioned doesn’t always work with every adaptor. Let the system handle it, it will figure out the correct way to run wpa_supplicant. Adding your own command will also just cause a bunch of ugly errors at bootup.
Now open /etc/wpa_supplicant/wpa_supplicant.conf
You should see a couple lines already there
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

Add the parts in bold to make it look like this

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
# ap_scan can be 0, 1, or 2. Some sources say to use 2 but it did not work for me. 1 did.
ap_scan=1
eapol_version=1
network={
        ssid="YOURSSID"
        # This is needed for hidden SSIDs
        scan_ssid=1
        mode=0
        psk=reallylonghexnumber
        # RSN for WPA2 or WPA for WPA1
        proto=RSN
        # WPA-PSK or WPA-EAP
        key_mgmt=WPA-PSK
        # CCMP for AES or TKIP for TKIP.
        pairwise=CCMP
        # OPEN for WPA1/2 or SHARED or LEAP
        auth_alg=OPEN
}

Make sure to tab indent the network section

Use a hex version of your passphrase as it will eliminate any messups caused by special characters. To get this use the wpa_passphrase command

wpa_passphrase <SSID> [passphrase]

If you have special characters in your passphrase you can enclose the passphrase with quotes. It will show you what the passphrase was that it used so you can double check it used the correct passphrase.

Note: If you use the actual passphrase it must be inside quotes. The hex number should not be inside quotes

These settings will depend on what you have your network configured with. Adjust them accordinly.

Now cross your fingers and reboot to make sure everything comes up properly

sudo reboot

If everything came up properly and you can connect to your Raspberry Pi over SSH or you can ping google.com congratulations. Continue reading if you want a static IP

Static IP Address

Open /etc/network/interfaces again and we’re going to make some changes

Change

iface wlan0 inet dhcp

to

iface wlan0 inet static

Now add the following lines. These values will be dependent on your network configuration again. Adjust them accordinly

address 192.168.1.11
netmask 255.255.255.0
broadcast 192.168.1.255
gateway 192.168.1.1

When you’re finished it should look like this

auto lo

iface lo inet loopback
iface eth0 inet dhcp

auto wlan0
allow-hotplug wlan0
iface wlan0 inet static
address 192.168.1.11
netmask 255.255.255.0
broadcast 192.168.1.255
gateway 192.168.1.1
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp

Cross your fingers and reboot again to make sure it all comes up and is working correctly. If you’re able to ping the IP you just configured congratulations.

Enabling HTML5 MP3 Playback in Firefox 30 and Above

The other day I was trying to play a track on Soundcloud and it wasn’t playing. Soundcloud switched to an HTML5 player instead of Flash quite a while ago. This was strange because it had previously worked. I tried Safe mode but it still didn’t work. I tried Chrome and it worked in there so I was somewhat perplexed.  I eventually found that starting with Firefox 30, Firefox started using Gstreamer 1.0 instead of the old 0.10 version. By default not all of the plugins to Gstreamer are installed in (K)Ubuntu. Pretty much all of the open source sound codecs will work (ogg, flac, vorbis, etc) but mp3 will not. The fix to this is simple.

sudo apt-get install gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly

Enjoy your HTML5 mp3 playback!

Why I Switched to KDE

I have always been a Gnome person. I’ve tried KDE every once in a while but I never really liked it. It seemed it was always either features that were missing that Gnome had or things didn’t work right where they worked fine in Gnome.  I could never get used to it and I would always find myself back in Gnome.

Recently though, the timing was just right. I used to be a big fan of Unity, but I was very put off by the version that is in Ubuntu 11.10.  I liked the version in 11.04 much better. Not to mention it was much stabler. The version in 11.10 was very unstable for me and I did not like some of the new functionality. I quickly became very unhappy with Unity.  I realized that I wasn’t as big of a fan of Unity as I thought. I didn’t want to use Unity anymore I got so frustrated with it. So I started looking at my options.

 

I decided I would try KDE yet again. Not only did KDE look absolutely beautiful, but all of the features that were missing for me had been implemented and all of the deal breaking bugs had been fixed after many years. So I tried to give KDE a genuine shot. It was a bit awkward getting used to the way KDE does things. But I fell in love with it after just a few days and haven’t looked back. KDE seems very refreshing and freeing compared to Gnome. I can customize every little bit to my likings. Now I look back and Gnome seems very restrictive to me.

 

tl;dr: Got tired of Unity and tried KDE again. Fell in love with it and never looked back.

2010 in review

The stats helper monkeys at WordPress.com mulled over how this blog did in 2010, and here’s a high level summary of its overall blog health:

Healthy blog!

The Blog-Health-o-Meter™ reads This blog is on fire!.

Crunchy numbers

Featured image

About 3 million people visit the Taj Mahal every year. This blog was viewed about 33,000 times in 2010. If it were the Taj Mahal, it would take about 4 days for that many people to see it.

In 2010, there were 3 new posts, growing the total archive of this blog to 51 posts. There were 3 pictures uploaded, taking up a total of 128kb.

The busiest day of the year was January 4th with 156 views. The most popular post that day was Getting Intel ICH8 Family (rev 03) Sound Card to Work in Gutsy.

Where did they come from?

The top referring sites in 2010 were ubuntuforums.org, forum.ubuntu-fr.org, linux.org.ru, linuxquestions.org, and forum.ubuntu.pl.

Some visitors came searching, mostly for epic fail, sed replace word, ubuntu scroll lock, gstreamer midi, and qgtkstyle ubuntu.

Attractions in 2010

These are the posts and pages that got the most views in 2010.

1

Getting Intel ICH8 Family (rev 03) Sound Card to Work in Gutsy October 2007
89 comments

2

Making Intel Wireless 3945ABG Work Better on Ubuntu Hardy April 2008
47 comments

3

Using sed to replace words in a file February 2008
7 comments

4

How To: Ubuntu MIDI Playback with Audacious January 2008
16 comments

5

Getting Scroll Lock to Work in Ubuntu April 2008
14 comments

On Unity

With the recent announcement of Ubuntu 11.04 shipping Unity instead of Gnome Shell by default, there has been a lot of backlash.  I’m talking about all the knee-jerk reactions such as “I DON’T LIKE THE DIRECTION UBUNTU IS HEADED TIME TO SWITCH TO GENTOO!!!!!!!!!!!!!11”.  It’s funny how people can react like this over an Ubuntu release that hasn’t even been released yet.  Unity has been made the default interface on the netbook edition, but what needs to be understood is that it is kind of a “1.0 release” sort of thing.   In the same way that the first release of KDE 4 was rough around the edges, Unity is rough around the edges. It is definitely not perfect.  Even I have some complaints about it, but for the love of sanity, try it for more than ten seconds and make your decision based on actual experience and not nonsense.  Also realize that the Unity that will ship with 11.04 will be much different from the current version.  The developers are going to get a lot of feedback during this release cycle and will improve upon it.

Transitions can sometimes be a bit uncomfortable.  We’ve been though this many times before.  As I mentioned before, when KDE 4 was initially released there were many, many complaints. Now all I hear is how nice KDE 4 is.  When PulseAudio was released it caused a lot of problems for people.  Over time though it has greatly improved and I would even dare to say that it now works for most people most of the time. When Ubuntu first released Notify-OSD, there was a lot of outcry about that but died down after a while.  Maybe because people become used to it or *gasp* prefer it to the old notification-daemon.  Unity will follow in a similar fashion.  Transitions can be bumpy but everything turns out OK in the end.

Some other things to consider:

  • Gnome Shell will still be in the repositories and easily installable.
  • Gnome 2.x will still be in the repositories.
  • Unity is not replacing Gnome 3

Give Unity a chance before writing it off and don’t spread FUD.

Irony

With the introduction of the new theme for Ubuntu 10.04 there has been much controversy over the placement of the window management buttons. A lot of people (or perhaps a small but very loud group of people) have complained about how the positioning on the left is bad. The thing is another major OS places its window management buttons on the left; OS X. I’m positive that Apple put a lot of usability research into the placement of those buttons. There’s no way the developers just arbitrarily placed the buttons on the left. But that’s besides the point of this post. What I find kind of ironic amongst all of the complaining is the most downloaded theme on gnome-look.org is this theme. And guess where the buttons are placed. That’s right, on the left. If buttons on the left are so bad, why do so many people want them? Just sayin’.

File Roller is Terribly Inefficient

The Gnome archive manager, File Roller, is terribly inefficient in the way it handles archive extraction and creation. I just happened to have Htop running while I was extracting a large gziped tar archive which was on my external hard drive with File Roller when I saw what File Roller was actually doing. First off, File Roller is pretty simple in the way it works. It’s just a GUI wrapper for the command line tools like tar, gzip, etc. So here is what File Roller does when you extract something. It copies the whole archive to a temporary directory in ~/.cache/.fr-xxxx. Then it extracts it in the temporary directory and then copies the extracted files to the location you’re extracting them to.  ARRRRRGGGHH! 👿 What is this I don’t even

Now if that archive happens to be sitting on an external drive and you’re extracting it to the same directory or to another directory on the same external drive you can see just how terribly inefficient this is. It has to copy the archive to your home directory then extract it, then copy it back to the external drive! This is such a waste of time, it makes it take twice as long since it has to make unnecessary copies to temporary locations. Like I said before, File Roller is simply a GUI wrapper for command line tools which is what makes me even more frustrated with this. Tar supports extracting to alternate locations with the -C option. So why the hell is File Roller making unnecessary, time-wasting copies to temporary locations!? I can accomplish the same thing in less time and more efficiently than File Roller with something like this

tar -xzvf file.tar.gz -C /path/to/destination

Another reason this is so bad is that if you happen to be running low on disk space in your home directory and you try to extract an archive that is on an external drive and the archive is larger than your free space you won’t be able to because it will complain about the lack of disk space even though you may have more than enough free space on the external drive.

Finally, it does something just as pointless when creating archives too. I had a 2.3GB file on my desktop that I wanted to compress with lzma. Guess what File Roller did. Yep, copied the whole 2.3GB file to a temporary directory, compressed it, then copied back to my desktop. 👿

I see no logical reason File Roller needs to be making these unnecessary copies to temporary locations. If anyone has a good reason why it does this please enlighten me.

Related bug https://bugs.launchpad.net/ubuntu/+source/file-roller/+bug/146206

/rant

IPtables Tarpit Support in Karmic

Edit: If you’re using Ubuntu 10.04 or higher this is no longer needed. The xtables-addons in the repositories compiles just fine.

IPtables has a nifty feature called Tarpit. In terms of IPtables a tarpit

“captures and holds incoming TCP connections using no local per-connection resources. Connections are accepted, but immediately switched to the persist state (0 byte window), in which the remote side stops sending data and asks to continue every 60-240 seconds. Attempts to close the connection are ignored, forcing the remote side to time out the connection in 12-24 minutes.” source

This basically means that it will be impossible for the person initiating the connection to close it until it times out, wasting their resources. 😈 Great for those pesky spammers that won’t leave your server alone. However, this feature is not considered stable so it is not included in the standard version of IPtables and therefore, Ubuntu does not have this functionality. However, Karmic offers a simple way to install it.

Karmic has a package in the repos called “netfilter-extensions-source” which contains the source to the Tarpit module as well as some other additions to IPtables, however according to upstream this package is deprecated. It’s also broken. So the package we need to use is called “xtables-addons-source”. However that’s also broken in Karmic. Fun fun. 🙄 So we’ll need to steal the version from Lucid.

wget http://archive.ubuntu.com/ubuntu/pool/universe/x/xtables-addons/xtables-addons-source_1.21-1_all.deb
wget http://archive.ubuntu.com/ubuntu/pool/universe/x/xtables-addons/xtables-addons-common_1.21-1_i386.deb
# For 64bit:
wget http://archive.ubuntu.com/ubuntu/pool/universe/x/xtables-addons/xtables-addons-common_1.21-1_amd64.deb

Now install them. If you’re doing this on a server I recommend using the command line  version of gdebi since it will help with dependencies. We’ll also need Quilt so that it can apply some patches when it gets compiled.

sudo apt-get install gdebi-core quilt
sudo gdebi xtables-addons-source_1.21-1_all.deb
sudo gdebi xtables-addons-common_1.21-1_i386.deb
# 64bit:
sudo gdebi xtables-addons-common_1.21-1_amd64.deb

Now just run the following command to compile and install it

sudo module-assistant --verbose --text-mode auto-install xtables-addons

Say yes to any additional packages it wants to install and then it will automatically compile it, package it into a deb and install it.

Now you can create some rules using the Tarpit module.

sudo iptables -A INPUT -p tcp -m tcp -dport 80 -j TARPIT

This will create a tarpit on port 80. Heads up if you’re actually running something on that port as it will become inaccessible.

Or perhaps you want to target a specific IP

sudo iptables -A INPUT -s x.x.x.x -p tcp -j TARPIT

Where x.x.x.x is the IP address.

These are only a couple basic examples. There’s a lot more things you can do with IPtables and Tarpitting which are beyond the scope of this post but a quick Googling will reveal a lot of good info on IPtables. For a basic intro to IPtables I recommend reading this.

Update: If you get a kernel update that bumps the ABI (e.g. 2.6.31-15-generic to 2.6.31-16-generic) then you will have to rebuild the xtables package after rebooting into the new kernel. To do this just rerun the module-assistant command

sudo module-assistant --verbose --text-mode auto-install xtables-addons

Actually I’ve found out this is better since you can recompile it before rebooting thus eliminating any period of time without a firewall.

sudo module-assistant --verbose --text-mode -l <kernel-version> auto-install xtables-addons

Replace <kernel-version> with the new kernel such as “2.6.31-17-generic”

So Much Potential

I was doing some thinking and I realized there’s a few pieces of technology in Linux that have so much potential but are extremely under-utilized.

PolicyKit

PolicyKit is an awesome piece of software. It allows for a finer grained permission system. Instead of launching an entire application as root, you can elevate your privileges in a seamless manner. However, PolicyKit is so under used. For example, when Gnome deprecated gnome-vfs and moved to gio/gvfs, Nautilus supposedly got a framework in place that would allow PolicyKit integration. So if you needed root permissions to makes changes to the file system you would be able to basically click a button and elevate your privileges through PolicyKit. Synaptic could also benefit from some PolicyKit integration. Why isn’t PolicyKit used more?

Tracker

Tracker is a great metadata indexer that crawls your files system and indexes metadata from files. Instead of only searching by file name, you can use Tracker to search ID3 tags or search for text in a OpenOffice or Word document. The problem is, no one has integrated this great search functionality into applications. Once again, there’s an opportunity for some integration with Nautilus. If Nautilus could use Tracker as a backend for searching and have the ability to add tags to files, it would really add some great functionality.

There’s so much potential here. It’s a shame it’s not being used.

Iomega Prestige HDD and Karmic

Just a little heads up. If you have an Iomega Prestige USB hard drive and you use suspend a lot and you are planning to upgrade to Ubuntu 9.10 or already have, there’s an annoying bug that makes the drive go in to an unresponsive state until power cycled. The symptoms include

  • Takes a long time to actually suspend, waiting at a blank screen
  • Drive doesn’t automatically power off like it should when it detects the computer has been suspended
  • Drive is no longer visible to the system after resuming, even after unplugging it and plugging it back in
  • Must be power cycled before it functions properly again

 

Here’s the bug report

A place for my tips and thoughts