Monday, February 10, 2014

DHCP configuration in Router

Configure DHCP (Dynamic Host Configuration Protocol) in Router

In DHCP the host is configured dynamically. If a network is configured by DHCP, the PC will get IP, Gateway, Subnet Mask, DNS address dynamically.

DHCP can be configured in Server as well as Router. Here I configured DHCP in Router.
Lets see how can we configure DHCP in Router.


I configured DHCP for the following topology.

Now go to the CLI of the Router. Enter config mode of the router and assign ip in the interface the switch is connected.
Type the following commands to do it.

Router(config)#interface gigabitEthernet 0/0
Router(config-if)#ip add
Router(config-if)#ip address 192.168.0.1 255.255.255.0
Router(config-if)#no shut


And now we are going to configure DHCP. Return to the config mode. At first we have to exclude IPs from DHCP, it means the IPs we've already used somewhere in statically should be excluded from DHCP network . We have use only one IP, which is in Router interface gigabitEthernet 0/0. The exclusion can be done in two ways. Only one IP or a range of IPs. I did it for a range.
And then we have to create DHCP pool. Its like a container which contain a set of IPs and while DHCP request comes from a PC, it provides IP from that container.
Then we have to define the network, default route(gateway), dns(if the network owns a dns).
The following commands are in sequence:

Router(config)#ip dhcp excluded-address 192.168.0.1 192.168.0.10
Router(config)#ip dhcp p
Router(config)#ip dhcp pool LAN
Router(dhcp-config)#ne
Router(dhcp-config)#network 192.168.0.0 255.255.255.0

Router(dhcp-config)#default-router 192.168.0.1
Router(dhcp-config)#exit


Thats all. Now go to ip configuration in a PC and click on DHCP, you'll see like the following image.

No comments:

Post a Comment