Speedtest.net Mini on your own box

sometimes I need a quick and dirty speed test of an internet connection. Speedtest.net Mini allows just that, but I did not want random surfers to eat my bandwith.

On RHEL5/CentOS5

  1. download the zip file
  2. mkdir /var/www/speedtest-mini
  3. unpack in there
  4. chown -R apache.apache /var/www/speedtest-mini
  5. create /etc/httpd/conf.d/speedtest-mini.conf with this content
    #
    # This configuration file restricts access to speedtest-mini
    # http://httpd.apache.org/docs/current/howto/htaccess.html
    # 
    
    Alias /speedtest-mini /var/www/speedtest-mini
    
    <directory "/var/www/speedtest-mini">
        Options Indexes
        AllowOverride AuthConfig
        AuthType Basic
        AuthName "Password Required"
        AuthUserFile /var/www/speedtest-mini.passwords
        Require valid-user
    </directory>
    
  6. htpasswd -c /var/www/speedtest-mini.passwords speedtest
  7. restart apache
  8. Access as http://yourserver.example.com/speedtest-mini

visiting Helsinki

Every time a friend comes to visit, I tend to give out the same travel information. Being lazy, turning that into a posting seems sensible.

Airports

There are 3 good airports to take a plane to. HEL, TMP and TLL.

Helsinki Airport

This page shows you all possible ways to get from the airport to the centre of town. My preferred in the Finnair City bus, you can find it’s schedule in plain text here. A taxi ride from the airport to my home costs me between 35€ and 40€, while the bus costs under 10€. Both take pretty much the same time for the journey.

Tampere-Pirkkala Airport

If you fly to Tampere, you will need to take public transport from the airport to Tampere itself, and from there on a train to Helsinki. That train journey is 1:26 or 1:46 hours, depending on which connection you take. Schedules for Finnish trains are found here.

Lennart Meri Tallinn Airport

If you fly to Tallinn, then you’ll have to go from Tallinn to Helsinki by boat. You can find schedules here.

For the adventurous or impatient, you can also take a helicopter.

Helsinki itself

Check the official city pages to get an overview of what’s happening here. The site also includes a 1 week weather forecast.

From time to time people ask me what my motorbike looks like.
Here’s some pictures I took shortly after I bough it.

'Gallery' Post | By pcfe on 2011-09-15

DynDNS updates with TSIG and NetworkManager dispatcher

for paid accounts (DynDNS Pro and Dyn Standard DNS), one can do the updates with TSIG.

This allows us to not use ddclient, thus not having our DynDNS.com password in a config file on disk. Obviously, if the key is leaked, an attacker can still wreak havoc with your DynDNS zone configurations, but at least they will not be able to log onto the web interface of DynDNS under your name.

Create /etc/NetworkManager/dispatcher.d/20-nsupdate-tsig with this content

#!/bin/bash
#
# NetworkManager dispatcher script to update dyndns via TSIG using nsupdate
#
# adaptation of http://messinet.com/trac/browser/networkmanager-nsupdate-gss-tsig/20-nsupdate-gss-tsig
# IPv6 and reverse support has been ripped out as I do not need them for DynDNS
# read https://www.dyndns.com/support/kb/ddns_updates_and_tsig.html
# pcfe, 2011-09-13
#

#
# Function definitions
#

# Invoke nsupdate
# (vars defined below)
updateRRs() {
  (echo "server update.dyndns.com"
   echo "zone ${ZONE}"
   echo "key ${KEY_NAME} ${KEY_HMAC}"
   echo "update add ${HOST}.${ZONE} ${TTL} A ${ADDR}"
   echo "send"
  ) | nsupdate -t 60 || exit 1
}

#
# Start working...
#

# Set the host name and ttl
ADDR=`/sbin/ifconfig $1 | grep "inet addr:" | awk '{print $2}' | awk -F ":" '{print $2}'`
# while it's elegant to have the TTL based on lease time, we want short TTL
# so that one can hop between e.g. LAN and WLAN and have a caching DNS
# get the new entry quickly
#TTL=${DHCP4_DHCP_LEASE_TIME:-86400}
TTL=60
# the DynDNS hostname and zone you want to update, e.g. myserver.mydomain.net
HOST="myserver"
ZONE="mydomain.net"
# get the next two values from https://www.dyndns.com/account/settings/tsig.html
KEY_NAME="MyKeyName"
KEY_HMAC="MyKeyHMAC"

# Proceed based on NetworkManager STATUS, passed as "$2"
[[ "$2" =~ ^(up|dhcp[46]-change)$ ]] && {
  # Wait a short while for IPv6 autoconfiguration to complete
  #sleep 10
  updateRRs
}
exit 0

nail down the file permissions:

cd /etc/NetworkManager/dispatcher.d/
chmod 700 20-nsupdate-tsig
chown root.root 20-nsupdate-tsig
restorecon -v /etc/NetworkManager/dispatcher.d/20-nsupdate-tsig

I’ve only used this on Fedora 15, but you should get this working on all distributions which use NetworkManager.

If the above makes no sense to you, then you probably want to continue updating your DynDNS entries with ddclient.

nsupdate can be found in the bind-utils RPM. yum install bind-utils.

When having trouble with bind, I find that the book DNS and BIND (5th Edition), ISBN 9780596100575, published by O'Reilly Media, Inc. always comes in handy.

Helsinki, especially the first Friday of summer months, has a rather high percentage of cool old cars. Here’s a few pictures I took.

'Gallery' Post | By pcfe on 2011-07-16

fixing badly aligned storage

In the olden days, one would have to manually calculate[1] to get a file system (FS), in a logical volume (LV) that was part of a volume group (VG) living on a software RAID, properly aligned. I would get this calculation wrong in about 10% of the cases.

These days, modern Linux distributions like Fedora 14 and RHEL 6 parse hints from the storage.

But, I had a VG that I had been using since Fedora 9 and it was one of those 10% I calculated wrong. The following steps got me nicely aligned FS (you want 0 in /sys/block/dm-*/alignment_offset at the end of the procedure):

  • plugged in a temporary HD to contain the LVs while re-doing the RAID
  • pvadd the temporary HD
  • if you have swap on an LV, do swapoff -a before attempting to pvmove
  • pvmove from the old PV (where alignment_offset is not 0)
  • pvremove old RAID device
  • tear down the badly aligned software RAID
  • remove RAID component partitions
  • set up in F15/RHEL6 (as per docs linked above)
  • pvadd the newly recreated RAID
  • pvmove away from the temp HD
  • pvremove the temp HD
  • check that /etc/mdadm.conf does not contain references to the old RAID

Do keep in mind that, depending on where one messed up the manual calculations, the above might not help. YMMW

[1] links I used previously to calculate the offset

Hello world!

Just installed WordPress.

It will take a while before the site is properly populated.