DHCP(Dynamic Host Configuration Protocol)
The Dynamic Host Configuration Protocol (DHCP) is a network management protocol used on Internet Protocol (IP) networks, whereby a DHCP server dynamically assigns an IP address and other network configuration parameters to each device on the network, so they can communicate with other IP networks. A DHCP server enables computers to request IP addresses and networking parameters automatically from the Internet service provider (ISP), reducing the need for a network administrator or a user to manually assign IP addresses to all network devices. In the absence of a DHCP server, a computer or other device on the network needs to be manually assigned an IP address, or to assign itself an APIPA address, the latter of which will not enable it to communicate outside its local subnet.
Operation
The DHCP employs a connectionless service model, using the User Datagram Protocol (UDP). It is implemented with two UDP port numbers for its operations which are the same as for the bootstrap protocol (BOOTP). UDP port number 67 is the destination port of a server, and UDP port number 68 is used by the client.
DHCP operations fall into four phases: server discovery, IP lease offer, IP lease request, and IP lease acknowledgement. These stages are often abbreviated as DORA for discovery, offer, request, and acknowledgement.
The DHCP operation begins with clients broadcasting a request. If the client and server are on different subnets, a DHCP Helper or DHCP Relay Agent may be used. Clients requesting renewal of an existing lease may communicate directly via UDP unicast, since the client already has an established IP address at that point.
Configuration
Simple DHCP configuration on Cisco Route,
Here we us cisco 1841 router as DHCP Server, fast ethernet 0/0(f0/0) is connected with switch. 3 host are connected with switch as configured as DHCP mode.
#ip dhcp pool <name pool>
#network<A.B.C.D-network address> <Subnetmask>
#default-router <A.B.C.D-Ip address of the gateway Ip>
#dns-server <A.B.C.D-dns server Ip address>
Start the configuration
Router>enable
#enter to privilege mode
Router#configure terminal
#global configuration mode
Router(config)#hostname Gateway
#assign hostname as Gateway for router
Gateway(config)#interface fastethernet 0/0
#select the interface
Gateway(config-if)#ip address 192.168.0.1 255.255.255.0
#assign IP Address for selected interface as 192.168.0.1
Gateway(config-if)#no shutdown
#turn on the interface
Gateway(config-if)#exit
Gateway(config)#ip dhcp pool A
#create DHCP pool named as “A”
Gateway(dhcp-config)#network 192.168.0.0 255.255.255.0
#assign network details for DHCP
Gateway(dhcp-config)#default-router 192.168.0.1
#assign default-router
Gateway(dhcp-config)#dns-server 192.168.0.1
Gateway(dhcp-config)#dns-server 8.8.8.8
Gateway(dhcp-config)#end
Gateway#
Gateway#show ip dhcp binding
IP address Client-ID/ Lease expiration Type
Hardware address
192.168.0.2 00D0.FFC8.5E8E -- Automatic
192.168.0.3 0004.9A39.0151 -- Automatic
192.168.0.4 0001.431B.0551 -- Automatic
Gateway#show ip dhcp pool
Pool A :
Utilization mark (high/low) : 100 / 0
Subnet size (first/next) : 0 / 0
Total addresses : 254
Leased addresses : 3
Excluded addresses : 0
Pending event : none
1 subnet is currently in the pool
Current index IP address range Leased/Excluded/Total
192.168.0.1 192.168.0.1 - 192.168.0.254 3 / 0 / 254
Gateway#
If we want to exclude Ip address from DHCP pool, then
Syntax: # ip dhcp excluded-address <A.B.C.D>
Eg:# ip dhcp excluded-address 192.168.0.2
If we want to exclude range of IP address from DHCP Pool, than
Syntax: #ip dhcp excluded-address <start IP> <End IP>
Eg:# ip dhcp excluded-address 192.168.0.2 192.168.0.10
Configuration:
Gateway(config)#ip dhcp excluded-address 192.168.0.2
#here we excluded one IP (192.168.0.2)
Gateway(config)#exit
Gateway#
Gateway#show ip dhcp binding
IP address Client-ID/ Lease expiration Type
Hardware address
192.168.0.3 0004.9A39.0151 -- Automatic
192.168.0.4 0001.431B.0551 -- Automatic
192.168.0.5 00D0.FFC8.5E8E -- Automatic
Gateway#
Same way, we can exclude range of IP
Gateway(config)#ip dhcp excluded-address 192.168.0.2 192.168.0.10
#here we excluded IP range from (192.168.0.2- 192.168.0.10), s
Gateway(config)#exit
Gateway#show ip dhcp binding
IP address Client-ID/ Lease expiration Type
Hardware address
192.168.0.11 00D0.FFC8.5E8E -- Automatic
192.168.0.12 0004.9A39.0151 -- Automatic
192.168.0.13 0001.431B.0551 -- Automatic
Gateway#
DHCP Relay Agent
DHCP relay agent is any TCP/IP host which is used to forward request and replies between DHCP server and client when the server is present on the different network. Relay agents receive DHCP messages and then generate a new DHCP message to send out on another INTERFACE. Also, DHCP relay agent adds a giaddr (gateway address of packet) field and also the Relay agent information option 82 if enabled. The option field is removed when the server reply is forwarded to the host.
Note – The discover and request messages are unicast by the DHCP relay agent.
Configuration:
Here we connected another router on f0/1 in Gateway router and f0/0 in Router 4. Assign the IP address 172.16.10.1 on f0/1 in Gateway Router and 172.16.10.2 on f0/0 in Router 4. In router 4, f0/1 is assigned as 172.16.11.1
In Gateway router,
#configuring f0/1 interface
Gateway>enable
Gateway#configure terminal
Gateway(config)#interface fastEthernet 0/1
Gateway(config-if)#ip address 172.16.10.1 255.255.255.0
Gateway(config-if)#no shutdown
Gateway(config-if)#exit
In Router 4,
Router>enable
Router#configure terminal
Router(config)#interface fastEthernet 0/0
Router(config-if)#ip address 172.16.10.2 255.255.255.0
Router(config-if)#no shutdown
Router(config-if)#exit
#here f0/1, we connected our host.
Router(config)#interface fastEthernet 0/1
Router(config-if)#ip address 172.16.11.1 255.255.255.0
Router(config-if)#no shutdown
Router(config-if)#ip helper-address 192.168.0.1
#assign the DHCP server details
Router(config-if)#exit
Router(config)#ip route 192.168.0.0 255.255.255.0 f0/0
#create a static route for communicating between these network
Router(config)#exit
Router#
In Gateway router,
#creating DHCP pool for second router host
Gateway(config)#ip dhcp pool B
Gateway(dhcp-config)#network 172.16.11.0 255.255.255.0
Gateway(dhcp-config)#default-router 172.16.11.1
Gateway(dhcp-config)#exit
#create a static route for communicating between these network
Gateway(config)#ip route 172.16.11.0 255.255.255.0 f0/1
Gateway(config)#exit
Gateway#show ip dhcp pool
Pool A :
Utilization mark (high/low) : 100 / 0
Subnet size (first/next) : 0 / 0
Total addresses : 254
Leased addresses : 3
Excluded addresses : 2
Pending event : none
1 subnet is currently in the pool
Current index IP address range Leased/Excluded/Total
192.168.0.1 192.168.0.1 - 192.168.0.254 3 / 2 / 254
Pool B :
Utilization mark (high/low) : 100 / 0
Subnet size (first/next) : 0 / 0
Total addresses : 254
Leased addresses : 3
Excluded addresses : 2
Pending event : none
1 subnet is currently in the pool
Current index IP address range Leased/Excluded/Total
172.16.11.1 172.16.11.1 - 172.16.11.254 3 / 2 / 254
Gateway#`
Gateway#show ip dhcp binding
IP address Client-ID/ Lease expiration Type
Hardware address
192.168.0.11 00D0.FFC8.5E8E -- Automatic
192.168.0.12 0004.9A39.0151 -- Automatic
192.168.0.13 0001.431B.0551 -- Automatic
172.16.11.29 000A.41A3.A29C -- Automatic
172.16.11.31 0002.177E.1169 -- Automatic
172.16.11.32 00E0.8F82.4D73 -- Automatic
Gateway#
Special Thanks to Corona institute.......✋
Comments
Post a Comment