If you have ever tried to play Starcraft on Linux (using Wine) over Battle.net you must have seen that the interface looks very bad and the text is very hard to read. In my case, I was even unable to sucessfully start a game. So I and my friend decided to try a “local” game using the Hamachi tunneling tool.
How does this work? Starcraft is an ancient game (1998!) that only allows multiplayer gaming over Battle.net, Direct Cable Connection (who has ever used this?) and a Local Area Network. What Hamachi does is to establish a (virtual?) link between computers on the Internet so they appear to be on the same local area network. This is what is called a Virtual Private Network: “virtual” because the computers are not really into the same local network, but they appear to be, and “private” because you can configure (using a password and encryption) who can connect to the network.
Why Hamachi? Because it’s easy to configure and use. The drawback is that the Linux support is a bit limited and they bug you to buy the premium version everywhere; but it works. Let’s go to the meat. Since I use Debian, I will describe the process for Debian-like systems here.
- Download and install the Hamachi² Beta client for Linux. Before being able to install it, you’ll need to have the LSB package installed on your machine. On Debian Squeeze, “aptitude install lsb” will work. Once you have LSB installed, you can do “dpkg -i logmein-hamachi_18.104.22.168-1_i386.deb” (or any greater version) to install the client.
- (Optional, you can use Hamachi without it). Install the Haguichi graphical frontend. The Hamachi² client for Linux is command-line only (see this page for instructions about how to use the command-line client), so Haguichi can make our life easier. Go to its download page and choose the option you prefer. I used the Ubuntu deb package and “dpkg -i <package-name>”. I’ve personally found Haguichi quite sluggy.
- Create a LogMeIn account from this page. You will need it to create and manage your own virtual networks. Reply to the confirmation email and such.
- Create a LogMeIn network using the web interface. Once you’re logged in (in https://secure.logmein.com), select “Networks” in the left-hand menu, then “Add network”. Enter a cool network name and select “Mesh” as network type. Edit the network and copy (or write down) the network ID you’ll find under the “Members” tab. Under “Settings” select either “Must be approved” if you didn’t specify a password to join the network, or “Accept automatically” if you decided to do so.
- Tell all your mates to join the network you created using the cited network ID, and do so yourself too. Through the command-line, it would be something like “hamachi join <XXX-XXX-XXX> <password>”, and straightforward using the Haguichi graphical interface. If you have set the join requests policy to “Must be approved”, you will have to get to the network edit page and approve all the join requests.
- Once you’re sucesfully connected to your mates, you’ll see a green icon next to their nicknames, or them listed under the appropiate network, with an asterisk to their left after “hamachi list”.
You’re now all connected using a (virtual) network interface usually named “ham0″. If you do “ifconfig” (as root), you’ll see this interface is listed and there’s an IP like 22.214.171.124 associated to it. There’s still one thing left to do. To find games, Starcraft sends what is called a “broadcast” message to all the clients connected to the network. The problem is that it doesn’t send the broadcast over all interfaces, but only over the first one available, which is usually the one you use to connect to the Internet. In Windows, this is solved by moving the (virtual) interface Hamachi uses (ham0 in Linux) to the top of a list (I’m not sure what it exactly does), or using a wrapping software called ForceBindIP. In Linux, I solved it doing the following.
In Linux, the way the system decides which network interface to use is via the so-called routing table. How does this work? Depending on the format of the IP address you’re trying to get to, it uses one interface or the other. This is called subnet masking, and it’s like using prefixes in phone numbers. If you have a home network, which means simply computers connected to the router used to access the Internet, you’ll have an internal IP of the type 192.168.1.34. The first part, “192.168.1″ is the prefix that the system will use to determine that the IP is local and thus don’t try to send it over the Internet, but keep it local.
You can inspect your current routing table typing “route -n” as root. What Starcraft does to find games is to send a broadcast packet to the address “255.255.255.255″, so what we have to do is to route this (broadcast) address to our Hamachi interface. As root:
route add -host 255.255.255.255 dev ham0
Done! Fire up Starcraft and enjoy. The routing table is not kept after restarts by default, so you’ll have to add the previous route every time you restart your system and want to play, or place it in some configuration file read on startup (see your distro documentation).