当有两个来自同一 MAC 地址的请求时,如何防止 ISC-DHCPD 提供不同的 IP

当有两个来自同一 MAC 地址的请求时,如何防止 ISC-DHCPD 提供不同的 IP

我有一组节点,它们的地址来自 ISC-DHCPD。由于它们使用 PXE 启动,因此会有两轮 DHCP(一轮来自 PXE,一轮来自 OS),并且出于某种原因,ISC-DHCPD 将提供两个不同的 IP。这很糟糕,因为节点的编号应该与 IP 的最后一个字节相对应。

以下是 Syslog 的摘录,显示了正在发生的事情:

May 25 23:16:26 cluster dhcpd: DHCPDISCOVER from 08:00:27:d3:d5:3b via eth1
May 25 23:16:27 cluster dhcpd: DHCPOFFER on 192.168.0.1 to 08:00:27:d3:d5:3b via eth1
May 25 23:16:29 cluster dhcpd: DHCPREQUEST for 192.168.0.1 (192.168.0.254) from 08:00:27:d3:d5:3b via eth1
May 25 23:16:29 cluster dhcpd: DHCPACK on 192.168.0.1 to 08:00:27:d3:d5:3b via eth1
May 25 23:17:07 cluster dhcpd: DHCPDISCOVER from 08:00:27:d3:d5:3b via eth1
May 25 23:17:08 cluster dhcpd: DHCPOFFER on 192.168.0.2 to 08:00:27:d3:d5:3b via eth1
May 25 23:17:08 cluster dhcpd: DHCPREQUEST for 192.168.0.2 (192.168.0.254) from 08:00:27:d3:d5:3b via eth1
May 25 23:17:08 cluster dhcpd: DHCPACK on 192.168.0.2 to 08:00:27:d3:d5:3b via eth1
May 25 23:17:08 cluster dhcpd: DHCPREQUEST for 192.168.0.2 (192.168.0.254) from 08:00:27:d3:d5:3b via eth1
May 25 23:17:08 cluster dhcpd: DHCPACK on 192.168.0.2 to 08:00:27:d3:d5:3b via eth1

以下是租约文件中的相应摘录:

lease 192.168.0.1 {
  starts 1 2015/05/25 21:16:28;
  ends 5 2151/07/02 03:44:43;
  cltt 1 2015/05/25 21:16:28;
  binding state active;
  next binding state free;
  rewind binding state free;
  hardware ethernet 08:00:27:d3:d5:3b;
  uid "\001\010\000'\323\325;";
}
lease 192.168.0.2 {
  starts 1 2015/05/25 21:17:08;
  ends 5 2151/07/02 03:45:23;
  cltt 1 2015/05/25 21:17:08;
  binding state active;
  next binding state free;
  rewind binding state free;
  hardware ethernet 08:00:27:d3:d5:3b;
}
lease 192.168.0.2 {
  starts 1 2015/05/25 21:17:08;
  ends 5 2151/07/02 03:45:23;
  cltt 1 2015/05/25 21:17:08;
  binding state active;
  next binding state free;
  rewind binding state free;
  hardware ethernet 08:00:27:d3:d5:3b;
}

这是 dhcp 服务器的配置:

ddns-update-style none;

default-lease-time -1;
max-lease-time -1;

authoritative;

allow booting;
allow bootp;
next-server 192.168.0.254;
filename "/pxelinux.0";

log-facility local7;

subnet 192.168.0.0 netmask 255.255.255.0 {

    range 192.168.0.1 192.168.0.253;
    interface eth1;
    option routers 192.168.0.254;
    option domain-name "cluster.hpc.org";
    option domain-name-servers 192.168.0.254;

}

答案1

您可以使用 ignore-client-uids 标志获取它。它自 isc-dchpd 4.2.0 版本起就已包含:

添加此行:

忽略客户端 uids true;

     ignore-client-uids flag;

     If the ignore-client-uids statement is present and has a value of
     true or on, the UID for clients will not be recorded.  If this
     statement is not present or has a value of false or off, then client
     UIDs will be recorded.

答案2

尝试类似

ddns-update-style none;

# Client control
deny duplicates;
one-lease-per-client on;

# Lease authority
default-lease-time 3600;
min-lease-time 3600;
max-lease-time 21600;

authoritative;

allow booting;
allow bootp;
next-server 192.168.0.254;
filename "/pxelinux.0";

log-facility local7;

subnet 192.168.0.0 netmask 255.255.255.0 {

    range 192.168.0.1 192.168.0.253;
    interface eth1;
    option routers 192.168.0.254;
    option domain-name "cluster.hpc.org";
    option domain-name-servers 192.168.0.254;

}
  deny duplicates;

   Host declarations can match client messages based on  the  DHCP  Client
   Identifier  option  or  based on the client's network hardware type and
   MAC address.   If the MAC address is used, the  host  declaration  will
   match  any  client  with that MAC address - even clients with different
   client identifiers.   This doesn't normally  happen,  but  is  possible
   when  one computer has more than one operating system installed on it -
   for example, Microsoft Windows and NetBSD or Linux.

   The duplicates flag tells the DHCP server that if a request is received
   from  a  client that matches the MAC address of a host declaration, any
   other leases matching that MAC  address  should  be  discarded  by  the
   server,  even  if the UID is not the same.   This is a violation of the
   DHCP protocol, but can prevent clients whose client identifiers  change
   regularly  from  holding  many  leases  at  the same time.  By default,
   duplicates are allowed.

来源

http://www.bctes.com/dhcpd.conf.5.html

http://www.xdracco.net/howto-configure-and-deploy-isc-dhcp-server/

相关内容