Covers the full process of configuring a Cisco IOS DHCP server on a Layer 3 switch, including address exclusions, pool creation, and client verification. Demonstrates how to assign a management VLAN scope with a default gateway, DNS server, lease duration, and domain name.
Configuring DHCP on a Switch
I am already on switch one, so let's start configuring it. I am going to configure my management VLAN, so that is VLAN 10, 10.1.10.0. That is the VLAN that I am going to configure to be DHCP.
The first step that I need to do is exclude the addresses that I don't want it to hand out. I want this network to have DHCP enabled, but I want to exclude these ranges.
First of all what I need to do is get into global configuration mode. The command I am going to use is ip dhcp excluded-address, and then it is going to be the first address of the range I want to exclude.
On my networks what I like to do is keep a big buffer at the beginning and a big buffer at the end. The big buffer at the beginning is for things like servers or printers, things that I am going to statically assign in that network. The buffer at the end is a range that I can use, that I can randomly choose one of those IP addresses to assign to a machine statically, just in case I need to assign something statically and temporarily to a machine for troubleshooting.
So I am going to start out with that beginning range, which is 10.1.10.1, space, so that is the first IP address that I want to block out, to the last, 10.1.10.50. That is the range that I want to block out at the beginning, so I am going to hit enter.
Then I am just going to use the up arrow and we are going to adjust this. I like a significant buffer at the end as well, so I am going to do everything to .254, that whole last block of addresses right there, so I am going to exclude those. There we have excluded those addresses.
The next thing that we are going to do is create the scope, and we give it a scope name. So what I am going to do is type in ip dhcp pool and give it a name, and we'll call this VLAN DHCP.
If you notice, the prompt here is dhcp-config, so now we are in a different sub menu of this. I am in the pool and I am configuring the pool.
Now I need to give it the network address, so I am going to type in network and the network address is 10.1.10.0. That is the network address for this, and then I need a mask, so 255.255.255.0. This is a slash 24, and then I'll hit enter, and now I have given it the scope, the IP address network there.
Next, I do want this to be able to communicate on this network and outside the network, so I need the default gateway. For the default gateway I'll do default-router, space, and it is going to be 10.1.10.1. That is the IP address of the VLAN 10 interface on switch one, because this switch right here is the default gateway. So I have got the default router, I'll hit enter on there.
The next one I am going to do is a DNS server, so dns-server. I don't have a DNS server set up right now, so I am just going to point at 8.8.8.8, and that is a DNS server that does actually work. So 8.8.8.8, I'll hit enter on that. I could actually put multiple; it is typical that you would put in two DNS servers.
Next I am going to set the lease, so I can set the days, and in this case right here we are going to go zero days. And then the hours, actually, let's do, just to make it interesting, let's do one day 12 hours. You can see I can keep going, I can set the minutes; I don't need to get that granular, I think just one day and 12 hours is fine, then they get it for a little over 24 hours. So I am going to hit enter right here, and now we have set the lease time on there.
And then one that many networks set is the domain name, so it has a domain name. This allows you to not have to type in the fully qualified domain name every time you want to reach a resource on the network. What I like to call my LANs is andy.land, so I'll name this domain name andy.land, and I'll hit enter on that. And then I have got my pool assigned here, so I am going to hit end on there.
Now some things that I can do to take a look at my settings: there are some show commands that I can do to see how it is functioning and how it is working. The first show command that we'll do is just the standard show run. I can hit enter and we can take a look at what it looks like in the running config. We have those exclude statements, and we have got the pool right here, the name of the pool and the information on the pool, so no big surprise there.
Next what I am going to do is hit Ctrl+C to break out of that, and then I am going to do show ip dhcp binding. This is going to show what IP addresses it has handed out and the hardware address that it has handed them out to. There is nothing here at this point in time because there are no clients that are on this network.
And then another thing I'll do, which for the same reason is not going to be terribly exciting, is show ip dhcp server statistics. You can see the different information, there is one address pool, and how much different information is received on this.
One note before we jump into the client side. I am just going to go into my global configuration mode, and if I want to turn this service off altogether, and if you are not running it you want it turned off, you can type in no service dhcp and this will shut the service off. Or if you want to turn it back on, you just remove the no, and then service dhcp will turn the service on.
Let's jump onto the client and see what the client looks like from that perspective. I am going to open up the network properties of this client machine, and what I always like to do is go down to this change adapter options. It is not quite as fancy as the new interface, but I find that I can do a few more things in it and it is what I am used to.
So I am going to go to this ethernet and right click on the ethernet. It is the Ethernet 1 that I want, not the Ethernet 2, that's the one I am looking at. And it is the Internet Protocol Version 4, so I am going to click on the properties of that, and I am going to switch this to obtain an IP address automatically. So I'll do that, and now the DHCP client is going to work. It disconnects me from my switch because it loses its IP address, and now it is trying to look, you can see, identifying, it is trying to look for a new IP address.
I am going to close out of these windows here and let's bring up the command prompt and see what happens. I am going to do an ipconfig, and look at there, we have the DNS suffix, so that is the domain that I entered in. There we have an IPv4 address here, 10.1.10.51, we have got the subnet mask, and we got the gateway, so everything is looking like we want it to.
I can also do an ipconfig /all to take a look at the DNS server, which is 8.8.8.8, so that is set up correctly as well.
If I wanted to renew this I could do ipconfig /renew, or I can start out by releasing it. I can release the old one, and then you can see that it is not associated with that IPv4 address. So then I am going to do a renew to get a new one, and it might take a second here. I can pull up that other window and see if it says identifying again. There, it grabbed it, so it grabbed the same address.
Let's jump back on the switch now and do those commands. I am going to restart my session here. I do need a password, so I am going to copy this password. Then show ip dhcp binding, and there we have it, there is my machine with its MAC address right there.
And I can also do that show ip dhcp statistics. Then we see how many DHCP offers there are, how many acknowledgments, so we have got some information now on this that is popping up on here.
So there you go. It is fairly simplistic to set up a DHCP server and get it up and running, and now my clients, any device that I plug in here, is going to automatically get an IP.
TechKnowSurge builds IT and cybersecurity professionals through hands-on, concept-first training built around real understanding — not memorization. Free interactive tools, structured programs, and 25+ years of real-world experience, all in one place.
Explore free tools and programs →