The simple version is that the network gateway is set up such that when you first connect any IP address resolves to the login screen. Once you've successfully logged in, addresses resolve to the real addresses.
Google for "hotspot" software. Chillispot is the OSS software that comes to mind. It's been installed with Sveasoft Alchemy on many WRT54Gs, but the installation instructions I've found so far are awfully vague :-)