Friday, July 20, 2007

How to share your laptop WiFi connection

I recently moved into a countryside apartment with no phone line, which means the only ways of getting online would be to get one of those Super-3G HSDPA modems, but that'd give me at the most about 3mbit downstream, OR, I could set up a wireless link from the next house (which has a 8/1 mbit ADSL line) using regular WiFi.

The second problem then would be how to connect the "server" I have standing under my dekstop, since it only has a wired connection. Solution 1 would be to buy a USB WiFi card and plug it in, but since I'm "broke", and I'm not sure what card will work with Ubuntu (probably most, but anyway).

Since I had one old D-Link DWL700 AP and also a DI-604 lying around I decided to connect the (WinXP) laptop using WiFi, and then share the laptop WiFi connection through the LAN port. I guess any basic AP and switch would do the trick, heck you could even use a crossed LAN cable between laptop and server.

It's all pretty straight forward once you get the basic components up; connecting the AP is easy, just plug it into the existing LAN switch in the neighbouring house, make sure it's correctly placed to get full signal strength to my apartment (which wasn't very tricky, window-to-window it's like 10 meters between the houses with no obstructions).

After that, I plugged both the laptop wired connection and the "server" into the DI-604 switch, configured a separate LAN network where the laptop got an IP of 192.168.50.1 and the server got 192.168.50.2. I set the default route of the laptop LAN interface to the WiFi AP IP address (defaulted to 192.168.0.50, which suited me fine), and the server gets a default route of 192.168.50.1 (the laptop). And.. Voilá!

This was all I needed to configure. Needless to say, I was overjoyed! No fuzzing around with XP ICS, no extra routing etc, It Just Works ™

Still, there's problems. The DWL 700 AP is a very simplistic AP, and does not have all the fancy routing and firewall features I need to forward ports to my server etc, so I'll probably invest in a better high-end AP once I get the money.

Now, if anyone tried other nice ways of sharing connections, please let me know..

Sunday, July 15, 2007

No Posts and how to make a GUID

There's not been any posts for quite a while now. Sorry for that, but been working on a couple of projects, building an "apartment", and also a new web/mobile project which is due for release tomorrow. I'll post the link(s) then!

For now I'll post a piece of PHP code that I was required to write for a RPC this project. Might come in handy to some (win32) users.

/**
 * Creates a unique GUID string.
 *
 * @return string Unique GUID
 */
function makeGUID()
{
  $ls = Array(8,4,4,4,12);
  $chrs = "0123456789abcdef";
  $guid = "";
  $chlen = strlen($chrs)-1;
  foreach($ls as $len) {
    if($guid != "")
      $guid .= "-";
    for($i=0; $i<$len; $i++)
      $guid .= $chrs[rand(0, $chlen)];
  }
  return $guid;
}