在服务器中存储dhcp客户端标识符,以便在以后的租约中使用

时间:2016-06-22 03:35:41

标签: linux networking dhcp

我想将客户端标识符存储在服务器中,以便服务器可以 稍后在尝试将IP地址租赁给其他人时参考该值 客户端。 每个客户端都会发送一个标识符,如果另一个客户端出现了 相同的标识符,我根据该标识符为它们分配主机名。 (只有2个 不同的标识符是可能的,所以我只需要存储两个标识符。)

这是我添加到服务器以存储它的内容。

#space to store the identifiers
option space local code width 2 length width 2;
option local.identifier1 code 1 = unsigned integer 8;
option local.identifier2 code 2 = unsigned integer 8;

#Custom option identifier sent by the client
option identifier code 189 = unsigned integer 8;
option switch code 190 = unsigned integer 8;

/// Storing  based on what client sent
class "acs"
{
  match if option dhcp-client-identifier = "ACS";

if option switch = 1
{
        option host-name "acs-01";
        option local.identifier1 = option identifier;
}
elsif option switch = 2
{
        option host-name "acs-02";
        option local.identifier2 =  option identifier;
}
else
{
        option host-name "bos-cart-unknown";
}
}


#Matching if the identifier matches or not.
class "sra"
{
  match if option dhcp-client-identifier = "SRA";

# If what was sent matches what currently is
if option local.identifier1 = option identifier
{
        option host-name "sra-01";
}
elsif option local.identifier2 = option identifier
{
        option host-name "sra-02";
}
else
{
        option host-name "bos-sra-unknown";
}
}

然而,这不起作用,第二个客户端总是获取主机名 BOS-SRA-未知。

如果我在这里做错了,请告诉我/有一个 不同的方法来解决这个问题。

0 个答案:

没有答案