During the learning process of network construction, we will encounter such a situation that DHCP servers are configured using routers or switches. Here we will explain the dhcp relay configuration. We can use routers or switches as DHCP servers to allocate IP addresses to machines in the LAN. Generally, DHCP servers are in the LAN, but sometimes DHCP servers may not be in the local LAN, then we need to configure DHCP relay.
As shown in the above topology, R3 is a DHCP server. To obtain an IP address through DHCP, the PC needs to configure DHCP relay on the R1PC and R1 directly connected ports, the DHCP broadcast is converted to unicast and sent to the DHCP server. When DHCP returns an IP address, the unicast is converted to broadcast on R1 and sent to the PC.
Dhcp relay configuration 1. Configuration on PC1:
- PC(config)#int f0/0
- PC(config-if)#ip add dhcp
- PC(config-if)#no shut
- PC(config-if)#end
Dhcp relay configuration 2. Configuration on R1:
- R1 (config) # int f0/0
- R1 (config-if) # ip helper-address 34.34.34.4 // 34.34.34.34.4 is the ip address of the DHCP server.
- R1 (config-if) # end
Dhcp relay configuration 3. Configuration on R3:
- R3(config)#ip dhcp pool mypool
- R3(dhcp-config)#network 12.12.12.0 255.255.255.0
- R3(dhcp-config)#exi
- R3(config)#ip dhcp excluded-address 12.12.12.1
- R3(config)#ip dhcp excluded-address 12.12.12.2
- R3(config)#exi
Of course, you only need to configure the route on R2 so that R1 can communicate with R3. After the configuration is complete, we can see the sh ip int bri on PC1:
- PC#sh ip int bri
- InterfaceIP-AddressOK? Method Status Protocol
- FastEthernet0/012.12.12.3YES DHCP up up
When the port is down and re-enabled, the IP address is changed.