The beautiful combination of MRTG and the ZyXEL P-2812HNU-1 ADSL/VDSL router

Quick one for those of you battling with MRTG and the ZyXEL P-2812 router. Apparently running the cfgmaker doesn’t work with this device, as its SNMP capabilities are severely limited. With a little manual probing and a lot of time understanding the MRTG documentation, you can actually get something from it.

If you try to run cfgmaker you’ll get complaints about no replies, much like there isn’t anything at all in the other end. Work with it a bit, and you’ll get whining about the system name OID, the uptime OID and the Ethernet index OID. As I understand it, you pretty much have to hard code all this yourself. Enough talk though, here’s the MRTG configuration beef (other non-related things removed):

LoadMIBs: /usr/share/snmp/mibs/UCD-SNMP-MIB.txt /usr/share/snmp/mibs/SNMPv2-SMI.txt

Target[router_net1]: ifInOctets.1.0&ifOutOctets.1.0:COMMUNITYNAME@ROUTERIP:::::2
RouterName[router_net1]: enterprises.890.
RouterUptime[router_net1]: enterprises.890.
MaxBytes[router_net1]: 1000000000
Title[router_net1]: net1 -- router
PageTop[router_net1]: net1 -- router
Leave the first comment

Adventures with the Linksys WRT54GL – Part 2

So yesterday after the kid was tugged in, I thought it would be a great idea to update my WRT54GL router from OpenWRT Backfire (10.03.1) to OpenWRT Attitude Adjustment (12.09-beta). I saw one (*one*) post saying that there were problems with WRT54GL, but I thought I’d give it a go anyway. That turned out to be a less than clever decision.

So, flashing the device wasn’t actually an issue. I decided to be fearless and did it from the shell like this:

root@gateway:/sdcard# wget
root@gateway:/sdcard# mtd -r write openwrt-brcm47xx-squashfs.trx linux

One reboot later, and the router was up – all configuration went out the window, but that was good with me. One thing immediately struck me – this new firmware was *slow*. Often the web interface would time out and I would be unable to even see certain sections. A little while later, it turned out that is was also highly unstable and rebooted often – maybe in relation to the web interface timing out. I decided to downgrade to Backfire again, but was unable to finish uploading a new firmware through the web interface. Again, I was fearless and decided to pipe the output from a wget directly to the mtd firmware tool. The reason for piping was lack of temporary space on the device (around 3MB needed).

I’d be lying if I was surprised, but the router crashed around 62% through the download and firmware write. Since the router was now unresponsive, I gave it a reset and saw the power LED blinking continuously. I even did the 30/30/30 reset and again the result was a blinking power LED. According to the intarwebs, that means this particular device is stuck in the boot process. That makes perfect sense, if I only managed to write 62% of the new firmware. Luckily, this only means the router is half dead. To brick it completely, you apparently need to write some really outrageous data to the nvram.

Half dead means that you can often upload a new firmware to the device using the TFTP protocol. If you want gory details about that, check out this OpenWRT wiki page. I decided to go for the old OpenWRT Backfire, and loaded that onto the device through TFTP. It worked as expected, and the device was back up and running.

So, the decision was to stick with the old firmware for now. I moved on to the SD/MMC-card installation, but was surprised to see that the kmod-broadcom-sdhc package mentioned in part 1 was no longer available. As it turns out, I was now running the brcm47xx version of Backfire, and the original firmware before the Attitude Adjustment adventure was the brcm-2.4 version. The difference seems to be kernel versions, with the old one running 2.4 and the new one 2.6. Attitude Adjustment is using kernel 3.3. Anyway, the kmod-broadcom-sdhc module is only available for kernel 2.4, which means I had to run Backfire 10.03.1 brcm-2.4. A firmware upgrade later, and I was running the right version of Backfire and I was able to install bkmod-broadcom-sdhc again and could access my SD-card. Worth mentioning is that the driver actually works with a relatively new 8GB card. Since the device is seriously strapped for resources, mostly in the RAM department, I have no idea what to use 8GB for and decided to stick with the 512MB card from 2006.

Moving some or all of the root filesystem to the SD-card seems like a somewhat pointless exercise, since I’m seriously limited in what the device can run anyway. At this point I’m hoping to get something like CoovaChilli running on it, and that’s it. Alternatively I’m going shopping for a dirt cheap alternative with 128M RAM and an USB port. I’ve seen routers like this with 1Gb ethernet ports at around $80/€60.

In part 3 I’ll be diving into the magnificent wonders of setting up a hotspot on OpenWRT.

Leave the first comment

Adventures with the Linksys WRT54GL – Part 1

For a long time, I’ve wanted to get rid of the 200 Watt Linux PC running around the clock in my bedroom. Not completely, since it’s also acting as my media center and file server, but there is absolutely no reason for it to be turned on all the time. One problem though – it’s also my gateway/router and I another low power gadget to handle that. Preferably dirt cheap, as I’m not swimming in cash.

So, my dear mother recently received a new DSL-router from her provider, which basically contained everything from VoIP to Wifi, rendering – among other things – the Linksys WRT54GL I set up for her obsolete. This router is amazing – it has numerous different custom firmwares available, like DD-WRT, Tomato and OpenWRT. DD-WRT has been my choice for a while, but this time I wanted to go beyond the pretty web interface and get my hands dirty with a terminal connection. OpenWRT (version 10.3.x aka Backfire) seemed like the perfect choice for this.

One of the things I wanted for my LAN, was a good local nameserver setup. Addresses being handed out by DHCP should resolve to a value hostname, preferably the one requested by the client, and the hostname should of course resolve back to the IP. DD-WRT can do this with a tiny bit of tweaking, but OpenWRT does it right out of the box. I changed the TLD from lan to stlan since I’m doing VPN to other places that use lan.

I also wanted to add an SD/MMC card to the WRT54GL. I’ve wielded a soldering iron before, and this hack doesn’t really require anything except some wires and an SD/MMC adapter (unless you want to solder directly on the card itself), so I jumped right in. I can’t exactly remember where I found the instructions for the hack, but try Google. They’re all pretty much the same mod, but with varying soldering and camera skills πŸ™‚ After the mod, my router looked like this:

My first attempt failed miserably though, but was probably due to thin wires and a bad ground connection.

Drivers for the card was a bit of a mess. I tried downloading several mmc.o kernel modules and loading them with no or minimal success. Finally I came across a post talking about the kmod-broadcom-sdhc package. As it turns out, the MMC driver was obsoleted by the SDHC driver. Running it required adding the GPIO-numbers to /etc/sdcard.conf (they’re usually 7, 3, 2 and 4, depending on the way you attached the reader). Firing up the driver and mounting (the prepared partition) was done with /etc/init.d/sdhc start.

So far, it looks like the hack and driver works well with both my 512M card from 2006 and a relatively new 8G card. I’m not really using the card for anything, except for saving DHCP-leases. I need to figure out how to get the most of my SD-card, either by putting the entire root system on it, or maybe just part of it. This may require installing the newest OpenWRT (codename Attitude Adjustment), and I’ll share my experiences with this in part 2 of this series.

I share my connection with a couple of other people, so I’m also interested in setting up some kind of easily maintainable hotspot solution with a login and a password. This will probably be in part 3.

Leave the first comment

ASP.NET Development Server, Fiddler and localhost

I’m developing in Visual Studio on a virtual Windows 7. Every time I try to run a project, an instance of the ASP.NET Development Server fires up and I can access my development site locally. Unfortunately my virtualization platform (VirtualBox) doesn’t support dual head, and to be honest, I’d prefer to debug browser issues in Chrome under Linux. Read on for an interesting solution to this issue.

I know I could set up the IIS instead of using the development server, but I run numerous projects, and sometimes it’s just a bit of a hassle. I also happen to run Fiddler once in a while, and it seemed like an interesting solution to configure Fiddler to run use an external network interface, allowing me to reach it from my Linux browser. With a tweak of the proxy settings in my Linux browser, I was able to hit http://localhost:../ on my Windows environment.

So, now all my traffic goes through Fiddler. This isn’t exactly what I wanted, or at least it’s not what I’ll be wanting from now and into eternity. SwitchySharp to the rescue! It’s not just an ordinary easily accessible proxy menu, it allows you to define rules to help it decide what proxy you’ll be wanting for each request. I’m pretty sure that will come in handy again at some point πŸ™‚

Leave the first comment

Avoiding VirtualBox’ annoying message after kernel update

Adding this to the root users crontab should make sure that the VirtualBox kernel modules are up to date after every reboot:

@reboot /etc/init.d/vboxdrv setup
Leave the first comment

Living with a Snow Lion – Part 3

.. or What the Hell happened to screen zoom? I liked the screen zoom functionality, and I’m a bit disappointed that they somehow switched it off. After a bit of investigating, I came across this post, and decided to peek in System PreferencesAccessabilityZoom. Here I found out that keyboard shortcuts were enabled for zoom, but none of them seemed to do anything. Checking the box Use scroll gesture with modifier keys to zoom made screen zoom work the way I was used to from Leopard. I unchecked Smooth images to get rid of the antialiasing. I like my pixels sharp around the edges πŸ˜‰

Leave the first comment

Living with a Snow Lion – Part 2

Life goes on with the new cat on my laptop, and now I’ve stumbled across a strange issue. When SSH’ing to one of my servers, my favorite editor, vim, stopped working with this rather puzzling error:

Error detected while processing /home/hc/.vimrc:
line  106:
E474: Invalid argument: listchars=tab:Β»?~@?,trail:Β·,eol:ΒΆ
Press ENTER or type command to continue

The problematic line above is part of my new, delicious editor configuration which should make my editor look something like this:

I’m not sure why, but I tried running locale on my server, and got this somewhat puzzling output:

$ locale
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory

Obviously something was wrong with my locale, and after a little Googling I came across this page where the author suggests to comment out the SendEnv LANG LC_* line in /etc/ssh_config like this:

Host *
#   SendEnv LANG LC_*
#   ForwardAgent no

The argument for this was that the locale environment variables on Show Lion are somehow broken, or at least not compatible with their Linux counterparts. I tried, and everything worked like it was supposed to. The reason for the vim error was probably the use of UTF8 characters as a part of the listchars parameter. The erroneous locale broke UTF8, making this configuration unparsable.

Leave the first comment

Living with a Snow Lion – Part 1

If there is a new Fedora release, you can be sure I’m the one of the first to get it on my box at the office, but when it comes to the operating system of my MacBook Pro, I’m a little more conservative. Yesterday I got sufficiently annoyed with the lack of iCloud synchronisation functionality in OSX 10.6, so I finally decided to fork over the dough for Snow Lion. These are my thoughts on it so far:

Contacts: What’s up with the cheesy leather look? What happened to the Apple philosophy about the UI looking the same all through the operating system? This reminds me too much of the weird behaviour of some Windows sound driver vendors that insist on installing a weird blue mixer app with rounded corners that look completely alien to the rest of the apps. Apple, please don’t be cheesy – it doesn’t suit you.

Contacts: I’m not done yet. I upgraded to Snow Lion to get iCloud for my iPhone in hopes that my address book would now be neatly synced and duplicates would be a thing of the past. I haven’t investigated (and as an Apple user, I really shouldn’t have to) but now some of my contacts show up four times. It could be Google synchronisation, it could be Facebook, I don’t know – and frankly I’m annoyed that I have to figure it out.

Installing: So I was one of the poor suckers who got the This disk cannot be used to start up your computer message slammed in my face right after purchasing the upgrade and running it. Not what I needer at all. The solution? Make the system partition 128M smaller. Seriously? Yep, that’s the official answer on the Apple support forum. Why is left for the user to ponder.

Inverted scrolling: Actually they decided that weird inverted scrolling should be called natural direction and selected by default. I can see how this makes complete sense on a touch device like the iPad or iPhone, but on my laptop? No thanks. Turn it off under System PreferencesTrackpadScroll direction.

Leave the first comment

The strange case of the missing load event

So, a while ago I was fiddling with some JavaScript and wanted a load event on an image. From time to time, the event failed to fire on IE8 and I had no clue why. It looked a bit like this:

jQuery('<img alt="" />', {'src': 'http://...'})
    .load(function(evt) {
        // Handle the event here

This would work every time in Chrome and Firefox, but for some odd reason it failed in IE8 unless i did a forced reload or manually wiped the cache. As it turns out, IE8 can be insanely fast when it comes to loading images from its cache, so when the Javascript engine gets around to attaching an observer to the load event, the image is already there and the event will never fire. Hmm. Who would have thought an IE-related issue was actually caused by speed.

Looking at the code snippet again, I realized that it was actually highly fragile, and somewhere in the distance I would hear one of my numerous programming teachers scream something while pulling their remaining hair out. One should of course never set the src attribute on an image element until any load-events have been set up. With that in mind, this is the right way to go:

    .load(function(evt) {
        // Handle the event here
    .attr('src', 'http://...')

I’m not making that mistake again.

Leave the first comment

The strange case of the changing GDM session

For the rare times when I’m not working, I’ve got a Fedora-based media center running the very excellent XBMC. It logs in automatically with GDM, and starts a xinit-compat session (see the xorg-x11-xinit-session package). I’ve got a few other things to do when I log in, which is why I’m not going with the XBMC session.

It works perfectly, except when it doesn’t. Once in a rare while, my choice of default desktop manager session is completely ignored, and I get a Gnome session instead. With the keyboard and mouse safely locked away outside the reach of curious 2-year old hands, logging out, picking the right session type and logging in again is a bother. That, and the sporadic nature of the issue pisses me of.

So, let’s take a peek at /etc/gdm/custom.conf – the file that tells GDM who to log in automatically (empty sections removed):


With account and delay specified (twice?) in this file, it seemed only reasonable that this would also be the place to select what type of session to start. Using my Googles, I found references to DefaultSession, but this seems to be obsolete in GDM3. Other people pointed to ~/.dmrc as the de-facto configuration file for specifying the default language and session type. Alas, this also is not supported by GDM anymore. In Ubuntu-country, people were talking about gdm-set-default-session but I was unable to find any source or package for Fedora with this file.

It turns out that GDM3 is using a service called AccountsService to store and retrieve information about users’ sessions. It’s apparently fully accessible via DBUS, which means absolutely nothing to me. Luckily enough it seems that AccountsService stores its information in plain text files in /var/lib/AccountsService/users/, so writing this to /var/lib/AccountsService/users/xbmc will ensure that the xbmc user always gets an xinit-compat session:


.. and to make absolutely sure GDM doesn’t modify this file, set the i attribute (file completely locked until root removes the flag again) on the file:

chattr +i /var/lib/AccountsService/users/xbmc
Leave the first comment