D-LINK DHCP Relay option 82

Материал из noname.com.ua
Перейти к навигацииПерейти к поиску

Настройка коммутатора Д-линк

Настройки коммутатора

enable dhcp_relay
config dhcp_relay hops 4 time 0
config dhcp_relay option_82 state enable
config dhcp_relay option_82 check disable
config dhcp_relay option_82 policy replace
config dhcp_relay option_82 remote_id user_define "172.29.14.122"
config dhcp_relay option_60 state disable
config dhcp_relay option_60 default mode drop
config dhcp_relay option_61 state disable
config dhcp_relay option_61 default drop
config dhcp_relay add ipif System 172.29.14.1

http://xgu.ru/wiki/%D0%9E%D0%BF%D1%86%D0%B8%D1%8F_82_DHCP

Настойка DHCPd

DHCP - пакет (детально)

tshark -V ...


Frame 19 (366 bytes on wire, 366 bytes captured)
    Arrival Time: Mar  9, 2009 15:24:42.257042000
    [Time delta from previous captured frame: 15.000093000 seconds]
    [Time delta from previous displayed frame: 15.000093000 seconds]
    [Time since reference or first frame: 780.215513000 seconds]
    Frame Number: 19
    Frame Length: 366 bytes
    Capture Length: 366 bytes
    [Frame is marked: False]
    [Protocols in frame: eth:ip:udp:bootp]
Ethernet II, Src: D-Link_17:c6:28 (00:1c:f0:17:c6:28), Dst: IntelCor_06:8b:c7 (00:1c:c0:06:8b:c7)
    Destination: IntelCor_06:8b:c7 (00:1c:c0:06:8b:c7)
        Address: IntelCor_06:8b:c7 (00:1c:c0:06:8b:c7)
        .... ...0 .... .... .... .... = IG bit: Individual address (unicast)
        .... ..0. .... .... .... .... = LG bit: Globally unique address (factory default)
    Source: D-Link_17:c6:28 (00:1c:f0:17:c6:28)
        Address: D-Link_17:c6:28 (00:1c:f0:17:c6:28)
        .... ...0 .... .... .... .... = IG bit: Individual address (unicast)
        .... ..0. .... .... .... .... = LG bit: Globally unique address (factory default)
    Type: IP (0x0800)
Internet Protocol, Src: 172.29.14.122 (172.29.14.122), Dst: 172.29.14.1 (172.29.14.1)
    Version: 4
    Header length: 20 bytes
    Differentiated Services Field: 0x00 (DSCP 0x00: Default; ECN: 0x00)
        0000 00.. = Differentiated Services Codepoint: Default (0x00)
        .... ..0. = ECN-Capable Transport (ECT): 0
        .... ...0 = ECN-CE: 0
    Total Length: 352
    Identification: 0x00c6 (198)
    Flags: 0x00
        0... = Reserved bit: Not set
        .0.. = Don't fragment: Not set
        ..0. = More fragments: Not set
    Fragment offset: 0
    Time to live: 128
    Protocol: UDP (0x11)
    Header checksum: 0xc411 [correct]
        [Good: True]
        [Bad : False]
    Source: 172.29.14.122 (172.29.14.122)
    Destination: 172.29.14.1 (172.29.14.1)
User Datagram Protocol, Src Port: bootpc (68), Dst Port: bootps (67)
    Source port: bootpc (68)
    Destination port: bootps (67)
    Length: 332
    Checksum: 0x4a5c [correct]
        [Good Checksum: True]
        [Bad Checksum: False]
Bootstrap Protocol
    Message type: Boot Request (1)
    Hardware type: Ethernet
    Hardware address length: 6
    Hops: 1
    Transaction ID: 0xa9dbdf39
    Seconds elapsed: 28 (little endian bug?)
    Bootp flags: 0x8000 (Broadcast)
        1... .... .... .... = Broadcast flag: Broadcast
        .000 0000 0000 0000 = Reserved flags: 0x0000
    Client IP address: 0.0.0.0 (0.0.0.0)
    Your (client) IP address: 0.0.0.0 (0.0.0.0)
    Next server IP address: 0.0.0.0 (0.0.0.0)
    Relay agent IP address: 172.29.14.122 (172.29.14.122)
    Client MAC address: Dell_95:8d:8b (00:1c:23:95:8d:8b)
    Server host name not given
    Boot file name not given
    Magic cookie: (OK)
    Option: (t=53,l=1) DHCP Message Type = DHCP Discover
        Option: (53) DHCP Message Type
        Length: 1
        Value: 01
    Option: (t=116,l=1) DHCP Auto-Configuration
        Option: (116) DHCP Auto-Configuration
        Length: 1
        Value: 01
    Option: (t=61,l=7) Client identifier
        Option: (61) Client identifier
        Length: 7
        Value: 01001C23958D8B
        Hardware type: Ethernet
        Client MAC address: Dell_95:8d:8b (00:1c:23:95:8d:8b)
    Option: (t=50,l=4) Requested IP Address = 169.254.86.169
        Option: (50) Requested IP Address
        Length: 4
        Value: A9FE56A9
    Option: (t=12,l=6) Host Name = "tester"
        Option: (12) Host Name
        Length: 6
        Value: 746573746572
    Option: (t=60,l=8) Vendor class identifier = "MSFT 5.0"
        Option: (60) Vendor class identifier
        Length: 8
        Value: 4D53465420352E30
    Option: (t=55,l=11) Parameter Request List
        Option: (55) Parameter Request List
        Length: 11
        Value: 010F03062C2E2F1F21F92B
        1 = Subnet Mask
        15 = Domain Name
        3 = Router
        6 = Domain Name Server
        44 = NetBIOS over TCP/IP Name Server
        46 = NetBIOS over TCP/IP Node Type
        47 = NetBIOS over TCP/IP Scope
        31 = Perform Router Discover
        33 = Static Route
        249 = Classless Static Route (Microsoft)
        43 = Vendor-Specific Information
    Option: (t=43,l=2) Vendor-Specific Information
        Option: (43) Vendor-Specific Information
        Length: 2
        Value: DC00
    Option: (t=82,l=25) Agent Information Option
        Option: (82) Agent Information Option
        Length: 25
        Value: 0106000408BC0001020F010D3137322E32392E31342E3132...
        Agent Circuit ID: 000408BC0001
        Agent Remote ID: 010D3137322E32392E31342E313232
    End Option

Меня в первую очередь интересует Option 82

    Option: (t=82,l=25) Agent Information Option
        Option: (82) Agent Information Option
        Length: 25
        Value: 0106000408BC0001020F010D3137322E32392E31342E3132...
        Agent Circuit ID: 000408BC0001
        Agent Remote ID: 010D3137322E32392E31342E313232

Формат поля DHCP option 82 для DES-35XX:

Формат поля опции с Circuit ID - в ней указывается порт коммутатора, за которым находится клиент и VID соответствующего VLAN:

1234567
Тип опции=1Длина=6Тип Circuit ID=0Длина=4VLAN IDModule (=0)Port
1 байт1 байт1 байт1 байт2 байта1 байт1 байт
  • Module : Для автономного коммутатора, поле Module всегда 0; для стекируемого коммутатора, Module = Unit ID.
  • Port : Порт коммутатора, с которого получен DHCP-запрос (начинается с 1) port

Сравним с тем что получено от коммутатора 000408 BC 00 01

1234567
Тип опции=1Длина=6Тип Circuit ID=0Длина=4VLAN IDModule (=0)Port
Тип опции=00Длина=04Тип Circuit ID=08Длина=4VLAN IDModule (=00)Port=01
1 байт1 байт1 байт1 байт2 байта1 байт1 байт



Формат поля опции с Remote ID - в ней указывается MAC-адрес коммутатора, являющегося агентом DHCP Relay: 1. 2. 3. 4. 5 2

8

0

6

MAC address

1 байт 1 байт 1 байт 1 байт 6 байтов

1. Тип опции 2. Длина 3. Тип Remote ID type 4. Длина 5. MAC address : MAC-адрес коммутатора.

(аналогично для DES-3028, DES-3052, вероятно для DES-3528)

Конфигурирование DHCPd

lease-file-name            "/var/lib/dhcp/dhcpd.leases";
option domain-name-servers 193.33.**.**,193.33.**.**;
local-address              172.29.14.1;
log-facility               local7;

authoritative;
ddns-update-style          none;

ignore                     client-updates;

Эта часть описывает логгирование

if exists agent.circuit-id
  {
  log(info, concat("Lease"
                   ," IP ",     binary-to-ascii(10,  8, ".", leased-address)
                   ," MAC ",    binary-to-ascii(16,  8, ":", substring(hardware,                1, 6))
                   ," switch ", substring(option agent.remote-id, 2, 15)
                   ," port ",   binary-to-ascii(10, 16, "",  substring(option agent.circuit-id, 4, 2))
                   ," VLAN ",   binary-to-ascii(10, 16, "",  substring(option agent.circuit-id, 2, 2))
                  )
     );
  }


Описание "Класса"

# Switch-Port-MAC classes

class "172.16.33.17_22_0:13:77:3a:58:48"
  {
  match if(    (binary-to-ascii(16,  8, ":", substring(hardware,                1, 6)) = "0:13:77:3a:58:48")
           and (substring(option agent.remote-id, 2, 15)                               = "172.16.33.17")
           and (binary-to-ascii(10, 16, "",  substring(option agent.circuit-id, 4, 2)) = "22")
              );
  }