DHCP option 82,固定接口獲取固定IP地址


在終端發送DHCP request請求時,在交換機的接口處添加option82屬性,報文攜帶字段發送到DHCP服務器上。DHCP服務器處理並識別option82字段,通過與DHCP地址池范圍關聯的class做匹配,從而實現從DHCP獲取固定地址的需求。

option82配置:

 dhcp server relay information enable  設備默認情況下開啟處理option82

#

dhcp enable
#
dhcp snooping enable

#             

interface Vlan-interface10

 ip address 192.168.1.1 255.255.255.0

#
dhcp class port1
 if-match rule 1 option 82 hex 706f727431 partial

#
dhcp server ip-pool test
 gateway-list 192.168.1.1
 network 192.168.1.0 mask 255.255.255.0
 class port1 range 192.168.1.123 192.168.1.123

#
interface GigabitEthernet1/0/1
 port link-mode bridge
 port access vlan 10
 dhcp snooping information enable
 dhcp snooping information circuit-id string port1
#

以上DHCP服務器在本地交換機,如果外置DHCP服務器繼需要開啟中繼:

interface Vlan-interface10

 dhcp select relay

 dhcp relay server-address 1.1.1.1

DHCP和class配置在DHCP服務器所在交換機,端口內circuit-id配置在用戶側交換機,並在與DHCP服務器相連的端口內添加信任服務器

dhcp snooping trust

需要注意的是,DHCP服務器處理識別option82字段校驗有兩種:

方法一:使用partial進行模糊匹配,使用class中配置的hex字段和端口中配置的ciruit-id對比,只要包含即視為匹配

if-match rule 1 option 82 hex 706f727431 partial

方法二:使用偏移量精確匹配,對接不通廠家設備時需要明確option82匹配項,對比一致視為匹配,總長度需要抓包明確

if-match rule 1 option 82 hex 706f727431 offset 2 length 5    //偏移兩個字符,總長度5個字符

 

下圖片展示了在二進制找到了option82中的3-9字符(共7個)

原圖片配置的class命令:if-match rule 1 option 82 hex 36706f72743339 offset 2 length 7    

文章內容和圖片來自知了社區:DHCP option82屬性實現固定接口獲取固定地址 - 知了社區 (h3c.com)

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM