为特定 MAC 前缀分配 DHCP IP

Jon*_*ley 9 mac-address isc-dhcp

我正在为我的网络运行一个 ISC DHCPd 服务器,为多个子网提供服务。我想做的一件事是为具有公共 MAC 前缀(例如 00:01:02)的主机分配特定范围的 IP。此外,分配必须能够被具有固定地址的分配覆盖。我已经用谷歌搜索了它,但没有找到任何确定的东西。

如果我可以将语句放在我的 dhcpd.conf 的子网节中(它会更适合我的管理软件),那就太棒了。

top*_*gon 15

像这样的东西:

class "specialK" {
    match if substring (hardware, 1, 3) = 00:01:02;
}
subnet 10.0.0.0 netmask 255.255.255.0 {
    pool {
        range 10.0.0.16 10.0.0.32;
        allow members of "specialK";
    }
}
Run Code Online (Sandbox Code Playgroud)

嗯,应该是 (hardware, 0, 2) 还是 (.. 1, 3),测试一下。:)

  • +1 - 这比二进制到 ASCII 的东西更有效。另外 - 偏移量 1,3 是正确的,而不是 1,8。 (2认同)

小智 8

在我的系统(debian lenny)上,我需要二进制到 ascii 才能匹配 mac 地址。在我的 dhcpd.conf 中的这个(工作)示例中,server247 在“本地”类中,但是,我给它一个固定地址,它不在池中。我建议固定地址与动态分配的地址位于不同的范围内(它们仍然可以位于同一子网中)。

class "kvm" {
   match if binary-to-ascii(16,8,":",substring(hardware, 1, 2)) = "56:11";
}

class "local" {
   match if binary-to-ascii(16,8,":",substring(hardware, 1, 2)) = "52:54";
}

host meme {
 fixed-address 10.1.0.254;
}

host server247 {
  hardware ethernet 52:54:00:2f:ea:07;
  fixed-address 10.1.0.247;
}

subnet 10.1.0.224 netmask 255.255.255.224 {
  option routers 10.1.0.225;
  pool {
     allow members of "kvm";
     range 10.1.0.226 10.1.0.235;
  }
  pool {
     allow members of "local";
     range 10.1.0.236 10.1.0.240;
  }
  pool {
     # Don't use this pool. It is really just a range to reserve
     # for fixed addresses defined per host, above.
     allow known-clients;
     range 10.1.0.241 10.1.0.253;
  }
}
Run Code Online (Sandbox Code Playgroud)

对于您的示例,您将执行以下操作:

match if binary-to-ascii(16,8,":",substring(hardware, 1, 3)) = "00:01:02";
Run Code Online (Sandbox Code Playgroud)