1 00:00:00,030 --> 00:00:01,080 DHCP 2 00:00:01,080 --> 00:00:04,170 or the Dynamic Host Configuration Protocol. 3 00:00:04,170 --> 00:00:07,170 Initially, we used to have to manually provide an IP address 4 00:00:07,170 --> 00:00:08,970 to every machine on our network, 5 00:00:08,970 --> 00:00:10,800 which is not really a big deal in your house 6 00:00:10,800 --> 00:00:12,780 where you might have three or four machines. 7 00:00:12,780 --> 00:00:15,180 But in the large networks I've worked on, 8 00:00:15,180 --> 00:00:17,070 we have hundreds or thousands 9 00:00:17,070 --> 00:00:20,370 or hundreds of thousands of computers and servers on them. 10 00:00:20,370 --> 00:00:22,506 That is a ton of labor hours that we spent 11 00:00:22,506 --> 00:00:25,320 just for configuring all of these devices. 12 00:00:25,320 --> 00:00:27,390 So, someone was really smart 13 00:00:27,390 --> 00:00:31,620 and created an automated way of doing this, known as DHCP. 14 00:00:31,620 --> 00:00:35,040 DHCP was invented to help us with this monumentous task 15 00:00:35,040 --> 00:00:38,010 of configuring all of these servers and workstations. 16 00:00:38,010 --> 00:00:41,160 Now, DHCP also can help eliminate configuration errors 17 00:00:41,160 --> 00:00:43,380 because when a person is entering an IP address 18 00:00:43,380 --> 00:00:45,060 into an end user's device, 19 00:00:45,060 --> 00:00:47,490 there is an opportunity for human error 20 00:00:47,490 --> 00:00:50,310 where they fat finger it and type in the wrong one. 21 00:00:50,310 --> 00:00:52,470 Also, it can be really hard to maintain 22 00:00:52,470 --> 00:00:54,270 a good list of every IP 23 00:00:54,270 --> 00:00:56,970 that every computer is using inside of your network. 24 00:00:56,970 --> 00:01:00,840 So often you can get IP conflicts by assigning the same IP 25 00:01:00,840 --> 00:01:04,440 to multiple machines inside the same network by accident. 26 00:01:04,440 --> 00:01:06,900 With DHCP, none of this will happen 27 00:01:06,900 --> 00:01:07,890 because each device 28 00:01:07,890 --> 00:01:10,860 is automatically going to get assigned an IP from a scope. 29 00:01:10,860 --> 00:01:13,920 Now, a scope is simply a list of valid IP addresses 30 00:01:13,920 --> 00:01:17,040 that are available for assignment or lease to a computer 31 00:01:17,040 --> 00:01:19,740 or an endpoint on a given subnet. 32 00:01:19,740 --> 00:01:21,960 Now, for example, in my home network, 33 00:01:21,960 --> 00:01:26,370 I have 254 IPs available for devices in my scope. 34 00:01:26,370 --> 00:01:29,010 So when the computer joins my home network, 35 00:01:29,010 --> 00:01:31,050 the DHCP server automatically picks 36 00:01:31,050 --> 00:01:34,280 one of these unused IPs from the scope 192.168.1.2 37 00:01:36,417 --> 00:01:40,770 all the way up to 192.168.1.254, 38 00:01:40,770 --> 00:01:43,590 and then it gives that IP to that device to use. 39 00:01:43,590 --> 00:01:45,510 This is known as a lease. 40 00:01:45,510 --> 00:01:47,010 As a network administrator, 41 00:01:47,010 --> 00:01:48,660 you can tell your DHCP server 42 00:01:48,660 --> 00:01:51,480 what IP addresses should be used in your scope, 43 00:01:51,480 --> 00:01:53,970 and you can even reserve some of those IPs 44 00:01:53,970 --> 00:01:55,350 that you don't want to be handed out 45 00:01:55,350 --> 00:01:57,900 as part of what's known as an excluded range 46 00:01:57,900 --> 00:01:59,370 within your scope. 47 00:01:59,370 --> 00:02:01,350 For example, in my home network, 48 00:02:01,350 --> 00:02:03,090 I have a couple of IP addresses 49 00:02:03,090 --> 00:02:05,610 that have been excluded from my DHCP scope. 50 00:02:05,610 --> 00:02:10,410 These are IP addresses in the range of 192.168.1.2 51 00:02:10,410 --> 00:02:14,010 up to 192.168.1.10. 52 00:02:14,010 --> 00:02:16,050 These IP addresses have already been assigned 53 00:02:16,050 --> 00:02:19,140 to some of those things in my network manually by me. 54 00:02:19,140 --> 00:02:21,630 Things like my printer, my network file server, 55 00:02:21,630 --> 00:02:22,890 and other things like that 56 00:02:22,890 --> 00:02:25,890 that I always want to have the same IP address for. 57 00:02:25,890 --> 00:02:27,510 Now, another way you could do this 58 00:02:27,510 --> 00:02:29,700 instead of statically assigning these IPs 59 00:02:29,700 --> 00:02:32,850 is to use something known as a DHCP reservation. 60 00:02:32,850 --> 00:02:35,640 This is very commonly used in large networks. 61 00:02:35,640 --> 00:02:37,290 Now, a DHCP reservation 62 00:02:37,290 --> 00:02:39,420 lets you exclude some of these IP addresses 63 00:02:39,420 --> 00:02:41,130 from being handed out to devices 64 00:02:41,130 --> 00:02:43,440 unless they meet certain conditions. 65 00:02:43,440 --> 00:02:46,110 For example, I could set up a DHCP reservation 66 00:02:46,110 --> 00:02:48,540 from my printer based on its MAC address. 67 00:02:48,540 --> 00:02:50,910 That way, whenever my printer joins the network, 68 00:02:50,910 --> 00:02:53,848 the DHCP server sees that it joins, checks its MAC address, 69 00:02:53,848 --> 00:02:56,610 and then assigns the exact same IP 70 00:02:56,610 --> 00:02:58,650 every single time to that printer 71 00:02:58,650 --> 00:03:00,660 because it's been listed as a reserved address 72 00:03:00,660 --> 00:03:02,700 inside the DHCP scope. 73 00:03:02,700 --> 00:03:04,080 This is a great way to do things 74 00:03:04,080 --> 00:03:05,310 when you have a large network, 75 00:03:05,310 --> 00:03:07,808 instead of having to manually configure each endpoint device 76 00:03:07,808 --> 00:03:10,200 with a specific IP address. 77 00:03:10,200 --> 00:03:12,930 This lets your DHCP server do it for you, 78 00:03:12,930 --> 00:03:16,230 essentially giving it a static address every single time, 79 00:03:16,230 --> 00:03:18,870 but using this automatic configuration. 80 00:03:18,870 --> 00:03:21,450 So with DHCP, we can automate the process 81 00:03:21,450 --> 00:03:24,810 of configuring all of our devices whenever they come online. 82 00:03:24,810 --> 00:03:26,370 When the device joins our network, 83 00:03:26,370 --> 00:03:28,620 it's going to reach out to our DHP server, 84 00:03:28,620 --> 00:03:30,630 and it's going to do what's known as a discovery. 85 00:03:30,630 --> 00:03:33,150 It's going to say, "Hey, DHCP server, 86 00:03:33,150 --> 00:03:35,370 I need to discover an IP address." 87 00:03:35,370 --> 00:03:37,770 This means I need one to be assigned to me. 88 00:03:37,770 --> 00:03:39,307 The DHCP server then says, 89 00:03:39,307 --> 00:03:41,760 "Okay, does this address look okay to you?" 90 00:03:41,760 --> 00:03:44,310 And it offers up an address from the scope. 91 00:03:44,310 --> 00:03:46,650 This is known as the offer phase. 92 00:03:46,650 --> 00:03:48,097 Then the computer is going to say, 93 00:03:48,097 --> 00:03:49,740 "Yeah, I like that address. 94 00:03:49,740 --> 00:03:51,270 I request to take it." 95 00:03:51,270 --> 00:03:53,490 And that's the DHCP request phase, 96 00:03:53,490 --> 00:03:56,100 which is going to be our third step in this process. 97 00:03:56,100 --> 00:03:58,230 Finally, our DHCP server is going to acknowledge 98 00:03:58,230 --> 00:04:00,600 that the IP is now being used by this client 99 00:04:00,600 --> 00:04:03,127 by sending what's known as an acknowledgement and saying, 100 00:04:03,127 --> 00:04:04,920 "Okay, that's your address, 101 00:04:04,920 --> 00:04:07,350 and you can borrow it for this amount of time." 102 00:04:07,350 --> 00:04:10,050 This is known as a DHCP lease. 103 00:04:10,050 --> 00:04:12,450 Now, when we look at this in our home networks, 104 00:04:12,450 --> 00:04:16,140 the default lease time is going to be about 24 hours usually. 105 00:04:16,140 --> 00:04:17,550 For a corporate network, though, 106 00:04:17,550 --> 00:04:19,829 you may choose to use a longer lease time, 107 00:04:19,829 --> 00:04:22,170 something like seven days or 30 days, 108 00:04:22,170 --> 00:04:24,090 depending on your use case. 109 00:04:24,090 --> 00:04:25,620 In the world of cybersecurity, 110 00:04:25,620 --> 00:04:28,260 having devices that are constantly changing their IPs 111 00:04:28,260 --> 00:04:31,170 makes it harder for us to track down when bad things happen. 112 00:04:31,170 --> 00:04:35,490 So in larger networks, we tend to use a longer lease time. 113 00:04:35,490 --> 00:04:39,120 Now, how are you going to remember these four steps at DHCP? 114 00:04:39,120 --> 00:04:42,030 Well, I have a little memory aid or mnemonic for this. 115 00:04:42,030 --> 00:04:44,310 I like to think of "Dora the Explorer." 116 00:04:44,310 --> 00:04:46,470 Dora is D-O-R-A, 117 00:04:46,470 --> 00:04:49,890 and it's discover, offer, request, and acknowledge. 118 00:04:49,890 --> 00:04:51,150 That is our four steps 119 00:04:51,150 --> 00:04:54,960 of configuring a device on a network using DHCP. 120 00:04:54,960 --> 00:04:56,820 Now, when the device gets a configuration 121 00:04:56,820 --> 00:04:58,200 from our DHCP server, 122 00:04:58,200 --> 00:05:00,630 it isn't just getting that IP address though. 123 00:05:00,630 --> 00:05:03,750 Instead, it's going to get four key pieces of information. 124 00:05:03,750 --> 00:05:06,360 This is the IP address, the subnet mask, 125 00:05:06,360 --> 00:05:09,390 the default gateway, which is the IP address of our router, 126 00:05:09,390 --> 00:05:11,880 and the IP address of the DNS server, 127 00:05:11,880 --> 00:05:15,060 so your client knows how to do a DNS name lookup. 128 00:05:15,060 --> 00:05:16,920 Once your client has these four pieces 129 00:05:16,920 --> 00:05:18,300 of information configured, 130 00:05:18,300 --> 00:05:20,280 that client can now get online, 131 00:05:20,280 --> 00:05:21,450 get out of your network, 132 00:05:21,450 --> 00:05:23,760 and get onto the internet because it now knows 133 00:05:23,760 --> 00:05:26,280 where it is on the network with its IP address, 134 00:05:26,280 --> 00:05:28,680 where the router is with that gateway address, 135 00:05:28,680 --> 00:05:31,620 and how to convert the domain names to IP addresses 136 00:05:31,620 --> 00:05:34,110 using that DNS server's IP. 137 00:05:34,110 --> 00:05:36,180 Now, I mentioned the fact that we use DHCP 138 00:05:36,180 --> 00:05:38,640 to dynamically assign our configuration needed 139 00:05:38,640 --> 00:05:40,350 for our devices to get online, 140 00:05:40,350 --> 00:05:42,191 but we can also do this manually, 141 00:05:42,191 --> 00:05:44,970 which is known as a static assignment. 142 00:05:44,970 --> 00:05:46,800 You see, when we do it dynamically, 143 00:05:46,800 --> 00:05:50,010 we let DHCP servers do the configuration for us, 144 00:05:50,010 --> 00:05:52,770 but you can also statically assign the configuration 145 00:05:52,770 --> 00:05:55,140 if you provide all four pieces of information 146 00:05:55,140 --> 00:05:56,700 to your client device. 147 00:05:56,700 --> 00:05:58,650 Now, again, in most large networks, 148 00:05:58,650 --> 00:06:01,050 you wouldn't want to statically assign the information, 149 00:06:01,050 --> 00:06:02,593 but instead you're going to want to use 150 00:06:02,593 --> 00:06:04,800 a DHCP reservation to do it. 151 00:06:04,800 --> 00:06:07,200 But in your home network or a small network, 152 00:06:07,200 --> 00:06:09,720 you may want to statically configure things. 153 00:06:09,720 --> 00:06:12,000 Now, if you need a statically configured device, 154 00:06:12,000 --> 00:06:14,190 be sure you double check everything you've entered 155 00:06:14,190 --> 00:06:16,230 for all four pieces of information. 156 00:06:16,230 --> 00:06:18,210 The IP address, the subnet mask, 157 00:06:18,210 --> 00:06:21,390 the default gateway, and the DNS server's IP. 158 00:06:21,390 --> 00:06:22,560 If you're troubleshooting a device 159 00:06:22,560 --> 00:06:24,120 that's having connectivity problems, 160 00:06:24,120 --> 00:06:26,160 you should check if it was statically configured. 161 00:06:26,160 --> 00:06:28,530 And if it was, you need to verify the IP address 162 00:06:28,530 --> 00:06:31,230 and the subnet mask are configured correctly 163 00:06:31,230 --> 00:06:33,660 because this is often the source of your problems. 164 00:06:33,660 --> 00:06:34,530 So at this point, 165 00:06:34,530 --> 00:06:37,620 we've talked about dynamic assignment and static assignment. 166 00:06:37,620 --> 00:06:39,300 Now, when we use a dynamic assignment, 167 00:06:39,300 --> 00:06:42,103 what happens if a device can't reach the DHCP server 168 00:06:42,103 --> 00:06:45,420 or it fails to receive a proper configuration? 169 00:06:45,420 --> 00:06:46,860 What should that device do? 170 00:06:46,860 --> 00:06:48,450 Should it just keep asking? 171 00:06:48,450 --> 00:06:50,760 Well, no, because then it's just going to sit there 172 00:06:50,760 --> 00:06:52,470 forever getting hung up. 173 00:06:52,470 --> 00:06:56,100 So instead, we need to have an alternate configuration. 174 00:06:56,100 --> 00:06:58,260 Whenever you're configuring DHCP, 175 00:06:58,260 --> 00:07:00,300 if DHCP is not successful 176 00:07:00,300 --> 00:07:01,740 and it's not able to negotiate its way 177 00:07:01,740 --> 00:07:04,350 through the DORA process for whatever reason, 178 00:07:04,350 --> 00:07:06,750 it's going to default to its alternate configuration 179 00:07:06,750 --> 00:07:08,400 that's set by the system administrator 180 00:07:08,400 --> 00:07:10,350 inside the operating system. 181 00:07:10,350 --> 00:07:12,870 By default, this is going to be set to use what's known 182 00:07:12,870 --> 00:07:16,020 as an APIPA address, APIPA, 183 00:07:16,020 --> 00:07:19,080 which is Automatic Private IP Address. 184 00:07:19,080 --> 00:07:21,990 Now, as a network administrator or a system administrator, 185 00:07:21,990 --> 00:07:23,580 you can also configure your device 186 00:07:23,580 --> 00:07:26,310 to fall back to a known good static IP address 187 00:07:26,310 --> 00:07:29,760 as your alternate configuration instead if you prefer. 188 00:07:29,760 --> 00:07:32,010 Now, when you're configuring your DHCP server, 189 00:07:32,010 --> 00:07:35,160 one of the things you can configure is your scope options. 190 00:07:35,160 --> 00:07:37,710 This allows you to configure a bunch of different things, 191 00:07:37,710 --> 00:07:39,720 but the most common are the subnet mask 192 00:07:39,720 --> 00:07:41,610 that is going to be applied to all the devices 193 00:07:41,610 --> 00:07:43,290 requesting that configuration, 194 00:07:43,290 --> 00:07:46,350 the default router or gateway that these devices should use, 195 00:07:46,350 --> 00:07:47,880 and the DNS server 196 00:07:47,880 --> 00:07:50,730 to include the IP address configuration for those devices, 197 00:07:50,730 --> 00:07:53,370 as well as the lease time for the IP address. 198 00:07:53,370 --> 00:07:54,240 Now, as you can see, 199 00:07:54,240 --> 00:07:57,090 we've already discussed all of these things in this lesson, 200 00:07:57,090 --> 00:07:59,370 but I wanted to bring this up so you're aware 201 00:07:59,370 --> 00:08:00,930 that you can change and configure them 202 00:08:00,930 --> 00:08:04,890 as part of your scope options inside your DHCP server too. 203 00:08:04,890 --> 00:08:06,300 Another unique configuration 204 00:08:06,300 --> 00:08:08,400 you need to make for DHCP in your network 205 00:08:08,400 --> 00:08:10,980 is the use of a DHCP relay. 206 00:08:10,980 --> 00:08:14,610 Now, a DHCP relay is any host that forwards DHCP packets 207 00:08:14,610 --> 00:08:16,530 between clients and servers. 208 00:08:16,530 --> 00:08:19,590 Now, really, the only time you're going to need a DHCP relay 209 00:08:19,590 --> 00:08:22,020 is when the client device and the DHCP server 210 00:08:22,020 --> 00:08:24,990 are not located on the same subnet or network. 211 00:08:24,990 --> 00:08:26,040 In this case, 212 00:08:26,040 --> 00:08:28,680 instead of installing a DHCP server on every subnet 213 00:08:28,680 --> 00:08:30,840 or mini network inside of your network, 214 00:08:30,840 --> 00:08:34,440 you can configure one device to act as the DHCP relay, 215 00:08:34,440 --> 00:08:37,169 and that way you can save yourself a lot of effort. 216 00:08:37,169 --> 00:08:39,330 This device will listen for discovery requests, 217 00:08:39,330 --> 00:08:42,179 and then forward that request to the DHCP server 218 00:08:42,179 --> 00:08:44,610 on the other network on behalf of your client, 219 00:08:44,610 --> 00:08:46,950 acting essentially as a middleman. 220 00:08:46,950 --> 00:08:49,110 Another unique thing about DHCP 221 00:08:49,110 --> 00:08:53,190 is that it operates using the User Datagram Protocol or UDP. 222 00:08:53,190 --> 00:08:54,240 For this reason, 223 00:08:54,240 --> 00:08:57,300 it is a fire and forget method of sending data. 224 00:08:57,300 --> 00:08:59,490 To help the data get to where it needs to go, 225 00:08:59,490 --> 00:09:00,570 you may need to configure 226 00:09:00,570 --> 00:09:03,810 what's known as an IP helper address on your router. 227 00:09:03,810 --> 00:09:05,010 The IP helper address 228 00:09:05,010 --> 00:09:06,660 is used to forward several different kinds 229 00:09:06,660 --> 00:09:09,240 of UDP broadcasts across the router 230 00:09:09,240 --> 00:09:12,330 and can be used in conjunction with the DHCP relay 231 00:09:12,330 --> 00:09:13,920 that we just talked about. 232 00:09:13,920 --> 00:09:15,927 Remember, if the DHCP client and server 233 00:09:15,927 --> 00:09:18,000 are on different network segments, 234 00:09:18,000 --> 00:09:20,070 the router on the client's network segment 235 00:09:20,070 --> 00:09:22,500 has to be configured with an IP helper address 236 00:09:22,500 --> 00:09:24,390 for DHCP to work properly 237 00:09:24,390 --> 00:09:27,303 and forward those requests over to the DHCP server.