Hack 74. Set Up an Ad Hoc WiFi Network
Don't have a WiFi router handy, but want to set up a network among multiple PCs? It's easy to do using the ad hoc networking built into XP.
There are times when you don't need a network to share a single Internet connection. Instead, you just want to share files, use the printer of another PC, send and receive instant messages; in other words, do pretty much everything you can do on a network.
But what if you want to do all that and you don't have a router?
You can set up an ad hoc network, in which you connect on a peer-to-peer basis with other computers and PDAs. You don't need any extra software for it. The capability is built right into XP.
All you need are WiFi-equipped PCs. To establish an ad hoc network, first one PC does the basic setup and then the rest of the PCs connect to that ad hoc network.
On the PC that's setting up the network, double-click the Wireless Network icon in the system tray. Click the Properties button, and then click the Wireless Networks tab. Click the Add button and make sure you're on the Association tab. The screen shown in Figure 7-30 appears.
Figure 7-30. Getting an ad hoc network started
Type a name for your network in the SSID box. At the bottom of the screen, check the box next to "This is a computer-to-computer (ad hoc) network; wireless access points are not used."
If you're not using encryption to protect the ad hoc network, choose Disabled from the "Data encryption" drop-down box. If you are going to use encryption, follow the instructions in [Hack #69] .
Click OK and then OK again. Your network is now set up. Even though you've set it up, it won't be visible to you. But it will be visible to people nearby, and they can easily connect to it.
On each PC that you want to connect to the network, right-click the Wireless Network icon in the system tray and choose View Available Wireless Networks. You should see the SSID of the network you've just set up. To connect to the network, just click the Connect button. Depending on how you've set up your PC's security, you can now share files, browse each other's hard disks, send messages, use each other's printers, and so on.
If for some reason another PC doesn't find your ad hoc network, you'll need to check that second computer's wireless settings. It might be set up to hide ad hoc networks. Double-click the Wireless Network icon in the system tray, click the Properties button, and then click the Wireless Networks tab. On that tab, click Advanced to display the dialog box shown in Figure 7-31. Make sure you haven't selected "Access Point (infrastructure) networks only." Then click Close. Now the network will show up.
Figure 7-31. Deselecting "Access Point (infrastructure) networks only" to see any nearby ad hoc networks
Because there is no router for the network, there's no DHCP server, but all PCs on the network get temporary IP addresses called link local addresses, ranging from 169.254.0.0 through 169.254.0.16.
7.11.1. Bluetooth File Transfers
Bluetooth also allows you to set up ad hoc networks. In fact, by their very nature, Bluetooth connections are in essence ad hoc networks. So, every time you set up a Bluetooth connection, you're setting up an ad hoc network. For details, see [Hack 72] and [Hack #73] .
To transfer files between two PCs with Bluetooth, first pair the PCs [Hack #73] . Then, from one PC, right-click the other paired PC and choose Discover Available Services. You'll see a file transfer icon. Double-click it. Depending on the security settings, you might be prompted to enter a PIN. If so, you'll use the same PIN on both PCs.
The other PC will now show up in My Bluetooth Places, and now you can navigate through it to transfer files from it to your PC.
7.11.2. Hacking the Hack
You can use an ad hoc network to share a single Internet connection among multiple users. In that case, the user that sets up the ad hoc network configures his PC to allow others to share his Internet connection. Then, when other PCs connect to the ad hoc network, they can get onto the Internet. Of course, to be able to do this, the PC has to have a live Internet connection, such as a broadband cable modem or DSL modem connection.
On the PC that set up the ad hoc network, right-click My Network Places and choose Properties. The Network Connections dialog box appears. Right-click the wireless connection and choose Properties. Click the Advanced tab to bring up the dialog box shown in Figure 7-32.
Figure 7-32. Sharing your ad hoc network's Internet connection with others
Check the box next to "Allow other network users to connect through this computer's Internet connection" and click OK. Don't check the box next to "Allow other network users to control or disable the shared Internet connection," unless you want to give them that kind of control over the connection. Then click OK again.
If you have servers or network services on your PC that you want to give others access to, such as FTP servers and mail servers, click the Settings button and put checks next to each server or service. Then click OK and OK again.
When you do all this, your PC will function like a DHCP server and hand out private network addresses to the other PCs accessing the Internet. In essence, you're turning your PC into a wireless router.