Deciphering DHCP (Wireless)

The Internet works because everything on it has a unique address, and the devices that run the Internet are very good at getting information between two addresses. Before your computers and printers are ready to talk on your network, you have to make sure they have an address.

There’s a protocol called DHCP, the Dynamic Host Configuration Protocol, that not only is the way to automatically address the computers on your network, but knowing the acronym is a great way to impress your geek friends.

Later in the topic, I go over other related services that might come in handy some day.

Understanding DHCP

To first understand DHCP, you must know a bit about addresses. The most popular analogy is the snail mail system.

Through rain, sleet, or snow

To send a letter, you first put your message in an envelope, then you write your return address on the corner of the envelope and your recipient’s address in the middle, and finally drop it in a mailbox. There’s a stamp involved in there, too, but the Internet doesn’t need stamps; they gum up all the gears.

Someone comes by and empties all the mailboxes into a truck. Trucks are emptied into a collection center. The mail is sorted based on the destination: envelopes are sent on trucks or planes at a facility that’s closer to the destination, eventually working their way into a postal carrier’s bag and in your friend’s mailbox.


Finally, we talk about Internet addresses

As I said earlier, each computer on the Internet has a unique address, which is a number instead of a street name. Each time data (such as an e-mail) is sent over the Internet, the data is wrapped in a packet that has the addresses of the sender and the receiver of the packet. The devices that run the Internet look at that destination address and get the packet one hop closer to its destination. The next hop device does the same thing until the final hop — the destination — processes the message.

Incidentally, those devices that run the Internet are called routers and are similar to the one you have at home. The major difference is that the routers that run the Internet are more powerful because they have a lot more addresses to deal with, and yours only needs to worry about the one that your ISP gave you.

So, what does an address look like? You already saw one in the last topic, where you ran the Windows ipconfig command. My address was 192.168.1.2, and I could see that the router’s address on the wireless side was 192.168.1.1. My router also had a second (external) address that the ISP gave it, such as 24.79.42.159, which belongs to the cable or DSL side. The router’s job is to send packets between these two networks, and it needs an address on each network to do that.

Hiding addresses

Earlier in this topic, I said that every device on the Internet has a unique address. But you may have noticed that both your router and mine have an address of 192.168.1.1, which makes it not unique. What gives?

Your router also does something special called address translation. The networks starting with 192.168.x.x are meant to be private, that is, never seen on the Internet. Your router takes its address on the ISP side (such as 24.79.42.159, in my case) and uses that instead of your computer’s address (such as 192.168.1.2) when relaying your packets to the Internet.

When responses come back, the destination is the router. The router remembers who was actually talking and changes the destination back to 192.168.1.2 or whoever was talking.

From your ISP’s perspective, there’s only one person using their service — your router. Clever, eh?

I still remember my first job out of school, which involved managing a small network. About 40 computers were on the network, and every time I added a new one, I went to a spreadsheet, picked the next available address, made a note in the spreadsheet, and then set up the computer with that address.

Manually specifying addresses is time consuming and error prone. If two devices on the same network try to use the same address, neither of them can talk. Additionally, some of the possible addresses are invalid, and using one will cause problems on your network. Addressing is clearly a job for a computer, not humans.

DHCP solves these problems by letting a computer hand out the addresses. This computer keeps track of who has which address and periodically makes sure the addresses are still in use. DHCP is simple enough that it’s built into almost every router on the market, so you can probably start using DHCP right away.

At a high level, when your computer starts up, it sends a message to all the computers on the network that says "I need an address!" If there’s a DHCP server on the network, it finds a free address and responds with, "Here, have this address!" Your computer responds with, "Thanks!"

Sounds like a breeze, eh? Of course, it’s more complicated than that, but you don’t have to worry about the gory details. Understand, though, that DHCP is an ongoing thing. Your computer must periodically remind the router it’s still there, otherwise the router will reclaim the address for someone else. This usually happens every 12 to 24 hours and is handled automatically by your computer.

The last thing to remember is that it generally doesn’t matter what address your computer has, as long as all the rules are followed. DHCP makes sure you follow the rules, so it doesn’t matter if one day you’re 192.168.1.2 and when you boot up the next day you’re 192.168.1.50.

Your DHCP server

By default, your router almost certainly has DHCP turned on; otherwise, you wouldn’t have been able to connect to your router in the first place!

Jump over to the Advanced LAN settings of your router, which I’ve shown in Figure 4-1.

In Figure 4-1, you see that familiar 192.168.1.1 address, which is the IP address of the internal side of your router. That address stays constant even though the rest of the addresses on your network will be dynamic. The reason is that the computers need to find your router by its address in order to get out on the Internet.

Advanced LAN settings.

Figure 4-1: Advanced LAN settings.

Don’t worry about the subnet mask; it just tells your computer how big the network can get (big enough). And that RIP stuff, pretend it’s not there.

What you’re really after is the configuration on the second half of LAN setup, starting with Use Router as DHCP Server. This option is selected, and it turns on and off the DHCP functionality. If for some reason you want to turn it off, you deselect this button and click Apply.

Underneath the DHCP on/off switch are two lines that let you set the range of addresses that DHCP uses. You can see that the first three boxes are grayed out, and they happen to have the same values as the IP address of the LAN interface. This is intentional; if you were to change one of those values, you’d be handing out invalid addresses.

You can only change the last value, which can be a number from 1 to 254. Number 1 is already taken by the router itself, so this router is already handing out the maximum number of addresses. These addresses start at 192.168.1.2 and go up to 192.168.1.254, for a total of 253 possible addresses.

Underneath the starting and ending address fields is a place where you can reserve addresses for computers, so the same computer will always get the same address. Just hold on to that thought.

Turning off DHCP

After all that talk about the great things DHCP does, why would you want to turn it off? You probably don’t need to, but DHCP can get in your way. Int the following sections, I go over some ways to make your new life with DHCP work for the best.

Reserving your spot on the network

Sometimes you’ve got some software that needs you to do something called port forwarding. This means that the router is going to let some connections from the Internet directly into your computer. I’m not going to get into port forwarding in this topic, but your software manual has more detailed instructions on what’s needed to make it work. Port forwarding needs an address on your network to which to forward the packet.

DHCP gives out addresses that can change. If your router is trying to send a packet to one address, and you’ve got a different one, what do you do? Turn off DHCP? No!

What if you could still use DHCP but be guaranteed the same known address all the time? No one else would be handed out that address. That’s called a reservation. You’re simply reserving the address from the DHCP server.

Go back to Advanced LAN Setup and click Add. A screen like the one shown in Figure 4-2 appears.

Adding a DHCP reservation.

Figure 4-2:

Adding a DHCP reservation.

You need the IP address you want to give your machine, your computer’s MAC address, and your computer’s name to complete this form. MAC stands for Media Access Control, and it is part of a protocol that defines how networks work. It’s also something you’ll be able to forget about except for this one trick: To find out your MAC address, open a command window (StartO RunOcmd) and then type ipconfig /all. Figure 4-3 shows the result.

Results of ipconfig /all.

Figure 4-3:

Results of ipconfig /all.

Look for the line that says Physical Address. Mine is 00-18-DE-05-9C-15 Type that address in the MAC address field, along with your IP address and name, and click Add. Presto! That address is yours forever.

You may be noticing in Figure 4-2 that my MAC is listed right above the field. In fact, if you click the radio button on the left side of that table, it’ll even be prefilled in the form, effectively letting you make any dynamic address permanent with two clicks.

It’s good to know how to reserve an address the long way, because not all routers support that shortcut.

Just give me static!

In the context of computers, static electricity is usually bad. Static addresses, though, aren’t. Sure, they’re harder to manage, but if only there were some way we could make them work without having to turn off DHCP.

This one is fairly easy to solve. When looking at the DHCP configuration, you saw that you could change the range of DHCP assigned addresses. Change it to give some space on one side, such as lowering the upper limit to 199. DHCP still offers addresses from 192.168.1.2 to 192.168.1.199, and anyone that wants to put their address in manually can use 192.168.1.200 to 192.168.1.254.

Some network-attached printers don’t understand DHCP and need to be addressed statically. The same goes for much older computers, especially computers designed to be servers and not for daily personal use. Fair enough, just give them an address in your static range.

If you do break out a separate area for statically addressed machines, it’s a good idea to make a note of it somewhere.

DHCP, get out of my hair!

Sometimes you just want to turn off DHCP. You only want one DHCP server on your home network. If you have another device that’s doing the job of DHCP and you plug in your device, then you’ll have two devices handing out addresses.

DHCP is so simple that most devices come with it turned on. As you add more pieces to your network, you’ll probably come across the situation where you get two DHCP servers. Make sure to turn that second (or third, or fourth) server off.

As a case in point, these combination router-access point-switch devices are roughly the same price as an access point, so you might just come home one day with a second router to expand your new wireless network. Configure wireless, turn off DHCP, and give the new router a different static address, and you can plug it into the rest of your network as if it were an access point. Just remember to leave the Internet port unplugged, because your first router is providing the path out to the Internet, and the new one is bridging your computer between the wireless and wired inside networks.

But Wait, there’s more!

Looking back at the results of ipconfig /all from Figure 4-3, a bunch of other information is there. Most of it isn’t that noteworthy, but tI discuss two in the following sections.

Default gateway

The Internet is one big game of Hot Potato. One guy throws his packet to a router, who throws it to the next router down the line, all the way until it lands at its destination. To join in, you have to know where to throw your packet.

Your default gateway is the place that your computer sends all the packets it doesn’t know what to do with (for people on your local network, you can talk directly to them). DHCP tells you the address of your gateway when handing out the address. You can see that this address is 192.168.1.1, which is your router.

Without a default gateway, you’re not going to get on the Internet.

DNS servers

This topic has talked a lot about addresses like 192.168.1.1, but you’ve probably never typed one into your browser. You’ve always typed URLs like http://example.com/, right?

DNS, the Domain Name System, is what translates those names that you understand into the numbers that computers understand. It’s like the phone topic of the Internet.

Most routers make themselves the DNS server and relay your requests to your ISP’s DNS servers. Sometimes they just tell you to talk to your ISP’s name servers directly by handing out those addresses. Either way is good.

The funny thing about DNS is that you can be connected to the Internet, but without DNS, you’ll get nothing but errors when you try to do anything. That’s because your computer has no way to figure out how to convert the names to IP addresses, and you probably don’t know the addresses off the top of your head, either. The address is required for your computer to connect to your destination, such as a Web server: a name won’t cut it.

Troubleshooting DHCP

If you get an address through DHCP, then DHCP is working great. It’s pretty simple that way.

With DHCP, you usually don’t end up without an address. If there’s a problem, your computer will assign itself an address starting with 169.254, which is called the autoconfigure address range. This address isn’t helpful, because it’s not one of yours and therefore can’t be used to talk to the Internet.

If you get this autoconfigure address, then make sure you’re within range of your access point. Sometimes you get enough strength from the wireless signal to see the other side, but not enough to have any meaningful conversation, such as the whole, "Hey, I need an address" song and dance that starts things off.

Other times, the problem is related to your wireless drivers, especially if you’re trying to get equipment from two different vendors to play nicely together. You need to check to see if you can hookup using a wired connection, and download some updated drivers.

Of course, if you’ve turned off DHCP on your network, or never had it in the first place, you’ll see a lot of those 169.254.x.x addresses until you set up a static address or turn on DHCP.

Next post:

Previous post: