Jump to content
Калькуляторы

Опция 82 + циска

Есть вот такая схема:

 

коммутатор доступа (циска 2950) - агрегация (3550) - ядро (6509)

 

На 2950 dhcp snooping вставляет опцию 82. 3550, svi которой смотрит в влан с клиентами, форвардит запрос через ip helper-address на dhcp-сервак (isc dhcpd), подключенный к ядру.

 

Мак 2950 - 001319c19b00

 

Хочу выдать адрес в зависимости от порта. Для этого накидал вот такой конфиг:

 

ddns-update-style none;
authoritative;
log-facility local7;

subnet 10.201.7.0 netmask 255.255.255.0 {

interface eth0;
option routers 10.201.7.254;
default-lease-time 600;
max-lease-time 7200;

class "port-1"{
match if (binary-to-ascii (10, 8, "", suffix( option agent.circuit-id, 1)) = "0")
and (binary-to-ascii (16, 8, "", suffix( option agent.remote-id, 6)) = "001319c19b00")
;
}

pool {
 range 10.201.7.1;
 allow members of "port-1";
}

class "port-2"{
match if (binary-to-ascii (10, 8, "", suffix( option agent.circuit-id, 1)) = "1")
and (binary-to-ascii (16, 8, "", suffix( option agent.remote-id, 6)) = "001319c19b00")
;
}

pool {
 range 10.201.7.2;
 allow members of "port-2";
}
}

if exists agent.circuit-id
{
log (info, concat(
"Leased address ", binary-to-ascii (10, 8, ".", leased-address),
" for MAC ", binary-to-ascii(16, 8, "", substring(hardware, 1, 6)),
" at switch ", binary-to-ascii (16, 8, "", suffix( option agent.remote-id, 6)),
" on port ", binary-to-ascii (10, 8, "", suffix( option agent.circuit-id, 1)) ,
" in vlan ", binary-to-ascii(10, 16, "",  substring(option agent.circuit-id, 2, 2))));
}

 

В итоге сервак не отвечает на dhcp request. Хотя на него прилетает запрос с нужной опцией.

Вот такой:

 

bd1fa8a50f12.png

 

Вроде с вычленением опции все верно:

1 - берем с конца бинарного представления circuit id 1 байт, преобразовываем его в ascii

2 - берем с конца бинарного представления remote id 6 байт, т.е. мак-адрес, преобразовываем его в ascii

3 - если оба значения попадают под условие, то выдаем адрес из соответствующего пула.

 

Честно говоря не догоню в чем проблема.

Share this post


Link to post
Share on other sites

and (binary-to-ascii (16, 8, "", suffix( option agent.remote-id, 6)) = "001319c19b00")

если все еще не работает, то попробуйте в такой форме сделать запись

and (binary-to-ascii (16, 8, ":", suffix ( option agent.remote-id, 6)) = "0:13:19:c1:9b:0");

ну или в Вашей форме записи вырезать незначащие нули

Edited by C@T

Share this post


Link to post
Share on other sites

Разобрался. У функции binary-to-ascii первый аргумент указывает в какую систему счисления переводить из бинарного вида, а второй - по сколько бит брать. Мы бъем мак по 8 бит, т.е. 6 октетов, разделенных двоеточием. Каждый октет по видимому переводится отдельно и для dhcpd нет разницы между 0f и просто f. Короче для простоты просто убираем по нолику слева в каждом октете и все.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.