星期三, 9月 14, 2016

DHCP Option 82的研究


RFC3046中定義了DHCP Relay Agent Information Option,也就是DHCP Option 82,這個選項有兩個子項目:Circuit ID和Remote ID。在實際的應用中,Circuit ID和Remote ID子項目分別對應「用戶權限」和「VLAN ID」。因此要使用Option 82認證就必須具備以下兩個條件:
一、DHCP Relay Agent通常在交換器上設定,因此交換器必須支援RFC 3046
二、要有一個過程或動作給Circuit ID和Remote ID一個值,以確定用戶端的信息

ISC-DHCP-Server的文件

binary-to-ascii (10, 8, "/", suffix ( option agent.circuit-id, 2)) = "1/5"表示來自交換器的port5是否符合
binary-to-ascii(16, 8, ":", substring(option agent.remote-id, 2, 6)) = "70:72:cf:95:aa:5c" 表示使用者電腦的網卡mac是否符合"70:72:cf:95:aa:5c"
binary-to-ascii (16,8,":",substring(hardware, 0, 4)) = "1:20:6a:8a"表示使用者網卡的的前面是否符合1:20:6a:8a
binary-to-ascii (10, 8, "/", suffix ( option agent.circuit-id, 2)) 確認來自哪一埠,例如1/5
binary-to-ascii (10, 8, ".", leased-address)表示使用者拿到分配的IP
binary-to-ascii(10,16,"",substring(option agent.circuit-id,2,2))   10表示十進制, 16表示16個bit. 這個表達式的結果就是把Option 82種的VLAN ID轉成10進制.
所以
class "VLAN10" {
        match if binary-to-ascii(10,16,"",substring(option agent.circuit-id,2,2)) = "10";
} # VLAN10
DHCP packet中檢查否符合vlan id 10

class "15f91" {
match if substring (option agent.circuit-id, 5, 3) =01:5f:91;
}


##########################################3



Circuit ID解析


以下圖為例:VLAN+Module+Port是4bytes,因此N=4,故Length為4+2=6



Remote ID解析



資料來源:http://www.alliedtelesis.it/media/datasheets/howto/dhcp-snooping-opt82_sd_a.pdf


Remote ID


There are two formats for this, depending on whether it's the default (switch MAC address) or specified hostname:
012-
06 (= Length)Switch MAC address
1LengthHostname

Circuit ID


This also has two formats, depending on whether the vlan-mod-port option is used, or something custom:
0123456-
04 (= Length)VLAN ID (big endian)Module (slot)Port ID
1LengthPort and VLAN circuit-id string


參考文件:

  1. CISCO DHCP Option 82文件
  2. DHCP Option 82, Cisco switches and routers and the ISC DHCP server
  3. isc-dhcp option82實例
  4. Cisco and HP Option 82 information compared
  5. The network on DHCP Option82 it are simple
  6. ISC DHCPD – Putting Option-82 Vendor Codes To Use To Reformat Cirtuit-ID and Remote-ID Values

沒有留言: