DHCP – CompTIA A+ 220-1201 – 2.4

We rely on the dynamic host configuration protocol (DHCP) to automatically assign IP addresses to our network devices. In this video, you’ll learn about the DHCP process, scopes, pools, and DHCP address reservations.


We’ve become very accustomed to turning on our desktop computers, our laptops, or our mobile devices and automatically getting an IP address. But it wasn’t always this way. There was a time where you’d have to manually configure all of these configuration settings in your device. So you would manually have to put in your IP address, your subnet mask, your default gateway, your DNS servers, and any other IP configuration parameters.

If you had a small number of devices, then you probably could configure these devices manually with the static IP addresses that never changed. But today we have thousands of devices on one single network, and it would be very difficult for an administrator to manually configure every single one of those devices.

That’s why we created DHCP, or the Dynamic Host Configuration Protocol. This is a protocol created in 1997 to allow us, the system administrator, to automatically assign this information across all of the systems in our infrastructure. So the next time you go to a coffee shop, you open your laptop and immediately start accessing the internet, you can thank DHCP.

Although we don’t often see this process that occurs behind the scenes to be able to assign these IP addresses, it is important as a system administrator that you know what’s really going on. We often refer to this automated process as DORA, D-O-R-A. Dora stands for discover, offer, request, and acknowledge. This process occurs every time someone connects to the network for the first time, and needs to get an IP address from a DHCP server.

Let’s take a scenario where we have Sam on the network, who currently has just turned on her computer and does not yet have an IP address. And we also have Jack on this network, who’s also just turned on his laptop. And Jack also does not have an IP address.

Let’s start with Sam’s laptop. And the default configuration for practically every operating system these days is to look for a new IP address using DHCP. So the first thing that Sam’s computer will do is to perform step one, or the discover step.

This means that her laptop will go out to the network and try to discover where all of the different DHCP servers might be and what IP addresses might be available for her workstation. If you were to capture packets on this network, you would see a DHCP discover message sent from Sam’s computer.

And currently, since Sam does not have an IP address, it is sent from IP address 0.0.0.0 over UDP port 68. And it’s sent across the network as a broadcast so that every device on the network will see this communication.

So this broadcast will go from Sam’s computer. When it reaches the switch, because it’s a broadcast, it is sent to all of the devices on this local subnet. One of the devices that received that discover message is the DHCP server that’s on this network. And you can see this DHCP server has an IP address of 10.10.10.99.

This server now sends a DHCP offer to Sam’s workstation using a broadcast, because obviously Sam does not yet have an IP address. So this step two, offer, is being sent from the DHCP server to an all 1’s broadcast, or 255.255.255.255. Here’s the offer from the DHCP server. And as a broadcast, it’s sent to all of the devices on this local subnet.

Obviously, Sam has also received this broadcast, which contains an offer from the DHCP server of an IP address that could be configured for Sam’s machine. Obviously, if there were more DHCP servers on this network, Sam would receive multiple offers to choose from.

And in step three, or the request part of this communication, Sam is going to choose one of the offers that’s been received and send a request for that IP address back to the DHCP server. The actual packet is a request sent from Sam’s computer using 0.0.0.0, because again, Sam does not yet have an IP address. It is sent from UDP port 68 to 255.255.255.255 over UDP port 67. This is obviously sent from Sam’s computer.

And since it is a broadcast, all of the devices on this local subnet will receive this request, including the DHCP server. The last step is an important one because it locks in that IP address on Sam’s device. This is sent as an acknowledgment from the DHCP server, acknowledging that IP address has now been assigned to Sam’s machine, and that IP address won’t be assigned to anyone else for the duration of that lease.

This is sent directly from the DHCP server, in this case 10.10.10.99. And again, its sent as a broadcast to everyone on this network to 255.255.255.255 over UDP port 68. And now that Sam has received that acknowledgment, the IP address can finally be updated on Sam’s computer and Sam has now been assigned 10.10.10.42. This is the process that occurs for anyone connecting to the network. So when Jack turns on his computer, he will also go through that same four-step process.

How did the DHCP server know what IP address to assign to Sam’s workstation? It was able to do that because a predefined list of IP addresses was already configured on that DHCP server. We refer to that predefined list of IP addresses and all of the other configuration settings for that device as a DHCP scope.

This might include all of the IP addresses available for devices on this network, as well as excluded addresses that might be used for other devices on the network that should not be given out as an IP address.

For example, you might have switches or routers on this network that have static IP addresses. We don’t want to assign those IP addresses to another device, creating a conflict on the network. We also configure the subnet mask as part of this DHCP scope, lease durations that we might use, and any other options that are important for the IP configuration of these devices. Things like a DNS server, a default gateway, voiceover IP server, IP addresses, and other details.

Inside of that DHCP scope are pools of IP addresses that the DHCP server will choose from to be able to automatically assign IP addresses to other devices. These will usually be large groups of IP addresses. For example, you might have 192.168.1.0/24, 2.0/24, 3.0/24, and so on.

If anyone connects to the network from any of those subnets, the DHCP server will pull from the appropriate pool and provide that available IP address to the end device. Although this is often a single large contiguous pool of IP addresses, it doesn’t have to be.

We could certainly configure different sections of IP addresses to assign, which means you might put exclusions in the middle of the pool so that certain addresses will always be assigned to a particular device. And you can use all of the other addresses as any available dynamic address for any other device on the network.

Let’s look at how the scope is configured on a DHCP server. This is the DHCP server that’s running on Windows Server, and in Server Manager is the IP version for DHCP server. And this one happens to have a scope that’s titled 165.245.44.0. This assigns IP addresses in that range for this particular subnet.

So on this DHCP server, we would add all of the available addresses for this subnet into this address pool. We could also view any leases that have already been assigned from this DHCP server.

We might also have devices that always receive the same IP address every time they’re turned on. We refer to those as a DHCP reservation. And then if there are additional options that you need to add as part of this scope, the DHCP server will also give you an area of the configuration to put all of those settings as well.

We often think of DHCP as randomly assigning any available IP address to any device that connects to the network. But sometimes you do need an IP address to stay with a particular device. Maybe it’s a file server or a web server, or maybe you always want your router to have the same IP address every time it’s turned on.

Now, of course, you could go to all of those servers and routers and switches and manually configure a static address on those devices. But if you happen to change anything with your IP addressing scheme, that means you would have to revisit all of those devices to manually update any configuration changes.

If you’re using a DHCP address reservation, you can make all of those changes in the DHCP server itself, and not have to manually update all of those individual devices. The way that we’re able to associate a device with a particular IP address is we configure the MAC address of that device in the DHCP server itself.

We would specify that this MAC address always receives this particular IP address. Sometimes you might see this referred to as a static DHCP assignment, a static DHCP, or simply an IP reservation.

Here’s the DHCP configuration in one of my routers. I have a range or pool of addresses that is used. This one uses 192.168.1.2 through 92.168.1.254. So anytime you turn on your computer, it will receive an IP address that is somewhere in that range.

However, there are two reservations included as part of that pool that would not be automatically assigned. That’s because we have two devices, one called Prometheus and the other called Odyssey. And you can see the MAC addresses of both of those devices.

If we turn on Prometheus, it will always receive an IP address of 192.168.1.6, and Odyssey will always receive 192.168.1.9. This means that we know that those two devices will always receive the exact same IP address every time we turn on that device. And anyone else on our network that happens to connect will receive any other available IP address from the available pool.