如何在dhcpd中通过MAC地址分配IP?

如何使用dhcpd分配特定于mac地址的IP地址?

到目前为止,我尝试过

host blah { hardware ethernet <mac address>; fixed-address <ip address>;} 

在我的dhcpd.conf。 但重新启动dhcpd和问题的MAC地址的机器后,我只是得到一个随机IP。

这是非常好的格式 – 我使用完全相同。 只有在行尾添加注释(另外)。 这是从工作dhcpd.conf节选:

 host wrt45gl-etika { hardware ethernet 00:21:29:a1:c3:a1; fixed-address ---.219.43.135; } # MSIE routeris WRT54GL 

正如@Christoph所提到的那样,可能会声明全局选项(或使用服务默认),这可能会影响IP分配/可能覆盖的方式。

dhcp3-server (v3)迁移到isc-dhcp-server (v4)时,我需要添加一些必需的选项并重写一些声明。 但是configuration文件的结构很简单:

 # # Sample configuration file for ISC dhcpd for Debian # # The ddns-updates-style parameter controls whether or not the server will # attempt to do a DNS update when a lease is confirmed. We default to the # behavior of the version 2 packages ('none', since DHCP v2 didn't # have support for DDNS.) ddns-update-style none; # option definitions common to all supported networks... option domain-name "mf.vu.---"; option domain-name-servers ---.219.80.11, ---.219.80.2, ---.171.22.22; default-lease-time 2678400; max-lease-time 2678400; # If this DHCP server is the official DHCP server for the local # network, the authoritative directive should be uncommented. authoritative; # Use this to send dhcp log messages to a different log file (you also # have to hack syslog.conf to complete the redirection). log-facility local7; # The subnet that shares this physical network shared-network TOTAL_MF { server-name "letta.mf.vu.--"; subnet ---.219.43.128 netmask 255.255.255.192 { option routers ---.219.43.190; option broadcast-address ---.219.43.191; group { host wrt45gl-etika { hardware ethernet 00:21:29:a1:c3:a1; fixed-address ---.219.43.135; } # MSIE routeris WRT54GL # ... host saulute { hardware ethernet 00:21:28:10:f4:16; fixed-address ---.219.43.189; } # Virtual Qemu PC NIC } } subnet 172.16.43.128 netmask 255.255.255.192 { option routers 172.16.43.129; option broadcast-address 172.16.43.191; group{ host ligo { hardware ethernet 08:00:20:7A:E2:70; fixed-address 172.16.43.179; } #a225 ligo # ... host vumfsa2 { hardware ethernet 00:80:48:8d:12:f0; fixed-address 172.16.43.140; } # 118 } } } 

在那里我没有使用pool ,没有range声明。 只有两个子网声明(一个接一个)。

在那里我没有分配给我的主机的随机IP在这里声明(绑定到MAC)。

我不知道你的dhcpd.conf,但是如果你有一个allow unknown-clients语句,你应该添加allow known-clients

如果我记得正确的话,固定的IP不应该在你的DHCP服务器提供给客户端的范围内。

当主机有一个来自同一台DHCP服务器的旧地址时,服务器只要有效即可发出旧租约,即租约时间未过期。

如果你可以提供更多的configuration,这将有所帮助。

dhcpd.conf手册页中没有任何地方明确提及(现在我不能尝试),但是我总是认为每行只允许有一条语句。

 host blah { hardware ethernet <mac address>; fixed-address <ip address>; } 

你的冒号太多了:

从dhcpd.conf手册页:

  host ncd1 { hardware ethernet 0:c0:c3:49:2b:57; }