XBox Live!, Linux, NAT, and UPNP

  • Posted on
  • by
  • in

A little bit of background first. I've been a subscriber to XBox Live! since its launch in November of 2002. For a while, I was on DSL (at my old apartment), and had a nice static IP dedicated solely to the XBox. Later, I bought a house and could no longer get DSL, so I switched to cable. No more nice static IPs, but I paid for a second dynamic IP and strung a looooong ethernet cable across my entire house and hooked up the XBox that way. In both of these cases, life was good. Of course, I couldn't just leave well enough alone. I was annoyed by the long ethernet cable, and Microsoft had just shipped the XBox Wireless Adapter, so I bought it. Now, a bit of background on my wireless setup: I use a Linux machine to do Network Address Translation (NAT) for my internal network (a wired desktop, a wireless laptop, a wireless TiVO, and now a wireless XBox). I've used a similar setup since college, oh so many years ago (I believe the first time I set this up was 1998). Anyway, back to the story. I plugged in the XBox wireless adapter, set it up, and things worked great. The XBox could connect to Live!, and I could play games. Then I noticed that there were some games I couldn't connect to. I lived with it, because there was usually an abundance of games to choose from (btw, my poison of choice is Project Gotham Racing 2 (PGR2)). Now that the game has been out for more than a year, the number of available online games or "rooms" has dwindled, and the "This session is no longer available" message is much more annoying. When there are only four or five available games in the list, and I can only connect to one of those if I'm lucky, my gaming time is spent more on searching for games than actually playing.

Well, I finally decided to do something about it. I was told to check out this page to help diagnose my problem. The key metric here was the "NT" value, or NAT Type. My XBox reported that value as 1, or "open", which means I shouldn't have any problems connecting to online games. And yet, I was. The description of NAT Type 1 is as follows, and gave me my first clue:

Open NAT means that either the port assignment policy is minimal or the router has a fully compliant version of UPnP (Universal Plug and Play) enabled by default.

"Ah ha!" I thought. UPNP is where to start. I knew for a fact that my Linux NAT server didn't support UPNP, so that was a very good first lead. A bit of time on Google gave me the SourceForge site for the Linux UPnP Internet Gateway Device (linux-igd) project. My first instinct was to see if it was available already in Debian, but of course it wasn't. So, time to grab the source. As I read the README, I was pointed to the Linux SDK for UPnP Devices (libupnp) page as a requirement for building linux-igd. Not a problem, so I check Debian's package list again with no luck, and download the source for 1.2.1.

Building and installing the source went smoothly, so I switched over to the linux-igd code and started building. Holy crap, there were a lot of errors! After a half hour of investigation (or, "investigation", meaning, "hair-pulling, cursing at my PC, and just general frustration"), I realized that linux-igd is pretty old (the latest tarball was Jan 12, 2003), while libupnp was a little newer (latest tarball Feb 13, 2003). I grabbed an older version of libupnp (or upnpsdk, as the 1.0 version was called), removed the 1.2.1 version, and built and installed the 1.0.4 version.

Okay, now back to linux-igd. With upnpsdk 1.0.4 in place, linux-igd built like a champ. I installed the binaries, added the necessary route (route add -net netmask internalInterface), ran the daemon (upnpd externalInterface internalInterface), and started tailing the syslog debug log (/var/log/debug in my case, but where you've told syslogd to log debug messages).

Time to fire up the XBox. I turned it on, put PGR2 in the tray, and loaded up the game. While the XBox was starting, I noticed a request to the UPnP daemon for a port mapping. This is starting to look good. I connected to Live! in the game, went to Optimatch, and did my standard search ("Kudos racing, selection limited to class of cars", because I like competition and it's better when everyone is forced to choose cars of similar capabilities). Seven or eight games showed up the list, and I picked one at random. Previously, I would've gotten an error saying "The session is no longer available" (well, okay, that only happened about 75-80% of the time). Tonight, the first game I chose allowed me right in. Thinking to myself that it must've been a fluke, I left the lobby and tried a different game. It worked. I did that another four or five times, and aside from trying to join one game with 7 out of 8 people in the lobby and having it fill up on me right as I tried to join, every game worked.

The moral of the story is that an "open" NAT as the XBox Dashboard reports it may not actually be an "open" NAT, if you don't have UPnP support. It seems that XBox Live! really relies on UPnP when running in a NAT configuration, so you need to provide that support if you want a smooth experience. The easiest route is to just buy one of the many commercially available routers that are now available at very reasonable prices, but I don't always like "easy". Now that my Linux box has UPnP support, I have the best of both worlds: Complete control over my network configuration and firewall, and rock-solid XBox Live! support. And best of all, it didn't cost me a thing since I already had everything I needed in place already.