[Lab environment]
GNS3 (Because Packet Tracer does not support DHCP-related commands, the GNS3 Simulator Based on the cisco ios image file can also be used on a real machine)
[PURPOSE]
Exercise configuring the DHCP service on a Cisco router to automatically allocate IP addresses
[Experiment topology]
Lab procedure]
0. Connect the device according to the topology and configure the IP address of the router port. The client uses DHCP to obtain the IP address.
1. Create a DHCP address pool and its name (Multiple Address pools can be created)
Router # conf t
Router (config) # ip dhcp pool slyar-pool
2. Specify the network or subnet of the address pool allocated by DHCP
Router (dhcp-config) # network 172.24.46.0 255.255.255.0
3. Specify the Domain Name of the DNS server (optional)
Router (dhcp-config) # domain-name slyar.com
3. Specify the IP address of the DNS server. A command can configure up to eight IP addresses. The priority ranges from high to low. In this example, two DNS servers are used, and the second is used as the backup DNS.
Router (dhcp-config) # dns-server 172.16.5.20.172.16.5.132
4. Configure the Default Gateway (usually the lan ip address of the router)
Router (dhcp-config) # default-router 172.24.46.254
5. Set the lease period. The default value is one day. The unit of allocation is days, hours, and minutes. In this example, 8 days are set.
Router (dhcp-config) # lease 8 0 0
Router (dhcp-config) # exit
6. exclude a specific IP address (not assigned to the client) and specify the excluded start address and end address. In this example, the four IP addresses 172.24.46.250-172.24.46.254 are excluded.
Router (config) # ip dhcp excluded-address 172.24.46.250 172.24.46.254
Router (config) # end
7. Check Configuration
Router # sh run
Ip dhcp excluded-address 172.24.46.250 172.24.46.254
!
Ip dhcp pool slyar-pool
Network 172.24.46.0 255.255.255.0
Domain-name slyar.com
Dns-server 172.16.5.20.172.16.5.132
Default-router 172.24.46.254
Lease 8
!
8. Refresh the DHCP Client, open cmd on the PC, and enter "ipconfig/renew" to obtain the IP address again.
PC> ipconfig/renew
IP Address...
Subnet Mask ......: 255.255.255.0
Default Gateway ......: 172.24.46.254
DNS Server...
9. Disable the DHCP service.
The DHCP service is enabled for Cisco IOS by default. Therefore, you only need to configure the address pool to use the DHCP function. To disable the DHCP service of a vrodhcp, run the following command:
Router (config) # no service dhcp