How to configure cisco router as DHCP

How To Configure DHCP Functions on Cisco Router

How to configure Cisco router DHCP functions to run perfectly on any devices? Well, in order to configure the Cisco router to perform the network operation desired, the first thing to do is to connect the Cisco router through console connection.

Most routers come with console cable that has one DB-9 end and the other end is RJ-45 connecter. The cable is usually a slim ribbon that looks different from the regular LAN twisted pair cables. After connecting the console cable to the computer, using the DB-9 connecter or the USB, software for terminal emulation is required. The basic settings that need to be done in the terminal emulation software are the following :

  1. Bits per sec: 9600
  2. Data bits: 8
  3. Parity: none
  4. Stop bits: 1
  5. Flow control: none

How to configure cisco router as dhcp client

How to Configure a Cisco Router as a DHCP Client

When your ISP gives you a dynamic IP address upon each connection or you need to configure the router to obtain its interface IP address automatically. Then you need to know how to configure a cisco router as a DHCP Client. It doesn’t need any special requirements and this is done by using a single command :

  • Router(config-if)#ip address dhcp

Some service providers might ask you to use a client-id or a hostname of their own choice. This can be done by adding the following parameters to the command below :

  • Router(config-if)#ip address dhcp client-id interfacename hostname hostname

Where interface-name is the interface name that will be used for the client-id and hostname is the hostname that will be used for the DHCP binding. This hostname can be different from the one that was set for the router in the global configuration. You can use both of these parameters, one of them, or none of them.

How to configure cisco router as dhcp server

How to Configure a Cisco Router as a DHCP Server

When using the router as a DHCP server to provide IP addresses and related information to DHCP clients this might be your solution. However, it does need a special hardware requirements. DHCP server software is supported for these series: 800, 1000, 1400, 1600, 1700 series (support for the Cisco 1700 series was added in Cisco IOS Release 12.0[2]T), 2500, 2600, 3600, 3800, MC3810, 4000, AS5100, AS5200, AS5300, 7000, 7100, 7200, MGX 8800 with an installed Route Processor Module, 12000, uBR900, uBR7200, Catalyst 5000 family switches with an installed Route Switch Module, Catalyst 6000 family switches with an installed MultiLayer Switch Feature Card, and Catalyst 8500. The configuration steps are as follows :

1. Define The DHCP Address Pool

  • Router(config)#ip dhcp pool dhcp-pool-name
  • Router(dhcp-config)#network network-address subnetmask

Where dhcp-pool-name is the DHCP pool name, network-address is the network address to be used by the DHCP pool, and subnetmask is the subnet mask for the network. You can replace the subnet mask by (/prefix) to provide the subnet mask.

2. Configure The Parameters To Be Sent To The Client

Cisco devices running software include Dynamic Host Configuration Protocol server and the relay agent software. The Cisco IOS DHCP server is a full DHCP server implementation that assigns and manages IP addresses from specified address within the device to DHCP clients. The DHCP server can be configured to assign additional parameters such as the IP address of the Domain Name System (DNS) server.

To provide the DNS server IP address :

  • Router(dhcp-config)#dns-server dns-server-address

To provide the IP address of the default-gateway, which is usually the IP address of the router interface connected to the network :

  • Router(dhcp-config)#default-router default-gatewayaddress

To provide the name of the domain of the network (if in a domain environment) :

  • Router(dhcp-config)#domain-name domain

To provide the IP address of the NetBIOS name server :

  • Router(dhcp-config)#netbios-name-server netbios-serveraddress

To define the lease time of the addresses given to the client. You can make it infinite, which is not advised, by using this command instead :

  • Router(dhcp-config)#lease days hours minutes

There is a large group of settings that you can configure to be sent to the clients, and I have only mentioned the most frequently used :

  • Router(dhcp-config)#lease infinite

3. Configure The IP Addresses To Be Excluded From The Pool

This is usually done to avoid the conflicts caused by the DHCP with servers and printers. Remember to give all servers and network printers static IP addresses in the same range of the DHCP pool. Afterward, exclude these addresses from the pool to avoid conflicts.

  • Router(config)#ip dhcp excluded-address excluded-ipaddress

Use the command in the previous form to exclude a single address. You can repeat it as many times as you see fit for the IP addresses you want to exclude. You can also use the same command to exclude a range of IP addresses all in a single command :

  • Router(config)#ip dhcp excluded-address start-ip-address end-ip-address

where start-ip-address is the first address in the range to be excluded from the pool and end-ip-address is the last excluded address in the range.

4. Enable The DHCP Service In The Router

Usually, the DHCP service is enabled by default on your router.

  • Router(config)#service dhcp

To disable it, use

  • Router(config)#no service dhcp

5. Check The DHCP Operation On The Router

This command shows the current bindings of addresses given to clients.

  • Router#show ip dhcp binding

This command shows the DHCP server statistics.

  • Router#show ip dhcp server statistics

This debug command is used to troubleshoot DHCP issues.

  • Router#debug ip dhcp server

How to configure DHCP relay cisco router

How to Configure DHCP Relay in Cisco Router

When the DHCP Client wants to get an IP address, it will send a DHCP Discover message. As the Router do not forward broadcast packets, this message will never reach the DHCP Server, and as a result, No IP address for the DHCP Client. To solve this problem, the DHCP Relay Agent feature is used on routers to forward DHCP messages to the DHCP Server, and when the DHCP Server respond, the Router will forward the replies to the Client.

DHCP Relay Configuration for IPv4

If you have a DHCP server other than the router and you would like the router to pass the DHCP requests to this DHCP server laying outside the LAN, go to the LAN interface that does not have the DHCP server and type the following command:

  • Router(config-if)#ip helper-address dhcp-server-address

Where dhcp-server-address is the IP address of the DHCP server located outside this LAN.

DHCP Relay Configuration for IPv6

If you have a DHCPv6 server other than the router and you would like the router to pass the DHCPv6 requests to this DHCPv6 server laying outside the LAN, go to the LAN interface that does not have the DHCPv6 server and type the following command:

  • Router(config-if)#ipv6 dhcp relay destination dhcp-serveripv6-address

Where dhcp-server-ipv6-address is the IPv6 address of the DHCP server located outside this LAN.

Leave a Reply