Overview
The network is configured with Vlan,vlan to isolate the broadcast, while the DHCP protocol uses broadcast, that is, by default the DHCP protocol can only be used within the VLAN, the DHCP server in VLAN30, only the client in VLAN30 can obtain the IP address from the DHCP server. What if the client of VLAN 2 or VLAN 3 also needs to get an IP address from this DHCP server?
Solution Ideas
1, to install a DHCP server for each network segment, but this way there is a waste of resources, and is not conducive to management
2, in the connection of different network segments of the device to turn on the DHCP relay function, DHCP this special broadcast information is forwarded between the VLANs, so that the other VLAN clients can also obtain an IP address from the DHCP server (similar to the intermediary agent)
Experimental environment
System Environment: centos6.5
GNS3 Simulator
Host IP Address: 192.168.1.20
RPM Package used: dhcp-4.1.1-38.p1.el6.centos.x_86_64.rpm
Build steps
1, SW2 switch on the configuration
Sw2#configure terminalSW2 (config) #no IP routing #关闭路由功能SW2 (config) #vlan 10,20,30 #创建vlan10, 20,30
Divide the F1/1 port into Vlan10
SW2 (config) #inter f1/1sw2 (config-if) #switchport mode accessSW2 (config-if) #switchport access VLAN 10SW2 (config-if) # Exit
Divide the F1/2 port into Vlan20
SW2 (config) #inter f1/2sw2 (config-if) #switchport mode accessSW2 (config-if) #switchport access VLAN 20SW2 (config-if) # Exit
Divide the F1/3 port into Vlan30
SW2 (config) #inter f1/3sw2 (config-if) #switchport mode accessSW2 (config-if) #switchport access VLAN 30SW2 (config-if) # Exit
Configure the F1/1 port with trunk
SW2 (config) #inter f1/0sw2 (config-if) #switchport mode trunkSW2 (config-if) #switchport trunk Encapsulation dot1q
2, SW1 three layer switch on the configuration
Configure the f1/0 port with trunk
SW1 (config) #inter F1/0SW1 (config-if) #no shutdown SW1 (config-if) #switchport mode trunkSW1 (config-if) #switchport trunk Encapsulation DOT1QSW1 (config-if) #exit
SW1 (config) #vlan 10,20,30SW1 (config-if) #exit
Add IP
SW1 (config) #int vlan 10SW1 (config-if) #no shutdownSW1 (config-if) #ip add 192.168.10.1 255.255.255.0sw1 (config-if) #exit
SW1 (config) #int vlan 20SW1 (config-if) #no shutdownSW1 (config-if) #ip add 192.168.20.1 255.255.255.0sw1 (config-if) #exit
SW1 (config) #int vlan 30SW1 (config-if) #no shutdownSW1 (config-if) #ip add 192.168.1.1 255.255.255.0SW1 (config-if) #exit
3. SW1 Configuring relay forwarding, pointing to the DHCP server
SW1 (config) #inter vlan 10SW1 (config-if) #ip helper-address 192.168.1.20SW1 (config-if) #exitSW1 (config) #inter VLAN 20SW1 (config-if) #ip helper-address 192.168.1.20
4. DHCP server configuration
[Email protected] ~]# vim/etc/dhcp/dhcpd.conf
[Email protected] ~]#/ETC/INIT.D/DHCPD restart #重启dhcp服务
5. Test (open GNS3 simulator vpcs)
Configure DHCP Relay Agent to assign IP addresses across VLANs under Linux