jostein.kjønigsen.net

Setting up a Linux UPnP router - Part 2

So in part 1 of this series I covered some of the things I needed to do to get a Linux-only routing solution with a bridged DSL-modem and no double-NAT. This hardly qualifies as a UPnP solution in itself, but it is a prerequisite for being able to run a UPnP daemon.

In this part I will cover the parts about setting up and configuring the UPnP service itself.

To recap: This is done a on Ubuntu Server 8.10 (Hardy) installation already configured to handle routing and firewalling. Unfortunately the Ubuntu developers somehow forgot to add some of the needed software to the Hardy software repository. This makes the job a little more tedious, but still simple enough to be worthwhile the effort.

Getting started

As a basis for the work, I used this guide from the Gentoo Wiki. Basically we will be using linux-igd to implement UPnP. While the guide is Gentoo-specific, I assumed the same basics should still apply.

Trying a sudo apt-get install linux-igd resulted in absolutely nothing happening. A little research showed that for some reason this package is inculded in both Guttsy and Intrepid, but not Hardy. Damnit.

I decided to simply fetch the source from sourceforge. Download and extract somewhere handy.

mkdir linuxigd
cd linuxigd/
wget http://downloads.sourceforge.net/linux-igd/linuxigd-1.0.tar.gz?modtime=1170893870&big_mirror=0
tar xzf linuxigd-1.0.tar.gz
cd linuxigd-1.0/

Reading up on the instructions there, it recommends that you compile libupnp from scratch yourself. Too be honest I couldn't bother with that. At least not in the first round.

sudo apt-get install libupnp-dev libupnp2

This fetches both the libupnp development files needed to build stuff using it, and libupnp shared library itself.

Trying to build this, I got a lots of noise. If this is the case for you as well, I suggest fetching build-essentionals and retrying.

sudo apt-get install build-essential

Following this all I had to do was a basic build and installation

make
sudo make install

You should now have upnpd installed as /usr/sbin/upnpd.

Back to the guide at hand: We are now ready to configure the service. Unlike in gentoo, the config for the service is not located in etc/linux-igd/, but can be found at /etc/upnpd.conf.

The only things in the configuration I had to change was the reported bandwidth and what iptables chain to use for FORWARDs. As mentioned in the previous post, and as recommended in the guide, I've set up a designated chain for UPnP, called UPNP, so I replaced the following section:

forward_chain_name = FORWARD

with

forward_chain_name = UPNP

Looking for the second config-file mentioned in the guide proved harded. Doing a find /etc/ -iname upnp* yielded no good results, so I decided to just check where /etc/init.d/upnpd were looking. Bad news. No upnpd init.d-file.

Looking in the linuxigd-1.0/etc-folder with the source, there is a file called upnpd.rc, but it doesn't seem LSB or Debian/Ubuntu-compliant and fails horribly.

In the end I said fuck it and just obtained the stuff I needed elsewhere. I got myself an alternate version, a lot more Ubuntu-friendly, and went with that. You can get my version here.

This script requires that you have a file called /etc/default/upnpd. Fire up your favourite editor to create this file and fill in the following parameters, obviously making sure the settings make sense on your setup.

EXTIFACE="eth1"
INTIFACE="eth0"

If you already have upnpd placed in /etc/init.d, all that remains should be to fire up the service:

sudo /etc/init.d/upnpd start

And you're done. Your Xbox 360 will now consider your Linux-router a "Microsoft Live Compliant Networking Appliance". No, really!

Thanks to

Various reasons

Misc stuff