Many web sites know where I'm from. For example, visiting Yelp shows me restaurant listings from the nearest metropolitan area and searching for "maps" on Live Search shows me a map of my current city.
My best guess is sites do this by using a large database mapping the user's IP address to city name. If this is true, where's the best place to obtain such a database at a reasonable cost? A Google search matches a lot of random vendors I've never heard of.