Posts Tagged ‘Linode’

Linode Native IPv6

Thursday, May 5th, 2011

Linode (my VPS provider) has recently added IPv6 support.  It's exciting to see companies starting to support this technology.  I've just reconfigured my Linode and it seems to be working well.  I did have some issues with the default route getting set by the autoconfig.  I'm going to blame shorewall6 for that.  It's getting late and didn't feel like messing with it further.  Adding the address and gateway to the interfaces file worked like a charm though.  I'm just happy they've started enabling it where they can.

Yearly Blog Post

Sunday, September 5th, 2010

I suppose there are many blogs out there that don't get posted to as often as they should. I'd like to get into updating the blog a bit more often, but I'd rather have quality posts than not.

The House

I recently purchased a house. I'm pretty happy about that as I was renting for quite a while and I was able to get into something while the market was more affordable. It's a small ranch and it's in pretty good shape. There is good amount of paneling I'd like to remove, but I'm pretty happy with the condition otherwise.

As I was preparing to move, I decided to take a look at what I did and didn't need.  Moving is always a good time to clear out some of the clutter.  I did the usual stuff like clean out the closet and all the electronics I'd collected.  I made some donations to Goodwill and took some old computer parts to the electronics recycling program.  I also decided to scrap the Asterisk VOIP phone I had set up.  I was running Asterisk on my Linode to provide phone service for myself and my sister.  My sister moved back to the US a few months ago so her and my brother-in-law got new cell phones.  I'm fine with just using the cell primarily.  So it was one less thing to maintain (no, I won't be updating any of the scripts I posted on here).

After moving into the new house, I had quite a time with Comcast.  First I wasn't able to connect the service during the weekend I moved because the old owner never cancelled their account.  So I was prevented from transferring service.  That was pretty frustrating since it's easy to verify ownership of a house with the county.  Then they missed two appointments to install the service.  I'm not even sure why someone had to come onsite since the service was working before they sent someone out to disconnect it when the old owners finally cancelled.  So yea, they weren't really treating the customer that great.  To be honest, I haven't been watching that much TV lately.  My biggest use of Comcast was for the Internet.  So I decided to give Clear Internet a try.  They're a wimax Internet provider that has recently started service in this area.  I can even see the tower out one of my windows.  I'm still waiting on the device though (I just ordered it before the weekend).  I have some anxiety over how well this thing will actually work, so I'll have to post back later about it.

TV Antenna

Since I'm no longer getting Comcast, I thought I'd give over the air TV another shot.  I did apply for one of those converter boxes last year, but I got really crappy reception at my last house.  I figure at least this way I can get some of the major TV networks (which is all I got from basic cable anyhow).  So without doing enough research, I set about to build an antenna.  Someone else I know had built one from directions on the Internet and was happy with it.  So I got the parts for a couple bucks at the hardware store and went about it.  The antenna works great for UHF.  For VHF, not at all.  The ABC and PBS stations in Philly are broadcasting over VHF.  Everything else is in the UHF bands.  The one good thing is that my family room faces the direction of the Philly stations and the antenna fits well in the window, so the UHF stations came in strong.  Later on, I tried adding different lengths of wire to make a dipole, but I haven't been able to get the ABC station.  My house also has aluminum siding, so that probably doesn't help stuff like TV signals (or the wimax device that's coming).  The dipole for the ABC station needs to be 5.6 feet wide, which may be a bit too big for indoors.  I left the smaller dipole pieces on and now I can get the PBS station as well as the UHF stations.  At some point, I'd like to build another one of these to mount on the roof.  Next time I'd use materials that'll hold up to the weather a bit better.  I may just see about adding a set of rabbit ears if I get that far.  I'll see what happens, but I'm content for the moment.

I suppose some of the ambition to build an antenna came from my semi recent interest in amateur radio.  Over the summer I took part in a class the county offered and I passed the exam during the annual ARRL field day.  Currently, I only have my tech license.  I'd like to go back and get the general license, but I need to get that book and do some studying.  Depending on how interested I stay in ham radio, I may put another antenna or two on the roof (or maybe in the attic).  Hopefully I'll post some more pictures if I get crafty.

The other hobby I enjoy is rock climbing.  I was lucky to get two camping and climbing trips in to New River Gorge this year.  I passed up on a trip last minute to go to Rumney , NH.  I would have liked to go, but I really needed some more time to get settled in the new house.  Hopefully, they'll be some more climbing opportunities before winter.

Well, that just about takes care of summarizing what's been going on in my life this past year.  I'll make an attempt to do more posts when I have some decent climbing pics or maybe a new antenna.

Linode Dynamic DNS Ash Script

Monday, May 11th, 2009

After my post last night regarding a bash script to update Linode's DNS Manager, opello from #linode on OFTC provided some sed commands to parse the JSON output. Using his commands, I made another version of the script.  I've tested this on my router running the Tomato firmware (which runs BusyBox).

I found that the wget command built into the version of BusyBox does not support HTTP POST. It also does not support https urls, only http. This means your Linode API key would be transmitted in clear text, which probably isn't a good thing.

Another solution that was suggested was to simply wget a CGI script running on your webserver, which could update the Linode DNS Manager using perl or python over secure channels. That would reduce the complexity on the home router side and allow you to use the developed Linode API libraries.

Therefor, I wouldn't recommend using this unless you are able to send the requests over ssl channels. I am glad to have a slightly better understanding of sed. I'll probably modify the original bash script to use that as well.

#!/bin/ash
#
# Script to update Linode's DNS Manager for a given name.
#

# Things you need to change.
APIKEY=$(cat /home/root/linode-apikey)
LASTIP="/tmp/lastip"
DOMAIN="domain.com"
SOAEMAIL="hostmaster@domain.com"
STATUS="1"
RRTYPE="A"
RRNAME="home"
IFACE="vlan1"

# Shouldn't need to change anything below here.

WGET="wget -qO - http://api.linode.com/api/?api_key=$APIKEY"
NEWIP=$(ifconfig $IFACE | head -n2 | tail -n1 | cut -d: -f2 | cut -d' ' -f1)
test -e $LASTIP && OLDIP=$(cat $LASTIP) || OLDIP=""

if [ x"$OLDIP" = x"$NEWIP" ]; then
  logger "No IP address change detected. Keeping $NEWIP"
else
   DOMAINID=$($WGET"&action=domainList" | \
        sed -nr "s#.*\"DOMAIN\":\"$DOMAIN\",\"DOMAINID\":([0-9]+),.*#\1#p")
   RESOURCEID=$($WGET"&action=domainResourceList&DomainID=$DOMAINID" | \
        sed -nr "s#.*\"RESOURCEID\":([0-9]+),\"DOMAINID\":$DOMAINID,\"TYPE\":\"$RRTYPE\",\"NAME\":\"$RRNAME\".*#\1#p")
   $WGET"&action=domainResourceSave&ResourceID=$RESOURCEID&DomainID=$DOMAINID&Name=$RRNAME&Type=$RRTYPE&Target=$NEWIP"; echo
   $WGET"&action=domainSave&DomainID=$DOMAINID&Domain=$DOMAIN&Type=master&Status=$STATUS&SOA_Email=$SOAEMAIL"; echo
   echo $NEWIP > $LASTIP
   logger "Updated IP address to $NEWIP"
fi

Linode Dynamic DNS Bash Script

Monday, May 11th, 2009

So Mark Walling was working on an ash script for his router running OpenWRT to update Linode's DNS Manager with his IP address. I liked the idea of a simple shell script to update without needing to install libraries for Perl or Python.  I took his script and tried to adapt it to get the DOMAINID and RESOURCEID using sed or awk.  Those utilities seem great for manipulating multiline files of text, but I wasn't getting anywhere trying to parse one line of JSON from wget.  So I used perl to extract the id numbers.  I believe OpenWRT has some sort of perl with limited functionality, so maybe this will work with that or at least be easily adapted.  This could also be easily modified to use curl instead of wget. I suspect someone out there will find this useful.

#!/bin/bash
#
# Script to update Linode's DNS Manager for a given name.
#

# Things you need to change.
APIKEY=$(cat ~/.linode-apikey)
LASTIP="/tmp/lastip"
DOMAIN="domain.com"
SOAEMAIL="hostmaster@domain.com"
STATUS="1"
RRTYPE="A"
RRNAME="home"
IFACE="eth0"

# Shouldn't need to change anything below here.

WGET="wget -qO - https://api.linode.com/api/"
NEWIP=$(ifconfig $IFACE | head -n2 | tail -n1 | cut -d: -f2 | cut -d' ' -f1)
test -e $LASTIP && OLDIP=$(cat $LASTIP) || OLDIP=""

if [ x"$OLDIP" = x"$NEWIP" ]; then
  logger "No IP address change detected. Keeping $NEWIP"
else
   DOMAINID=$($WGET --post-data "api_key=$APIKEY&action=domainList" | \
        perl -e 'if ( =~ /"DOMAIN":"'"$DOMAIN"'","DOMAINID":([0-9]+),/) { print $1; }')
   RESOURCEID=$($WGET --post-data "api_key=$APIKEY&action=domainResourceList&DomainID=$DOMAINID" | \
        perl -e 'if ( =~ /"RESOURCEID":([0-9]+),"DOMAINID":'"$DOMAINID"',"TYPE":"'"$RRTYPE"'","NAME":"'"$RRNAME"'"/) { print $1; }')
   $WGET --post-data "api_key=$APIKEY&action=domainResourceSave&ResourceID=$RESOURCEID&DomainID=$DOMAINID&Name=$RRNAME&Type=$RRTYPE&Target=$NEWIP"; echo
   $WGET --post-data "api_key=$APIKEY&action=domainSave&DomainID=$DOMAINID&Domain=$DOMAIN&Type=master&Status=$STATUS&SOA_Email=$SOAEMAIL"; echo
   echo $NEWIP > $LASTIP
   logger "Updated IP address to $NEWIP"
fi

Compiling Dahdi Modules on Linode

Thursday, January 1st, 2009

Happy New Years everyone! This holiday I decided to work on setting up Asterisk, which is an open source pbx system. I had some issues where I wasn't getting any audio and it became apparent that I needed to compile the dahdi_dummy kernel module for a timing source. Since my VPS account is hosted at Linode, where they run Xen, I'm able to build my own kernel modules and my own kernel images if I wanted.

I was using the 2.6.18.8 kernel and everything built fairly easily under that, but modprobe had a segmentation fault when I loaded the dahdi_dummy module. Linode recently made the 2.6.28 kernel available, so I decided to give that a try instead.  I prefer to use the kernels that Linode provides for the stability and support.  Linode makes the kernel source available from which the kernels are built.  I did run into a few glitches though.  The first was that the dahdi modules were looking for bounds.h, which did exist.  It seems that "make clean" removes some of the generated header files.  Running "make prepare" solves that quickly (thanks caker).  I then found that the scripts/genksyms/genksyms binary was compiled for 64bit Linux.  Since I'm using a 32bit distribution, that didn't work out so well.  That part of the kernel tree needs to get cleaned and rebuilt in order to compile the dahdi modules.  After messing around awhile, I ended up rebuilding the entire kernel just to get a few small files.  I decided it's be best to write a small script to only clean the sections I need and make this easier next time around.

The script I used is below.

#!/bin/bash
#
# Script to clean genksyms in the kernel source and prepare the source to be
# used when compiling modules for things like asterisk.  This was needed to
# remove binaries in the scripts tree because the Linode kernels are built on
# a 64bit server and my Linode is using a 32bit distribution.
#
# Copyright (c) 2009 Patrick Hennessy
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation
# files (the "Software"), to deal in the Software without
# restriction, including without limitation the rights to use,
# copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following
# conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.
#

# Set this to where your kernel source is placed.  I usually have a symlink
# for both of the locations below.
#
# KSOURCE=/lib/modules/$(uname -r)/build
#
KSOURCE=/usr/src/linux

# Simple test for the Makefile.
#
if [ ! -e $KSOURCE/Makefile ]; then
        echo "Can't find $KSOURCE/Makefile.  Make sure $KSOURCE exists."
        exit
fi

# Patch the Makefile to clean the scripts tree when doing clean.
#
patch -d $KSOURCE << END
--- ../2.6.28-linode15.orig/Makefile    2008-12-29 15:36:08.000000000 -0500
+++ Makefile    2009-01-01 03:08:19.000000000 -0500
@@ -1174,7 +1174,7 @@
 #
 clean: rm-dirs  := \$(CLEAN_DIRS)
 clean: rm-files := \$(CLEAN_FILES)
-clean-dirs      := \$(addprefix _clean_,\$(srctree) \$(vmlinux-alldirs) Documentation)
+clean-dirs      := \$(addprefix _clean_,\$(srctree) \$(vmlinux-alldirs) Documentation scripts)

 PHONY += \$(clean-dirs) clean archclean
 \$(clean-dirs):
@@ -1194,7 +1194,7 @@
 #
 mrproper: rm-dirs  := \$(wildcard \$(MRPROPER_DIRS))
 mrproper: rm-files := \$(wildcard \$(MRPROPER_FILES))
-mrproper-dirs      := \$(addprefix _mrproper_,Documentation/DocBook scripts)
+mrproper-dirs      := \$(addprefix _mrproper_,Documentation/DocBook)

 PHONY += \$(mrproper-dirs) mrproper archmrproper
 \$(mrproper-dirs):
END

# Run make targets to prepare the tree.
#
make -f $KSOURCE/Makefile clean
make -f $KSOURCE/Makefile oldconfig
make -f $KSOURCE/Makefile scripts/genksyms/
make -f $KSOURCE/Makefile prepare

This should be useful for other Linode users building dahdi or other kernel modules under 32bit Linux distributions.

[2009-Jan-01 EDIT:  The reason I didn't do "make mrproper" or "make distclean" is that I needed the Module.symvers file, which is created during the kernel compile.  That file appears to be used to add symbols when building modules.  Even while using difference force options, I was getting "no symbol version for struct_module" errors.  Once that Module.symvers file was present, I was able to build and load the modules as expected.]

[2009-Jan-02 EDIT: You may be using a different version of gcc than what the Linode kernel was compiled with. In that case, you'll need to pass the "--force-vermagic" option to modprobe when loading the module.]

[2009-Jan-02 EDIT: Updated the script to run oldconfig after the clean stage.]