What is a DHCP Server and why to use one?
The Dynamic Host Configuration Protocol (DHCP) is a standardized network protocol used on Internet Protocol (IP) networks. The DHCP is controlled by a DHCP server that dynamically distributes network configuration parameters, such as IP addresses, for interfaces and services. A DHCP server enables computers to request IP addresses and networking parameters automatically, reducing the need for a network administrator or a user to configure these settings manually. In the absence of a DHCP server, each computer or other device on the network would need to be statically assigned to an IP address.
In the network below there is one router, one end-user computer, and a DNS Server. In real world deployments a network could have dozens or hundreds of routers or devices depending on the scale of the network. Regardless of the network complexity DHCP serves the same role in that its purpose is to dynamically assign IP address. With even a small number of devices static IP addressing can be very cumbersome. Hence, the creation of DHCP. A DHCP Server can also serve as a mechanism to provide DHCP options for technologies like Voice over IP (VoIP).
Steps to configure a DHCP Server
Step 1: Configure all applicable router interfaces.
R1(config)#interface FastEthernet0/0 R1(config-if)#ip address 192.168.1.1 255.255.255.0
Step 2: Configure a DHCP Server on the network route, assign a default-router, domain-name, dns-server, and lease duration. Lease duration is configured in the format of days and hours. In this example the lease is configured for 8 hours.
R1(config)#ip dhcp pool 192.168.1.0 R1(dhcp-config)#network 192.168.1.0 255.255.255.0 R1(dhcp-config)#default-router 192.168.1.1 R1(dhcp-config)#domain-name domain.local R1(dhcp-config)#dns-server 192.168.1.12 R1(dhcp-config)#lease 0 8
Step 3: Configure any DHCP exclusion necessary. If an exclusion is not configured all static IP addresses used on the network to which the DHCP Server is configured to provide addressing the DHCP Server will assign overlapping addresses. In this example we are exclusng the IP address of the router (DHCP Server) and the DNS Server.
R1(dhcp-config)#ip dhcp excluded-address 192.168.1.1 R1(dhcp-config)#ip dhcp excluded-address 192.168.1.12
TIP: You can also use IP SLA with route-maps in order to track and failover a route. In this scenario you can avoid specifying a single next-hop in the route-map and instead specify a primary and backup next-hop. The command would look like set ip next-hop 10.2.0.1 10.3.0.1. Without using IP SLA the secondary next-hop will never become active. You can reach more about how to make use of Route Failover using IP SLA here.
Verify the configuration
Now that the configuration is finished lets verify the DHCP Server configuration. Using the show run and show ip dhcp binding commands you can verify the DHCP Server settings and view any clients to which the DHCP Server has assigned an IP address.