DHCP assigns local IP addresses withing a local area network (LAN). This video details the process of handing out IP addresses.
Hi I’m Peter in this video I’ll show you where a computer gets its local IP address from now usually something called the dynamic host configuration protocol will automatically take care of that for you it hasn’t always been this way though let’s have a look at a world before DHCP was invented in our example Network every host will have an address that starts with one ninety two dot one sixty eight dot one at the center of our network we have a router that is wired up to two hosts the common way to assign addresses would be to give our router the dot one address and to give the host the dot two and dot three addresses respectively if someone accidentally gave the same IP address to both computers we’d have an IP conflict on our hands now I don’t know if you’ve ever shared a street address with another house but that’s bound to lead to all sorts of misunderstandings grant it that’s in a small manageable network but what about for laptops maybe throw in a couple of smart phones at a tablet phone hybrid a smart TV to watch YouTube on a Wi-Fi enabled printer and a washing machine that sends a notification to your phone when the laundry is ready oh don’t give me that weird look it’s inevitable look I don’t event these things but this is a mess and we need a system instead of keeping track of all those IP addresses manually why not let DHCP do all the math for you before we cover the technicalities of the algorithm here’s the simpler bird’s eye view jumping back to the previous example the second computer has just joined the network at this point it doesn’t have an IP address but it wants one first our new host will send a message asking for an IP address the router will respond to this request with an offer the new host will accept the offer and finally the router will confirm that the IP address is now assigned to the host from this point forward it is known as one ninety two dot one sixty eight dot one three now that you get the gist of it it’s time to look at DHCP s four-step process in a little more detail DHCP has two requirements one of which being a server you’ll need at least one DHCP server on your network but routers usually have one built in secondly every host on the network needs to run a DHCP client there are ways to run DHCP alongside static IP addresses in your network but let’s not overcomplicate things right now and leave that aside here’s our trusty old network again we have a router set up at dot one and we have a host set up at dot two let’s consider what happens when a new host appears step one of the process is the DHCP Discoverer step this is where the host searches for any available DHCP servers to get an address from since the host does not know where our DHCP server is it will just send out a discover request to everyone on the network this is called broadcasting to put it in human language the new machine asked everyone for an address since our new host does not yet have an IP address the sender field of this packet will be set to 0 the receiver field will be set to 4 times 255 which will cause the packet to be broadcast over the current network one last thing about ports before we move on UDP port 68 is reserved for DHCP clients UDP port 67 on the other hand is reserved for DHCP servers step two involves the server’s offering an IP address to the new host the way they do this is by broadcasting their offered to everyone on the current network the reason that they broadcast this information to everyone is that they don’t know where to find the new host a typical DHCP offer message will say something like I’m willing to give you this address for that amount of time the center will be the DHCP server and the receiver will again be the broadcast address note how the ports were flipped so the sender is the UDP port 67 which is the server port and the receiver is port 68 which is the client port moving on to step number three at this point the host has received at least one offer for an address and it now gets to pick which one at once after having done so it will send out a DHCP request message to everyone on the network once again this is a broadcast and in this message it will say which address it picked with this DHCP request message the host expresses its intention to accept a specific offer in this specific example the host wants to claim one ninety two dot one sixty eight dot one dot three for 3,600 seconds which of course is equal to one hour once again the sender field says zero because we don’t have an address yet you should also take note of the ports that are used here we’re doing 68 to 67 which is client to server we’re down to the fourth and final step now this one’s called DHCP ACK where the accents for acknowledgment in this step the DHCP server will confirm to the host that it can start using the address like in all other steps this message will also be broadcast loosely speaking a DHCP ACK message will confirm that the host can start using the address for the previously specified amount of time as is the case with DHCP offer messages the server will put its IP address into the sender field and use port 67 and 68 as the sender and receiver after the host receives confirmation the process is complete now the host can start using a shiny new IP address now before we wrap up there are a few more things you might want to know about as I said earlier you need at least one DHCP server on your work but you can also have multiple when you have multiple servers they can all respond with an address offer whenever this happens the new host will be allowed to choose from any of the offers it received it will announce its choice using a DHCP request message like we saw in step 3 there’s always the possibility that two new hosts start asking for IP addresses simultaneously so how can we keep them apart the answer is relatively simple DHCP uses transaction IDs to keep track of ongoing procedures and to distinguish them from one another you may remember that addresses expire after a certain amount of time well that mechanism was invented to recycle unused IP addresses so that others can use them again hosts can prevent the server from taking away their IP address by renewing the lease we won’t cover that procedure here but just remember that this is the reason why your computer’s IP address doesn’t suddenly change for no apparent reason alright that’s it for DHCP if there’s anything you’d like to see explained here let me know in the comments thanks for watching see you next time
0 Comments