1. Introduction
Section, you’ll learn about Cisco support for DHCP. DHCP is the Dynamic Host Configuration Protocol, and it’s a way that we can automate assignment of IP addresses on our host. It’s much quicker to use DHCP and more convenient than it is to manually assign IP addresses to everything. In this section, I’ll show you how to configure a Cisco router to be a DHCP server. You’ll also see how to configure the router to support an external DHCP server. And finally, I’ll show you how a Cisco router can be a DHCP client itself and get its own IP address via DHCP. Okay, so let’s go with the DHCP.
2. DHCP Dynamic Host Configuration Protocol
In this lecture, you’ll learn about DHCP, the dynamic host configuration protocol. It’s a client server protocol that automatically provides a host with its IP address and other related configuration information like its subnet mask and default gateway. The DHCP clients obtain their IP configuration information from the server rather than being being manually configured. So this can save you a lot of legwork if you look on my PC here. Let’s look at how to manually configure an IP address. This is on a Windows host. So in control panel. I’ll go to the network settings. I’ll find my network card, go to the proper Is, and then the Internet Protocol version four.
So the IPV Four Proper is and in here I can see that it’s selected to obtain an IP address automatically. That means that my laptop is currently a DHCP client. If I wanted to manually set an IP address on here, I could choose the other radio button to use the following IP address and manually type in an IP address, subnet mask, default gateway and DNS Server. But I don’t want to do that. I want it to automatically receive it from the DHCP server. So I will just cancel out of here. How DHCP works is the client sends a DHCP Discover message which is broadcast traffic. The DHCP server will then reply back with a DHCP offer, but it’s not completed yet. The client will then reply back with a DHCP request, and then finally the DHCP server sends a DHCP acknowledgement.
At that point, the client will have its IP information like the IP address, et cetera. So the benefits that we get from using DHCP, well, I just showed you there a minute ago about how we can manually configure an IP address. Imagine if you worked in a large campus where you had 5000 hosts there. It would obviously be super inconvenient to physically walk around all 5000 hosts and manually configure them with an IP address. Also, if you did that, it’s very likely on some of them you would accidentally make a misconfiguration like a typo, or accidentally enter some duplicate IP addresses. But using a DHCP server, that gives you centralized and automated IP configuration in that one central location, and you know that you’re not going to have any mistakes happening. Much easier than manually assigning an IP address to all your individual hosts.
You can also add additional IP configuration values by using DHCP options. For example, if you’re using IP phones in your office, they need to learn where their server is. That’s their TFTP server. Well, you can give them that information using DHCP.
It gives efficient handling of clients that must be updated frequently, such as laptops that move to different locations on a wireless network in your campus. Different physical areas of the network are going to have different IP subnets and different VLANs. It would be really inconvenient if you had to manually change the IP address on your laptop every time you move to a different location in the network. By using DHCP, the laptop will automatically be updated with a correct IP address. And lastly, the forwarding of initial DHCP messages. By using a DHCP, really agent eliminates the need for a DHCP server on every subnet. So in a large campus where you do have multiple subnets, you don’t need to do a DHCP server on every single one.
You’ll have one centralized DHCP server, maybe two for redundancy, and they will have different scopes for the different subnets. And whenever a client comes online, it will automatically be given an IP address for the correct subnet. You’ll see how that works later on in this section. So we mentioned earlier that you have all of those benefits of it being more convenient using a DHCP server. It also stops you from accidentally putting in a typo or configuring duplicate IP addresses. The kinds of clients that will be DHCP clients. Well, desktop PCs and laptops are good candidates to be DHCP clients because typically you’re going to have a lot of those in the office. You don’t want to have to manually go and configure them all. Using DHCP saves you having to do that.
And your normal desktop PC, it will make outgoing connections to the Internet and to other internal hosts, other internal servers in your network. But it’s not going to be taking direct incoming connections. You’re not running any services on there, so you’re never going to have somebody outside it directly connecting to that host. So it doesn’t need to have a fixed IP address. It doesn’t matter if the IP addresses changes over time. And that can happen with DHCP. Your servers and network infrastructure devices, on the other hand, like your routers, your switches, and your firewalls, are not good candidates to be DHCP clients. They’re mission critical devices that are required for the running of the network and for its services to function. Their IP addresses are going to be fixed.
They have to stay the same because they’re going to be accepting incoming connections. So you’re going to manually configure them to make sure that they never change. And also, you don’t want them to be reliant on the DHCP server to be up and running. Okay, so that was an introduction to DHCP. In the next lecture, we’ll start talking about what our different options are to actually implement this.
3. Cisco DHCP Server
In this lecture, you’ll learn about the first option for configuring a DHCP server, which is using a Cisco router. You’ve already got two main options for your DHCP server. You can use a Cisco router or you can use an external server, which is probably going to be running on Windows or maybe Linux or Unix. So we’ll take a look at the first option here, which is used using a Cisco router. If you’re going to do this, it’s most likely to be a small network, like a branch office, where you don’t want to go to the expense of putting in a dedicated server to act as your DHCP server.
You’re already going to have a Cisco router in that office anyway for doing the routing. So you can also use it as the DHCP server as well, and there’s not going to be any additional cost to do that. So we’re going to have a look at this in the lab in a second. In our scenario, we’ve got small branch office, we’ve got R One there which is configured with IP address 1010 124 on its Fast Ethernet One interface, and there are DHCP clients on that network that it’s going to give IP addresses to. So we need to configure a DHCP pool for the 1010 O 24 subnet. We’ve also got a DNS server in the office as well at IP address 1010 2010, and we also want to give the client PCs that information as well.
So the commands to configure this first off, we’re going to specify our excluded addresses. Typically in a subnet. You might have some hosts there that you’re going to want to have a fixed IP address, for example, printers, or the router itself, other network infrastructure devices. So usually you’re not going to give out every single address in the entire IP subnet. For DHCP clients, you’re probably going to have a few addresses that are reserved. You’ll usually have reserved addresses either at the start of the scope or at the end of the scope. For example, one to ten or 248 to 254. In that example here, we’re going to exclude addresses one to ten from the DHCP scope.
And it’s a good idea to put this command in first before you configure the DHCP scope, so that way clients won’t get them before you exclude them. So the command to do this is a global configuration IP DHCP excluded address, and then the starting IP address ten one for our example in minutespace, and then the ending address in the range 1010. So one to ten will not be given out to clients. We then need to configure our DHCP pool. So again, at global config we say IP DHCP pool, and for our example, I’ve called it 1010 or underscore clients, but you can call it anything you like. We could have called it IP DHCP pool, Mickey Mouse if we wanted to. That will then take you to your DHCP configuration the next command, we say network 1010 or space 255-255-2550. That’s where we specify the IP range of addresses that we’re going to be giving out, and also the subnet mask as well. So clients will be given an IP address from this range and that subnet mask, and the addresses will be given out on a first come, first serve basis. Next command default router 1010 one to tell the clients where their default gateway is. And finally we’ve said DNS server 1010 2010 to also tell them where the DNS server is. So that’s our configuration. To verify it. We can say show IP DHCP pool. And for our example, here you can see the only addresses is two. So we have given out two addresses in this range to see the addresses that were given out and who they were given out to, we can say Show IP DHCP binding. And here I can see that ten 1011 was given out to the client with Mac address ending D 1116. And then ten 1012 was given out to the client with Mac address ending a three five nine. So you can see it started giving out addresses starting with eleven because we’d excluded 1210.
Okay, so that’s it. Pretty simple configuration. And for the lab demo, we’re going to use that exact scenario again. So we’ll configure r one. We’ll configure it with a DHCP scope for the 1010 O subnet. So let’s go on to R one. You can see I’ve already got my interfaces configured there. I’ll go to Global Configuration. I want to exclude the addresses first that I don’t want to give out so that’s IP DHCP excluded address 1010 one to 1010. Then I configure my pool. So I say IP DHCP pool. I’ll call this one demo and then the network that I want to be assigning addresses for. So ten 1010 or 255-25-5255, or the default router is this router itself at ten 1010 one. And I also want to specify the DNS server, which was at 1010 2010. Okay, so that’s it all configured.
And then to verify it, I can do a Show IP DHCP pool. Let’s see if the clients have taken their IP addresses yet. Looks like they have. Two of them have been leased to verify Show IP DHCP binding. And there I can see that my two clients have picked up their IP addresses from DHCP. The first one got eleven and the second one got twelve. So that’s how you configure a Cisco router to be a DHCP server. In the next lecture, we’ll look at how to configure the Cisco router to support an external DHCP server.
4. External DHCP Server
In this lecture, you’ll learn about how to configure a Cisco router to support an external DHCP server. So you learned in the last lecture, for small branch offices, we’ll often configure our Cisco router as a DHCP server to save buying an external router. But in larger offices where we’ve got several subnets, then typically we’ll have an external DHCP server. There maybe two of them for redundancy as well. So that’s what we’ve got in the example here, we’ve got an external DHCP server, we’ve got the same topology as the last lecture. So I’ve got R One, and our PCs are in the 1010 subnet. But we’re not going to configure a DHCP scope on R One here. The DHCP requests are going to be served by our DHCP and DNS server, which is at 1010 2010.
But we’ve got a problem here, so let’s see what the problem is. So PC Two gets powered on, doesn’t have an IP address yet, so it’s configured as a DHCP client. So it sends out a DHCP request that is broadcast traffic. It hits the switch and the switch will forward it out all parts apart from the one it was received on because it’s broadcast traffic. So it will hit PC One. It’s not a DHCP server, so it will silently discard the packet and it will hit R One. And it’s not a DHCP server either. The problem is that R One is a router, and routers by default, do not forward broadcast traffic. So R One will not send that DHCP request out onto the 1020 subnet, so it will never reach the DHCP server and PC Two will not get an IP address.
So that’s the problem. And the fix for this is we need to configure R One to forward DHCP requests. The way we do this is we configure it on the interface, which will be receiving the DHCP request. So in our example here, the interface and R One, which is facing the clients is Fast One. So we go to the configuration for interface Fast One, and we say IP helper address 1010 2010. Now whenever the router receives a DHCP request on that interface, it will forward it to the DHCP server at 1010 2010.
And now our clients will be able to get IP addresses. So that’s how we configure a Cisco router to support an external DHCP server. Let’s have a look at actually configuring this in the lab. So I’m running this in packet tracer because Packet tracer supports a DHCP server. If we have a look at the config on our DHCP server, if I go to the Services tab on here and choose DHCP, you can see I’ve configured a DHCP scope for the ten 1010 network I’ve specified. The default gateway is at one and the DNS server is at 1010 210. And I’m going to give out addresses in that subnet starting with ten dot, ten dot, ten dot 100 with a slash 24 subnet mask. So my DHCP server is all set up and configured if I haven’t looked at the config on the PC. So I’ve gone into PC One here and if I look at the config for its interface, I see that it’s configured as a DHCP client.
But if I open up a command prompt on here and do IP config, you can see that it is not getting a valid IP address. That is because the DHCP request is not reaching the server. So to fix this, I need to go onto the router. I’ll go into the command line here and I want to go to Global configuration and then it’s interfacefast zero one, the interface facing the clients. And I say IP helper address. Let me just expand this out. So IP helper address. And my DHCP server is at 1010 2010. That’s it all that I need to do. If I now go back onto the PC and I do an Ipconfigrenew, then hopefully it’s going to be able to pick up the IP address now. And you can see, yes, it has. It’s been given the first address in the scope that would address 1010 100. It’s also received its default gateway and its DNS server. So that’s how you configure a Cisco router to support an external DHCP server.
5. Windows, Mac and Linux client IP settings
This lecture, you’ll learn how to configure and verify the IP settings on Windows, Mac and Linux clients. I’ll start off with Windows. And I’m on my Windows laptop here, and I’ve got Windows File Explorer open. This is what I find to be the quickest and most convenient way to open the network settings. There are other ways you can get there, such as just going through Control Panel, but the way I like to do it is in Windows File Explorer. I will right click on Network and then choose Properties, and then I’ll click on Change Adapter Settings and then I’ll see all of my network cards here. I’ve got a lot of network cards on my laptop because I’ve got a lot of virtual cards because I’ve got VMware installed.
I’m plugged in with an ethernet cable right now on this interface here and if I wanted to configure the settings, I’ll right click on that and choose Properties. And then in here you can see that I can set my IP settings for both IPV Four and IPV Six. So let’s click on IPV Four and then go to Properties and you see that it defaults to obtaining an IP address automatically, which means that by default it is a DHCP client. All of the client desktop operating systems will default to being DHCP clients. If I wanted to configure a manual fixed IP address on here, I would just tick the radio button to use the following IP address and in there I would enter my IP address, subnet mask and default gateway and I would also configure my DNS server in here as well.
But I want to leave this as a DHCP client so I’m going to select that notice in here in the GUI. It does not actually tell me what the IP address is. So to find the IP address, what I’m going to do is open up a command prompt. So I’ll go up the search bar and type in CMD to open up a command prompt and the command is IP Config. Now, IP Config will show you the main information, but normally you want to do an IP config all because this will show you extra information such as the Mac address on your network cards also what the IP address of your DHCP server is. So I’ll enter that I’m getting loads of output because I’ve got so many network cards in here. So I’m just going to scroll all the way back up to the top again. And in here you can see there is the IP address, there’s the subnet mask, and there is the default gateway. I can also see other information in here such as the DNS servers, the IP address of my DHCP server, et cetera.
Okay, so that’s how you set your IP address in Windows and also how you verify it with the IP config command. Next up, let’s have a look at Mac. So I’ve got my macOS open here to configure your IP address and Mac go up to the top left, click on the apple icon here and then select System Preferences and then click on Network. And then you’ll see with Mac it’s a little bit different than Windows that the GUI will actually tell you directly in here what your IP address is. Again, it’s using DHCP by default and I can see my IP settings in here. If I wanted to change this to be a manually set IP address, I just click on the drop down and I would choose manually in there and then that gives me the option to enter my IP information. If I want to check this at the command line, then what I do is just open up a terminal and in Windows it was IP config in macOS and in Linux, as you’ll see in a second, it’s if config for the interface. So enter if config and in there I can see syncing information as I saw on Windows, my IP address, subnet mask, et cetera. This does not actually show me the default gateway. So to get that, what I do is a Netstat and then R for route and N for numerical to see it in IP address format and hit Enter. And then in there I can see there is my default route and there is my default gateway.
Okay? So in Mac it was Fconfig to see the IP address and subnet mask and the Netstat RN to see the default gateway. Okay, last one. Let’s have a look at Linux as well. So I’ll go on to my Linux machine here and then to configure your IP address on Desktop Linux. So I’ve got Ubuntu desktop running on here, which has got a Gui running on it by default, a graphical user interface. I can click on the Show applications in the bottom left here. Then I’ll click on Settings and then click on Network and I can see my network interface cards here. To configure it I click on the Settings icon and then I can see the settings in there on the Details tab so that’s where I can see my IP address information.
To change it I click on the IPV Four tab again, it defaults to DHCP and I could click on the Manual radio button here and configure my IP address, subnet mask, default gateway, etcd. Okay, that’s where you can configure it if you want to verify it at the command line, then go through the applications again and then open up a terminal window. And on older versions of Linux. You’ll still see this on a lot of distributions. The command to use is ifconfig, the same as it was on Mac. You’ll actually see that I’m running a newer version of Ubuntu desktop here, which is why, if Config is not installed by default, I could install that if I wanted to, just by running this command here. But I’ll show you what the new command is, and that is IP Address Show. And in there I can see there is my IP address, and I can see it’s a Slash 24 subnet mask. This doesn’t show me my default gateway to see that it is IP Route Show.
And there I can see my default gateway is 109 216811. Okay, so the older command is if config the newer commands IP Address show and IP Route show. So that was how to configure and verify your IP settings on Windows, on Mac, and on Linux. See you in the next lecture.
6. Cisco DHCP Client
In this lecture you’ll learn how to configure a Cisco router as a DHCP client. And you may be thinking, hang on a minute, neil, you just told me a minute ago that our routers don’t get configured as DHCP clients, they get configured with manual IP addresses. And that is typically what will happen. But there is one fairly common exception to that rule. That’s where a branch office is connected to the Internet, but it hasn’t bought any static public IP addresses for that office. That would be because the branch office doesn’t contain any publicly available servers that need a fixed public IP address for incoming connections. So the companies decided we’re not going to pay for a range of public IP addresses. They are fixed addresses because we don’t need them.
In that case, the office is still going to require at least one public IP address to allow the internal hosts outbound connectivity to the internet though, and it’s going to use Nap for that that we spoke about in an earlier lecture. We’re going to cover it in more detail in a later section as well. So in that case, you’re going to be having just that one public IP address, but you haven’t paid for a fixed IP address. So the router is going to need to get that public IP address on its outside interface using DHCP from the Internet service provider. The other inside interfaces on the router will have fixed IP addresses. It’ll just be that outside interface facing the service provider that is going to be a DHCP client.
So our configuration to support that is on the outside interface. In our example here, it’s interface fast. We just say IP address DHCP rather than the usual IP address and then the actual IP address. And because it’s a router, remember, we have to no shut down the interface. So that’s simple configuration to support an interface as a DHCP client to get information about the DHCP lease it showed DHCP lease. So an example here we can see that we were given IP address 203 1132 by the provider.
We can also see the DHCP lease server. That’s the server that gave us the IP IP address and it is at 203 one. Okay, so that’s how we do the configuration. Very simple. Let’s have a look at this in the lab. So I’m running packet tracer again here and I’ve already configured the service provider router as a DHCP server. The outside interface on R One is currently unconfigured. So I’m going to configure that as a DHCP client. So I go onto R One and enable config t to get to global configuration. And I’m going to go to interfacefastero IP address DHCP and no shutdown and it will take a minute and then I should see it picking up the IP address and the interface going live in packet trace that I’ll know. It’s happened when both sides of the link go green. So I’ll just waffle for a second while I wait for that. Actually, let’s do a Show DHCP lease now, see if it’s picked up anything yet. And it’s zero. So it hasn’t got the DHCP address yet. I just saw in packet tracer that both sides went green.
So if I repeat that Show DHCP lease command, I now see okay. It still hasn’t got the IP address. Okay. And there we go. It does take a while, but after a minute or so, I see a log message that the DHCP address was assigned on fast zero zero. It was given IPRs two, three, dot O dot one one, three, dot two. I can do my Show DHCP lease again. And I see there’s the address two or three dot one one, three dot two, which was given by 20 three dot O dot one one, three dot one. And if I do a Show IP interface brief, I can see that for fast ethernet zero, the method is DHCP. And the address is 203 dot 1132. Okay, so that was it. That’s the DHCP section completed. See you in the next.