How to configure a DHCP Server on CISCO IOS

As you know, Routers and L3 switches can be configured to act as a DHCP server. So, in this post, we will see how to configure DHCP on Cisco IOS.

Let’s take the following topology:

ARCHI

As you can see, we have a DHCP Server; in our case here is a router, and 2 DHCP clients. The clients will be configured to receive their IP addresses using DHCP. We are using the network 192.168.1.0/24 and the Fa0/0 of our router (DHCP Server) will use 192.168.1.1/24.

Let’s start by configuring the IP address on the Fa0/0:

DHCP_SERVER(config)#interface fa0/0
DHCP_SERVER(config-if)#ip address 192.168.1.1 255.255.255.0
DHCP_SERVER(config-if)#no shutdown
DHCP_SERVER(config-if)#exit

Noting special here. Now we will start to configure our DHCP server:

DHCP_SERVER(config)#ip dhcp pool DYNAMIC
DHCP_SERVER(dhcp-config)#network 192.168.1.0 255.255.255.0

You will have to start by the ip dhcp pool command and give a name to this pool (DYNAMIC in our case). This DHCP pool will use 192.168.1.0/24. That’s all you have to do it if you want to configure a DHCP Server on your network. Let’s see if this is true:

DHCP_SERVER#show ip dhcp binding
IP address        Client-ID/      Lease expiration       Type
Hardware address
192.168.1.2     0090.0CBD.8215           —                     Automatic
192.168.1.3     0090.0C2D.7922           —                     Automatic

To verify if your DHCP server is running, look to your bindings by using the show ip dhcp binding command. You can see that we have 2 DHCP clients, and they receive IP addresses.

This is the basic configuration of our DHCP server. But imagine that your hosts want to go on the internet, for this, they have to know a default gateway and a DNS server. Let’s add this information to our DHCP server, so he will let the DHCP clients know that the default gateway is 192.168.1.1/24 and the DNS server  is 67.67.67.67:

DHCP_SERVER(config)#ip dhcp pool DYNAMIC
DHCP_SERVER(dhcp-config)#default-router 192.168.1.1
DHCP_SERVER(dhcp-config)#dns-server 67.67.67.67
DHCP_SERVER(dhcp-config)#exit

We used the default-router command to configure the gateway, and dns-server command to configure the IP address of the DNS server.

Last thing; imagine that you are using some static addressing in your network, for example from 192.168.1.10/24 to 192.168.1.20/24. In this case, we have to tell our DHCP Server to not affect these addresses to any host. Let’s see how we can do this:

DHCP_SERVER(config)#ip dhcp excluded-address 192.168.1.10 192.168.1.20

ip dhcp excluded-address “@IP” command tells the DHCP server to exclude these addresses from the pool of available addresses.

That’s all that I have for you. If you have any questions, just leave a comment.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.