Layer 3 switch DHCP server/DHCP relay interconnection configuration details

Foreword:

This is a problem I encountered recently when I was doing the problem---the Layer 3 switch acts as a DHCP server to connect the Layer 3 switch DHCP relay to distribute IP addresses to different network segment vlans, and I have searched the whole network and there is no article that can To solve my problem, all relevant websites in the whole network only have DHCP as a server or DHCP as a relay configuration explanation, but there are very few articles that integrate them together. I have mastered this knowledge now, in order not to let more The beginners are suffering from a catastrophe similar to mine, so I thought of writing a detailed explanation of this knowledge point to save everyone

1. Configuration requirements

1. PC1 and PC2 use DHCP to obtain IP addresses

2. PC1 and PC2 belong to different vlans and network segments, and the gateway of each network segment must be configured on LSW2

3. Each network segment allocated by DHCP does not include the first five addresses of each network segment and the lease period is 2 days

4. LSW1 is the DHCP server

 Configuration idea: from bottom to top, first configure the second layer and then configure the third layer

#Configure the second layer first, and configure each access and trunk interface according to the requirements (it is relatively simple and will not be repeated here)

#lsw3
vlan batch 10 20
int e 0/0/1
 port link-type access
 port default vlan 10
int e 0/0/2
 port link-type access
 port default vlan 20
#lsw2
[LSW2]VLAN B 10 20 30
[LSW2]int g 0/0/1
[LSW2-GigabitEthernet0/0/1]p l t
[LSW2-GigabitEthernet0/0/1]port trunk allow-pass vlan 10 20
[LSW2]int g 0/0/2
[LSW2-GigabitEthernet0/0/2]port l a
[LSW2-GigabitEthernet0/0/2]port default vlan 30
#lsw1
[LSW1]vlan b 30
[LSW1]int g 0/0/2
[LSW1-GigabitEthernet0/0/2]p l a
[LSW1-GigabitEthernet0/0/2]port default vlan 30

# Layer 2 configuration complete


We have already configured the second layer, and the next step is to configure the third layer. If you are a beginner, it is recommended to start the configuration from the DHCP server, and then configure the DHCP relay to call, which is relatively easy to understand.

#lsw1 #Create
IP address pool vlan10
[LSW1]ip pool vlan10

#Create a DHCP distribution URL range
[LSW1-ip-pool-vlan10]network 192.168.10.0 mask 24

#Configure gateway
[LSW1-ip-pool-vlan10]gateway-list 192.168.10.254

#Remove the first five addresses of this network segment, meet the requirements
[LSW1-ip-pool-vlan10] excluded-ip-address 192.168.10.1 192.168.10.5

#Extend the lease period to two days as needed (generally not modified)
[LSW1-ip-pool-vlan10]lease day 2

#Same as the address pool vlan10, no more details
[LSW1-ip-pool-vlan10]ip pool vlan20
[LSW1-ip-pool-vlan20]network 192.168.20.0 mask 24
[LSW1-ip-pool-vlan20]gateway-list 192.168 .20.254
[LSW1-ip-pool-vlan20] excluded-ip-address 192.168.20.1 192.168.20.5
[LSW1-ip-pool-vlan20]lease day 2

#Enter vlanif interface to configure IP address and establish global mode
[LSW1]interface Vlanif 30
[LSW1-Vlanif30]ip add 192.168.30.2 30
[LSW1-Vlanif30]q
[LSW1]dhcp enable 

#This self-understanding of this device can be matched by this address outside the address pool
[LSW1-Vlanif30]dhcp select global 

lsw1 The IP address pool of the DHCP server has been configured, and the IP address is configured under the vlanif interface for DHCP relay communication and the DHCP global mode is started

#DHCP server configuration is now complete


#Configure lsw2DHCP relay (key)

#Note that if the value of vlanif is the same as the pvid value of the interface, then the data frame sent from this interface is a data frame without any vlantag

At this time, we must ensure that this IP address must be on the same network segment as the other party's open global address pool, and can ensure communication, so as to ensure that the following address distribution work can be performed
[LSW2]interface Vlanif 30
[LSW2-Vlanif30]ip add 192.168. 30.1 30


[LSW2-Vlanif30]q

#This is the address of the 192.168.10.0 network segment, which must be consistent with the gateway in the IP address pool
[LSW2]interface Vlanif 10
[LSW2-Vlanif10]ip add 192.168.10.254 24
[LSW2-Vlanif10]q

#This is the address of the 192.168.20.0 network segment, which must be consistent with the gateway in the IP address pool
[LSW2]interface Vlanif 20
[LSW2-Vlanif20]ip add 192.168.20.254 24
[LSW2-Vlanif20]q

#So far, if you manually configure an IP address for the PC, you can reach the most basic network interoperability

#Configure DHCP relay service group

#This is also easy to understand, because there may be multiple different network segments under the switch to obtain IP addresses using DHCP, so in order to prevent confusion, groups will be established, and DHCP address providers will be specified in these groups. Cache them in this group (personal understanding), which is convenient for being called by other different DHCP demand network segments
[LSW2]dhcp server group 10

#Because the DHCP server has enabled global mode on the 192.168.30.2 interface, the relay DHCP service asks this interface for
[LSW2-dhcp-server-group-10]dhcp-server 192.168.30.2
[LSW2-dhcp-server-group- 10]q
[LSW2]dhcp server group 20
[LSW2-dhcp-server-group-20]dhcp-server 192.168.30.2

#The gateway (DHCP demand group) is bound to the dhcp service group
[LSW2] interface Vlanif 10

#To the following device asking for DHCP to assign an IP address, say I am just a relay (middleman)
[LSW2-Vlanif10]dhcp select relay

#Tell the device that I am not a server. If you want to use DHCP to assign IP addresses, go to this group. It is a DHCP service group. The demand packets sent by the device go to the DHCP service group. This group has real DHCP. The server interface, although it is on other devices, can communicate between our two Layer 3 devices. In this way, the discover of the device can be sent to the real DHCP server
[LSW2-Vlanif10]dhcp relay server-select 10
[LSW2 ]interface Vlanif 20
[LSW2-Vlanif20]dhcp select relay 
[LSW2-Vlanif20]dhcp relay server-select 20

Note: it's not over yet! ! !

Now the DHCP server of the device can receive the discover message, but cannot reply

Because of the DHCP relay, the DHCP server is not directly connected to the device, so there is no routing entry to the device. We configure it manually.

 #lsw1 configure static
[LSW1]ip route-static 192.168.20.0 24 192.168.30.1
[LSW1]ip route-static 192.168.10.0 24 192.168.30.1

#At this point the configuration has been completed


 The device starts DHCP, don't forget to click Apply

At this time, if you try to capture the packet, you will find that the DHCP server will issue an IP address to the device with a routing entry.

 The PC also has an IP address distributed by the DHCP server.

Guess you like

Origin blog.csdn.net/xiaobai729/article/details/123540542