How can I assign an IP by MAC address in dhcpd
This is perfectly fine format -- I use exactly the same. Only I append a comment in the end of line (in addition). This is excerpt from working dhcpd.conf
:
host wrt45gl-etika { hardware ethernet 00:21:29:a1:c3:a1; fixed-address ---.219.43.135; } # MSIE routeris WRT54GL
As @Christoph mentions, there may be global option declared (or service defaults used) which may impact a way IPs are assigned / may override it.
While migrating from dhcp3-server (v3) to isc-dhcp-server (v4) I needed to add some mandatory options and rewrite some declarations. But the structure of config file remained simple:
#
# 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
}
}
}
There I used no pool
, no range
declarations. There are only two subnet declarations (one followed by another).
There I got no random IPs assigned to my hosts which are declared here (tied to MACs).
There is no explicit mention anywhere in the dhcpd.conf
man page (and I can't try it now), but I always assumed that there is only one statement allowed per line.
host blah {
hardware ethernet <mac address>;
fixed-address <ip address>;
}
I don't know your dhcpd.conf, but if you have an allow unknown-clients
statement, you should add allow known-clients
.
If I recall correctly, the fixed IP should not be inside the range your DHCP-Server hands out to clients.
When the host has an old address from the same DHCP-Server, the server may hand out the old lease as long as it is valid, i.e. lease time not expired.
It would help, if you could provide more of your config.