Skip to content

Latest commit

 

History

History
151 lines (103 loc) · 3.97 KB

DHCP.md

File metadata and controls

151 lines (103 loc) · 3.97 KB

Dynamic Host Configuration Protocol (DHCP)

1. Definition

  • DHCP is a service.
  • It allows devices to acquire their IP configuration dynamically.
  • It is defined in RFC 2131 and 2939. It works in the server/client model.
  • The server offers and delivers IP configurations. Clients request and acquire their IP configurations.

2. Operation

dhcp-operation

3. DHCP Address Allocation Methods

3.1. Static allocation

Static DHCP (aka DHCP reservation) is a useful feature which makes the DHCP server on your router always assign the same IP address to a specific computer on your LAN.

To be more specific, the DHCP server assigns this static IP to a unique MAC address assigned to each NIC on your LAN. Your computer boots and requests its IP from the router's DHCP server. The DHCP server recognizes the MAC address of your device's NIC and assigns the static IP address to it.

In this method, the administrator configures an allocation table on the DHCP server. In this table, the administrator fills the MAC addresses of all clients and assigns an IP configuration to each client.

3.2. Dynamic allocation

The DHCP server assigns a reusable IP address from IP Pools of addresses to a client for a maximum period of time, known as a lease. This method of address allocation is useful when the customer has a limited number of IP addresses; they can be assigned to clients who need only temporary access to the network.

3.3. Automatic allocation

The DHCP server assigns a permanent IP address to a client from its IP Pools. On the firewall, a Lease specified as Unlimited means the allocation is permanent.

4. Lab

4.1 Network diagram

image

4.2. Configuration

  • ISP
interface Loopback0
 ip address 8.8.8.8 255.255.255.255
!
interface Ethernet0/0
 ip address 192.168.1.2 255.255.255.252
!
ip route 172.16.0.0 255.255.255.0 192.168.1.1
!
  • R1 (DHCP server for pool-172)
interface Ethernet0/0
 ip address 192.168.1.1 255.255.255.252
!
interface Ethernet0/1
 ip address 172.16.0.1 255.255.255.0
!
ip route 0.0.0.0 0.0.0.0 192.168.1.2
!
! #provide IP dhcp start from 0.50 to 0.254
ip dhcp excluded-address 172.16.0.1 172.16.0.49
!
ip dhcp pool pool-172
 network 172.16.0.0 255.255.255.0
 default-router 172.16.0.1
 dns-server 1.1.1.1 1.1.1.2
!
  • VPC4

image

Success!!

  • Verify on R1

image

Default, lease time is 1 day. By the way, you can set lease day minute.

  • How ever, if we want to DHCP static allocation?

Example, VPC4 (MAC 00:50:79:66:68:26) we want to assign IP with 172.16.0.51.

R1#debug ip dhcp server packet

To see client ID of VPC4.

image

So client-identifier of VPC4 is 0100.5079.6668.26.

Configure pool-static-vpc4 for VPC4:

ip dhcp pool pool-static-vpc4
 host 172.16.0.51 255.255.255.0
 client-identifier 0100.5079.6668.26
 end
!

Try ip dhcp serveral times, but still got IP the same. Bingoo!!!

  • IP dhcp relay

Supose, ISP router is a DHCP server:

Router#show runn | sec dhcp
ip dhcp pool ISP
 network 172.16.0.0 255.255.255.0
 dns-server 9.9.9.9
 domain-name test.com
 default-router 172.16.0.1

R1:

R1#sh run int e0/1
!
interface Ethernet0/1
 description TO-VPC
 ip address 172.16.0.1 255.255.255.0
 ip helper-address 192.168.1.2
end

R1#

This is the command which enables hosts in R1 to dynamically obtain IP addresses from the DHCP server configured on Router ISP( a server located in a different broadcast domain).

Done~~.