Setup Sharing an Internet Connection

You don’t need an Internet connection to have an ad hoc network. For that matter, you don’t need an Internet connection to have any computer network. Computer networks existed long before widely available Internet connectivity, indeed long before the Internet itself.

And remember that the Internet is simply another network, special only in the fact that it operates as a network of networks (hence the inter portion of its name), and the fact that the world has adopted it. But many networks continue to exist that offer full connectivity internally without external Internet access.

That said, in the case of pretty much all non-business LANs, Internet connectivity has become the norm. In fact, you could argue that it’s become the entire purpose for creating the LAN in the first place.

In homes and many small offices, particularly homes, users rarely need their PCs to connect to one another; instead they need them—or at least want them—to connect to the Internet. E-mail and the Web, for these users, are far more important than sharing files, printers, or other resources, or even playing networked games.

If you want to share an Internet connection most reliably and conveniently with your wirelesslyconnected PCs, buy an access point and build an infrastructure network. However, you can most certainly share an Internet connection among the PCs on an ad hoc network.

You simply need to designate one of those PCs the sharing computer, connect it to the Internet, and use the Internet Connection Sharing (ICS) feature of Windows to make the Internet available to all the other networked PCs.

Internet Connection Sharing works by fooling the Internet into thinking that only one computer is performing Internet requests, uploads, and downloads. The sharing machine acts as a focal point for the entire LAN, with all incoming and outgoing data passing through it.

In effect, the sharing computer acts as a proxy server, and in fact Windows ICS is a kind of simplified proxy server. Full proxy servers control, secure, and cache all incoming and outgoing data, and offer control over individual machines on the LAN, whereas Windows ICS just routes data and offers minimal security.

With Windows ICS, each computer on the LAN is given its own unique IP (Internet Protocol) address, just like all other computers on the Internet. However, the LAN’s IP addresses are private to that LAN, and do not provide direct Internet access.

The only computer with a public Internet IP address is the sharing machine, and it has two IP addresses: one private, one public. The public IP number is assigned by the Internet service provider at the time of connection, while the private IP number is assigned through the Network applet in Windows Control Panel, either manually or via the ICS wizard.

For the remainder of this discussion, let’s give the computers names to avoid confusion. We’ll call the sharing machine Computer A and the other PCs on the LAN Computer X, Y, and Z (as needed). The private IP address for Computer A is 192.168.0.1—the 192 series is restricted to private LAN use (the Internet doesn’t recognize the 192 numbers).

The ICS wizard sets this IP automatically, or you can set it yourself using Control Panel’s Network app. Computers X, Y, and Z (and all others on the LAN) require IP numbers in the range 192.168.0.2 through 192.168.0.253.

You can assign these numbers through the Network app, or you can have the sharing computer assign them through its built-in DHCP (Dynamic Host Configuration Protocol) routine. The latter is easier, simply because it eliminates the need to dig into each machine’s Network app manually.

Indeed, nearly all cable/DSL routers and other Internet sharing devices, including server computers, use DHCP as the basis for address assigning, although not all begin the counting with 192.168.0.1 as Windows itself does.

The Microsoft Wireless Base Station, for example, takes the address 192.168.2.1 and assigns from there, and other routers use other private-range addresses.

When Computer X makes a request to the Internet, such as sending e-mail to an Internet address or clicking an external hyperlink in a browser, Computer X’s private IP address is sent to Computer A.

There, the private IP address is translated to Computer A’s public IP address—with Computer X’s IP address retained in conjunction with the request by the sharing computer—so that the requested Internet server can respond.

The response from the Internet comes back to Computer A’s public IP address, and Computer A recalls the original IP address and sends the response to Computer X. Computer A works the same way as all other machines on the LAN, translating all interactions from the 192.168.0.1 address to the public IP address.

But because the data doesn’t need to flow between machines in this case, the process is faster than one in which the data traverses the LAN wires. Computer A will be affected by network slowdowns, however, just like any other computer on the LAN.

Although ICS setups typically use a router or switch, with or without the access point, for the sake of establishing a more purely ad hoc network, we dispense with the AP/router/switch here to work solely with one PC acting as an ICS host, and however many node PCs as you wish forming an ad hoc network with one another and receiving an Internet connection from the ICS host.

What you get in the end is a network with each node wirelessly connected to each other node, and each one capable of accessing the Internet as well. Call it ad hoc–plus, if you will.

Configuring the ICS Host

The network in this demonstration (a typical such network) has a desktop PC as a host PC and three notebook PCs constituting the ad hoc WLAN. Certainly you could start with a notebook PC instead, but we’ve chosen a desktop for the simple reason that it will be the only node on the WLAN without a PC Card wireless adapter.

Instead, it can use either a PCI or a USB adapter, and the example here uses the latter. To share a broadband connection, the ICS host needs an Ethernet LAN adapter, typically a PCI card inside the computer or an adapter build right onto the mainboard.

In either case, you connect the ICS host to the Internet by running an Ethernet cable from a cable or DSL modem (typically) into the Ethernet card. You then set up the Internet connection according to the instructions you receive from your Internet provider.

In the case of virtually all cable and DSL providers, this means first configuring the Network Properties dialog box to obtain an IP address automatically and to obtain the DNS (Domain Name System) server addresses automatically, as shown in Figure 1.

Configuring the TCP/IP settings.

DSL customers need to create a login script as well, a process you can perform either via the New Connection Wizard or the Network Setup Wizard.

This login script consists only of the username and password your ISP has assigned to you, and the wizard not only gives you a screen with fields for both of the entries, it also stores the entries for future logins.

To sign into your DSL account, you launch the Connect dialog box from the desktop or from the Network Connections dialog box, and on this box you’ll see the username in the appropriate field, along with a password field that says, “[To change the saved password, click here.].”

The password you typed in the wizard is the one already in force, so there’s no need to change it unless you do so with your ISP.

Unless you’ve used the Network Setup Wizard, during which Windows configures your PC to share the Internet connection, you must tell Windows that you wish to do so.

Open the Network Connections folder by first opening My Network Places and then clicking the View Network Connections link in the Network Tasks pane. Right-click the icon for the network resource (LAN or Internet connection) you are using to connect to the Internet and choose Properties.

Under the Advanced tab you’ll find the checkbox, “Allow other network users to connect through this computer’s Internet connection.” Check this box, and unless you have a specific reason to uncheck the other boxes—“Establish a dial-up connection whenever a computer on my network attempts to access the Internet” and “Allow other network users to control or disable the shared Internet connection”—leave them selected.

If you’re using DSL or cable, feel free to uncheck the former, and if you want to ensure nobody else disconnects, uncheck the latter, but typically neither option presents any problem.

If you want to use the Network Setup Wizard to configure ICS instead of doing so manually, launch it from the Network Tasks pane, by clicking the “Set up a home or small office network” link, and follow these steps:

  1. Step through the wizard to the question, “Do you want to share an Internet connection?”

With your cable/DSL connection already established, the appropriate response is “Yes.” If you have more than one possible connection and you don’t want to use the default suggestion, click “No, let me choose another way to connect to the Internet.”

  1. On the “Select a connection method” screen, choose “This computer connects directly to the Internet.

The other computers on my network connect to the Internet through this computer.” Note that if you have already established a LAN with the Internet connection shared through a cable/DSL router or a separate router, choose the second option, “This computer connects to the Internet through a residential gateway or through another computer on my intranet.”

If you do so, however, your PC no longer acts as host; the router does. For this example, therefore, the first choice is correct.

  1. Choose the Internet connection you wish to share. Windows takes its best guess at it for the sake of automation, and this guess is usually right. You want to share the broadband connection, which in turn provides Internet access to all machines. See Figure 2.

Choosing the source of the Internet connection.

  1. On the next screen, “Select your private connection”, you choose the connection that will provide Internet connectivity for the ad hoc WLAN. Here’s where difficulties can result.

The answer, in our sample case, is the Local Area Connection belonging to the Ethernet card in your PC—not the Wireless Network Connection option, if it appears in this list.

In other words, Steps 3 and 4 have you establish the broadband connection as sharing the Internet connection, and the Ethernet card (Local Area Connection) as acting as the hub for the WLAN.

  1. The next screen has you giving the ICS host computer a name and an optional description, and naming the workgroup whatever you choose. Windows standardizes on MSHOME for the network name.

But not only can you change it, you should. Anyone looking to break into your network has an easier time if you opt for the default name, so personalize it and simultaneously get rid of some casual hacking.

  1. On the “File and printer sharing” screen, you can choose whether to turn on the file and print sharing option. If you do turn on file or print sharing, you risk allowing intruders easier access to your files.

In fact, if you don’t have a firewall program, don’t even consider turning this option on. The default is to turn it off, and that’s a good idea for now. You can always reverse your decision later by reconfiguring the network.

  1. After clicking Next twice (the first time to confirm your choices), Windows sets up your network. The first time it does so can take several minutes, but if you re-run the wizard later it takes significantly less time.

After finishing, the wizard presents you with the choice of creating a network setup floppy disk for use on the other nodes on the network, using an already created network setup floppy, setting up the nodes by using the Windows XP installation CD, or finishing the wizard without creating media to run on the other nodes.

If all your nodes are running Windows XP, as we assumes, you don’t need to do anything. For PCs with any other version of Windows, create the setup floppy as assurance of getting the network up and running on all your machines.

Providing Internet Connectivity to the Ad Hoc WLAN

At this stage, you have an ICS host ready to roll, but you have no way for the other nodes on the network to connect to it. For this, you need to install a WLAN adapter into the host.

If your host PC contains a PC Card adapter (most desktop PCs do not), you can simply use an adapter identical to those in your notebook PCs. In the vast majority of cases, however, you need a PCI or USB adapter.

This example uses USB, simply because it’s easier to install and set up, although we’ve become aware through testing a variety of products that both PCI adapters and PC Card adapters tend to connect—and maintain the wireless connection—on a more consistently reliable basis.

If you intend to share your Internet connection with a WLAN in the manner described here, you should consider using a PCI WLAN adapter if your ICS host is a desktop PC or a PC Card WLAN adapter if your host PC is a laptop.

Here, too, the Network Setup Wizard can help you. Install the drivers for your WLAN adapter on the desktop, plug in the adapter itself (PCI slot or USB port), and connect the adapter to the ad hoc network you’ve already created.

With the ad hoc network fully in place, run the Network Setup Wizard once more. This time, Windows will bridge the Ethernet connection to the Internet with the wireless connection to the other nodes on the WLAN, while simultaneously configuring the ICS host’s WLAN adapter to provide IP and DNS addresses to those nodes.

The node PCs require this addressing information to connect to the Internet and receive and send traffic beyond the ad hoc network. If you don’t want to use the Network Setup Wizard, you can configure the ICS host’s WLAN adapter manually to perform the same addressing function.

To do so, configure all WLAN adapters, including the one installed in the ICS host, to obtain IP and DNS server addresses automatically. Open the Network Connections folder, right-click the icon for that connection, and, on the General tab of the resulting Properties dialog box, select the Internet Protocol (TCP/IP) item in the list of items and then click the Properties button.

On the General tab of the Internet Protocol (TCP/IP) Properties dialog box, choose the top radio button in each section—“Obtain an IP address automatically” and “Obtain DNS server address automatically”—and then click OK until you’ve closed all the dialog boxes.

Because the ICS host is configured to share an Internet connection, and because the host’s WLAN adapter receives its IP and DNS addresses automatically and communicates with the rest of the ad hoc network, the nodes on the WLAN will also receive Internet connectivity information.

Again, if you have difficulties with the manual setup, run the Network Setup Wizard and let Windows do the job for you. Indeed, often this is the most efficient method to use.