Normally this is great, but when we want to host a website at home or host BitTorrent downloads at home, it's inconvenient. In these cases, we want other people to be able to connect to our computer... for those purposes only, of course.
Fortunately, all well-made routers allow us to forward ports to a particular computer inside the "local" network (your collection of computers at home, "behind" the router). Unfortunately, many routers assign a new address to each computer every time it is turned on. To forward connections on web or BitTorrent ports, we first need a "static" (unchanging) local address on the local network to forward those connections to! So how do we keep our computer from getting a new address every time we power it on? That's the question I'll answer here.
There are two ways to solve this problem. If your router is well-designed, it might have a feature that lets you assign a specific, never-changing local IP address to your computer by its name on the local network. That's convenient because you don't have to change settings on the computer itself.
The second way... which is the only way with some routers, like my own SMC Barricade G and the popular Linksys WRT54G... is to assign your computer an IP address outside the range of addresses that your router gives out automatically. By forcing the computer to use a specific IP address, we avoid the problem of receiving a new address every time we power the computer on. In this case we'll make the change in your computer's network settings. But first, we'll want to double-check the range of IP addresses that your router gives out, so that two different computers never get the same IP address.
Please don't ask me what your router password is! You chose it when you set up your router, or it is still set to the default. If you can't seem to get in, check the manual of your router for more information. There may be a default password, or the default password might be blank. In a worst-case scenario, follow your router's procedure for a hard reset (not just a power cycle -- there is usually a recessed button for this job, see the manual).
Once you have logged in to your router's configuration interface, explore the advanced settings and look for a way to assign a fixed, unchanging IP address for your computer on your local network. Your router may provide a way to do this on a page of settings devoted to DHCP (Dynamic Host Configuration Protocol). Also take note of the range of addresses automatically assigned to computers without a fixed address. Typically this is 192.168.2.100 to 192.168.2.254 or something similar.
Now reboot your computer. At the Windows command line (Start -> Run -> cmd.exe), the ipconfig command should now report the fixed IP address that you assigned.
If Your Router Doesn't Let You Set Static Local IPs
If your router doesn't allow you to assign fixed local IPs in this way, all is not lost. You can still assign a fixed IP via the Windows Control Panel (or the Macintosh or Linux equivalent). Follow these steps to force your computer to use a fixed IP address:1. Choose an address. It must be in the same "class C subnet" as your router. That is, if your router's web interface is at http://192.168.2.1/ (typical for the SMC Barricade G) or http://192.168.1.1/ (typical for the Linksys WRT54G), then you can choose an address where the last of those four numbers is different. The number you choose must be between 2 and 254, and you must choose an address that won't be dynamically assigned to other computers. The DHCP settings page of your router's web interface will tell you what range of addresses are dynamically assigned by DHCP. Many routers, including both the SMC Barricade G and the Linksys WRT54G, are set up "out of the box" not to assign addresses ending in a number between .2 and .99. So anything in that range is a good choice for your server. For instance, with my SMB Barricade G, 192.168.2.11 is a good choice for a static local IP. With the Linksys WRT54G, 192.168.1.11 is a good choice.
2. Access the Network Connections control panel of Windows XP (Start -> Control Panel -> Network Connections). Pick the connection you're using, either Local Area Connection (for wired Ethernet cables) or Wireless Network Connection (for WiFi). Right-click on that connection's icon and pick Properties. Under "this connection uses the following items," scroll down to "Internet Protocol (TCP/IP)" and double-click on that. The "Internet Protocol (TCP/IP) Properties" window will appear.
3. Right now, "Obtain an IP address automatically" is probably selected. Instead, select "Use the following IP address." In the "IP address:" field, enter the address you chose (for example, 192.168.2.11 works well with my SMC Barricade G, while 192.168.1.11 would work well with a Linksys WRT54G). The subnet mask will automatically become 255.255.255.0, which is correct. Set the "Default gateway" field to the address of your router, which is usually 192.168.2.1 (for the Barricade G) or 192.168.1.1 (for the Linksys WRT54G) -- but please don't copy and paste this! Use the address that actually gives you access to the router's web interface.
4. "Use the following DNS server addresses:" is now selected. In the "Preferred DNS server:" field, enter the IP address of your router (the same as the default gateway). Leave "Alternate DNS server:" blank.
5. Click "OK" to leave the "Internet Protocol (TCP/IP) Properties" window, and again to leave the connection properties window. In Windows XP, your IP address will change immediately at this point. Verify that you can still access the Internet. If not, double-check your work.
"My server doesn't show up on the client list in my router!"
The "client list" displayed by some routers is just a list of PCs that were assigned addresses dynamically by the built-in DHCP server in the router. You have a static IP address for your server, so it doesn't show up. This is normal, and it's a good thing.
Legal Note: yes, you may use sample HTML, Javascript, PHP and other code presented above in your own projects. You may not reproduce large portions of the text of the article without our express permission.
Got a LiveJournal account? Keep up with the latest articles in this FAQ by adding our syndicated feed to your friends list!
Follow us on Twitter | Contact Us
Copyright 1994-2012 Boutell.Com, Inc. All Rights Reserved.
