Friday, August 22, 2014

"What is DHCP?" for the Non-Technical

When you take your laptop to a place and connect to a WiFi network (or plug a network cable into your desktop), I imagine you expect it to simply connect to the network and let you browse the Internet and communicate with other computers there.

As is the case with all things computerized, it's not quite so simple.

Before I start explaining what DHCP is exactly, I have to explain some introductory networking concepts. Here are some words you should know:

  • MAC address: the ID of your computer's network card. This is usually a physical, burned-in setting that was determined at the time of manufacturing. (Some network cards let you change it.) This address is used to participate in any kind of network communication. Please note that it has absolutely nothing to do with Mac OS or Apple at all. (It stands for Media Access Control.)
  • IP address: the ID of your computer, as seen by other computers on the network. IP stands for Internet Protocol, which is just one of many communication types in which you can participate. IP addresses must be translated to MAC addresses for determining where data needs to flow because physical network machines can use different protocols as well (ICMP for example), which don't use IP addresses at all.
  • Router: a (usually) physical device that determines where data needs to go next in order to get to its destination. All modern routers are Internet Protocol (IP) devices, so identification with them uses IP addresses.
  • Routing: the process by which data is sent on its way to the intended receiver, usually by mapping various types of network addresses to physical plug-in ports.
  • Protocol: a previously agreed-upon system of and format for electronic communications.
  • Switch: a (usually) physical device that is like a router, but uses MAC addresses for identification. More different types of information can flow across switches because they don't care about anything besides what physical device you want to send data to. (Routers will only pass along IP data.)
  • Packet: a segment of information sent across the network. A packet (unless some hacking is in progress) always contains the MAC address of its sender and the MAC address of the next device to receive it. Keep in mind that the sending computer does not typically know the MAC address of the destination computer, only where the packet needs to go in order to get routed to continue on its journey. A packet may contain higher-level information, like the destination IP address.
  • Host: a computer on a network.
OK, that's out of the way. Now, DHCP stands for Dynamic Host Configuration Protocol. It helps you get connected to the network by automatically assigning your IP address. Why is this important?

The Internet and most network operations are based on Internet Protocol. To talk to your router (which is very important if you want to be able to talk to any web sites on the external Internet), you need to have an IP for it to use in routing. You also need to know the IP address of the router itself. It is possible (and was frequently done before DHCP was invented) to enter these settings manually. Of course, if you happen to set your computer's IP address to one that's in use by another, horrible things happen, namely nobody being able to use the network. Also, if you enter an IP that is not in the right network group (the subnet), all the computers are confused and most routers will null your packets.

If you just connected to a wireless network, you probably have absolutely no idea what the router's IP is, or even what range of IP addresses you should pick from. Fortunately, DHCP is here to automatically detect these settings for you. When you connect, your computer will broadcast a message (to everyone, because it has no idea who it needs to talk to) and wait for a reply from somebody claiming to be a DHCP server.

The DHCP server is listening for these broadcasts. When it hears one, it looks in its settings (which are configured once by the network administrator) to find what IP addresses it can assign. It then picks one that isn't in use and sends it to the IP-less computer that sent the broadcast. If the broadcaster accepts it, the DHCP server maps that IP address to that MAC address and (sometimes) informs the router that it has a new routable client. Presto, the client has been given a usable IP and the network administrator only had to enter the complicated network settings once; DHCP takes care of disseminating them.

Using its snazzy new IP address, the computer can start talking to the router (also known as default gateway) to send IP packets out of the network to the Internet. And that, ladies and gentlemen, is the Dynamic Host Configuration Protocol.

Footnote: DHCP can also help automatically inform clients of other interesting places on the network, like the domain controller, the DNS suffix, the mail exchange server, IRC servers, or pretty much anything. It's like a tour guide!

No comments:

Post a Comment