DHCP Snooping Option 82配置舉例
關鍵詞:DHCP snooping、DHCP server、Option 82
摘 要:本文主要介紹DHCP Snooping Option 82的應用環境及其典型配置。
縮略語:
縮略語 | 英文全名 | 中文解釋 |
DHCP | Dynamic Host Configuration Protocol | 動態主機配置協議 |
DNS | Domain Name System | 域名係統 |
Circuit ID | Circuit identification | 電路標誌,Option 82的子選項1 |
giaddr | Gateway IP address | 網關地址 |
Remote ID | Remote identification | 遠端標誌,Option 82的子選項2 |
WINS | Windows Internet Naming Service | Windows Internet名稱服務 |
目 錄
Option 82稱為中繼代理信息選項,該選項記錄了DHCP client的位置信息。DHCP snooping設備通過在DHCP請求報文中添加Option 82,將DHCP client的位置信息告訴給DHCP server,從而使得DHCP server能夠為主機分配合適的IP地址和其他配置信息,並實現對客戶端的安全和計費等控製。
圖1 Option 82應用舉例
DHCP server通常根據請求報文中的giaddr或接收到請求報文的接口IP地址,為客戶端分配IP地址。在圖1 中,DHCP服務器根據主機所在的網段,選取地址分配給Host A和Host B。
如果希望連接Ethernet1/2端口的客戶端地址在某一範圍,連接Ethernet1/3端口的客戶端地址在另一範圍,傳統的地址分配方式是無法實現的。利用Option 82,DHCP服務器根據客戶端連接的DHCP snooping端口和giaddr地址來為客戶端分配合適的IP地址,這樣就可以滿足上述需求。
Option 82能夠標識不同的用戶,服務器可以根據Option 82為不同的用戶分配不同的IP地址,從而實現QoS、安全和計費的管理。
l 隻有使能DHCP snooping功能之後,DHCP Option 82功能才能生效。
l DHCP snooping不支持鏈路聚合。若二層以太網接口加入聚合組,則該接口上進行的DHCP snooping配置不會生效;該接口退出聚合組後,之前的DHCP snooping配置才會生效。
l 設備隻有位於DHCP客戶端與DHCP服務器之間,或DHCP客戶端與DHCP中繼之間時,DHCP snooping功能配置後才能正常工作;設備位於DHCP服務器與DHCP中繼之間時,DHCP snooping功能配置後不能正常工作。
l DHCP snooping option 82功能建議在最靠近DHCP client的snooping設備上使用,以達到精確定位用戶位置的目的。
l 使能DHCP snooping功能的設備,不能作為DHCP服務器和DHCP中繼。
l 建議不要在同一台設備上同時配置DHCP客戶端/BOOTP客戶端和DHCP snooping功能,否則可能無法生成DHCP snooping表項,DHCP客戶端/BOOTP客戶端也可能申請不到IP地址。
某公司的辦公區域包括三個小組group1、group2和group3,獨立地分布在三個房間中。該公司通過DHCP server統一管理IP地址,為不同的小組分配不同範圍的地址。
具體需求如下:
l DHCP server為辦公室設備分配192.168.10.0/24網段的地址,有效期為12小時,並指定DNS和WINS服務器地址分別為192.168.100.2和192.168.100.3。
l 三個小組group1、group2和group3分別通過端口Ethernet1/1、Ethernet1/2和Ethernet1/3接入DHCP snooping設備,並通過DHCP snooping設備與DHCP server通信。
l DHCP server為group1的用戶分配192.168.10.2~192.168.10.25之間的地址;為group2的用戶分配192.168.10.100~192.168.10.150之間的地址;為group3的用戶分配192.168.10.151~192.168.10.200之間的地址。
圖2 DHCP Snooping組網圖
l 在DHCP snooping設備上啟動Option 82功能。
l 配置Option 82的子選項內容,使不同小組的用戶攜帶不同的Option 82信息。可以通過用戶自定義Circuit ID子選項內容的方式來實現。
l 在DHCP server上配置IP地址分配策略,使得DHCP server可以根據Option 82為DHCP client分配合適的IP地址。
本舉例是在Comware V500R002B42D001版本上進行配置和驗證的。
& 說明:
以下配置均是在實驗室環境下進行的配置和驗證,配置前設備的所有參數均采用出廠時的缺省配置。如果您已經對設備進行了配置,為了保證配置效果,請確認現有配置和以下配置不衝突。
# 使能DHCP Snooping功能。
<Switch> system-view
[Switch] dhcp-snooping
# 配置端口Ethernet1/4為信任端口。
[Switch] interface ethernet 1/4
[Switch-Ethernet1/4] dhcp-snooping trust
[Switch-Ethernet1/4] quit
# 在端口Ethernet1/1使能Option 82。
[Switch] interface ethernet 1/1
[Switch-Ethernet1/1] dhcp-snooping information enable
# 在端口Ethernet1/1配置Option 82的Circuit ID填充內容為group1。
[Switch-Ethernet1/1] dhcp-snooping information circuit-id string group1
[Switch-Ethernet1/1] quit
# 在端口Ethernet1/2使能Option 82。
[Switch] interface ethernet 1/2
[Switch-Ethernet1/2] dhcp-snooping information enable
# 在端口Ethernet1/2配置Option 82的Circuit ID填充內容為group2。
[Switch-Ethernet1/2] dhcp-snooping information circuit-id string group2
[Switch-Ethernet1/2] quit
# 在端口Ethernet1/3使能Option 82。
[Switch] interface ethernet 1/3
[Switch-Ethernet1/3] dhcp-snooping information enable
[Switch-Ethernet1/3] quit
# 在端口Ethernet1/3配置Option 82的Circuit ID填充內容為group3。
[Switch-Ethernet1/3] dhcp-snooping information circuit-id string group3
[Switch-Ethernet1/3] quit
<Switch> display current-configuration
#
interface Ethernet1/1
port link-mode bridge
dhcp-snooping information enable
dhcp-snooping information circuit-id string group1
#
interface Ethernet1/2
port link-mode bridge
dhcp-snooping information enable
dhcp-snooping information circuit-id string group2
#
interface Ethernet1/3
port link-mode bridge
dhcp-snooping information enable
dhcp-snooping information circuit-id string group3
#
interface Ethernet1/4
port link-mode bridge
dhcp-snooping trust
#
設備上,可以通過兩種方式配置Option 82的內容:
l 用戶自定義方式:用戶手工指定Option 82的內容;
l 非用戶自定義方式:采用默認的normal模式或verbose模式填充Option 82。
采用用戶自定義方式配置Circuit ID子選項內容時,Circuit ID子選項的格式如圖3 所示。
圖3 Circuit ID子選項的格式
例如,由端口Ethernet1/1接入的用戶,Circuit ID子選項內容為group1,DHCP報文中添加的Circuit ID子選項信息應為:0x010667726F757031,其中0106是Circuit ID的子選項號和子選項長度,67726F757031是字符串“group1”的十六進製值。
本例中隻需根據小組編號進行IP地址的分配,因此,在DHCP server上隻需對Circuit ID子選項中標識小組編號的字段進行匹配即可。
& 說明:
DHCP server使用的是Cisco Catalyst 3745設備上的配置,對應的軟件版本為IOS 12.3(11)T2版本,如果使用其他型號或其他版本的設備,請參考隨機資料中的用戶手冊進行操作。
# 配置接口的IP地址為192.168.10.1/24。
Server> enable
Server# configure terminal
Server(config)# interface fastethernet 0/0
Server(config-if)# ip address 192.168.10.1 255.255.255.0
Server(config-if)# exit
# 配置DHCP Server功能,並配置使用Option 82信息進行地址分配。
Server(config)# service dhcp
Server(config)# ip dhcp use class
# 為從DHCP snooping設備Ethernet1/1端口接入的group1用戶建立DHCP分類,並配置匹配的Option 82信息為Circuit ID子選項中的小組編號,無需匹配的內容可以使用通配符“*”代替。
Server(config)# ip dhcp class group1
Server(dhcp-class)# relay agent information
Server(dhcp-class-relayinfo)# relay-information hex 010667726F757031*
Server(dhcp-class-relayinfo)# exit
# 為從DHCP snooping設備Etherent1/2端口接入的group2用戶配置分類和匹配信息,方法與上麵命令相似,隻是將Option 82信息中的小組編號由1改為2。
Server(config)# ip dhcp class group2
Server(dhcp-class)# relay agent information
Server(dhcp-class-relayinfo)# relay-information hex 010667726F757032*
Server(dhcp-class-relayinfo)# exit
# 為從DHCP snooping設備Etherent1/3端口接入的group3用戶配置分類和匹配信息,方法與上麵命令相似。
Server(config)# ip dhcp class group3
Server(dhcp-class)# relay agent information
Server(dhcp-class-relayinfo)# relay-information hex 010667726F757033*
Server(dhcp-class-relayinfo)# exit
# 創建DHCP地址池office,為DHCP地址池配置租約期限、網關、DNS和WINS服務器地址。
Server(config)# ip dhcp pool office
Server(dhcp-config)# network 192.168.10.0
Server(dhcp-config)# lease 0 12
Server(dhcp-config)# default-router 192.168.10.1
Server(dhcp-config)# dns-server 192.168.100.2
Server(dhcp-config)# netbios-name-server 192.168.100.3
# 為三個DHCP分類分別指定地址範圍。
Server(dhcp-config)# class group1
Server(dhcp-pool-class)# address range 192.168.10.2 192.168.10.25
Server(dhcp-pool-class)# class group2
Server(dhcp-pool-class)# address range 192.168.10.100 192.168.10.150
Server(dhcp-pool-class)# class group3
Server(dhcp-pool-class)# address range 192.168.10.151 192.168.10.200
經過上述配置後,DHCP服務器即可為辦公區域的不同小組自動分配一定範圍內的IP地址及網關、DNS、WINS服務器地址。
l RFC 2131:Dynamic Host Configuration Protocol
l RFC 3046:DHCP Relay Agent Information Option
Copyright ©2008 杭州華三通信技術有限公司 版權所有,保留一切權利。
非經本公司書麵許可,任何單位和個人不得擅自摘抄、複製本文檔內容的部分或全部,並不得以任何形式傳播。
本文檔中的信息可能變動,恕不另行通知。