Hi,
as I’m not that happy with the docs in regard to how the /ip/dhcp-server picks the right IP configuration defined in /ip/pool and /ip/dhcp-server network, I would like to share my interpretation, hoping it helps others as well.
Feel free to correct me.
IP pool can be any range, it does not have to much the intended subnet for the DHCP Server. Connections would just simply fail if /ip/pool and /ip dhcp-server network address are not within the same subnet.
DHCP Server identifies the intended network by the Address and Network (/ip/address) of the interface on which the DHCP Server shall run on
The /ip dhcp-server network which belongs to the DHCP-Server is identified by the match of /ip/address of DHCP Server’s Interface and the defined Gateway in /ip dhcp-server network.
/ip dhcp-server network address defines Broadcast and Netmask address
If the address assigned to the client from the pool doesn’t match the address prefix of any /ip dhcp-server network row, the client will get that address with a /32 netmask and with no defaul gateway. That is the reason why the “connections would fail” - the client has an address, but since the netmask is /32, it has to use a route (gateway) for anything it wants to send, but it has got no gateway either.
The DHCP server will assign an address from any pool attached to it, regardless the IP address(es) and netmask(s) attached to the same interface. The only way to choose a specific pool is currently to use an /ip dhcp-server vendor-class-id row.
The /ip dhcp-server network is a “profile” grouping additional parameters of the lease (default gateway, dns server list, …); it is chosen by best match of its address parameter (a prefix) to the leased address. It does not relate to the address attached to the interface to which the DHCP server is attached.
The address item on the /ip dhcp-server network row is a prefix used to match against the leased address to choose the best matching row and to specify a netmask in the lease; the latter can be overridden by setting the netmask item on that row, e.g. if you use multiple /ip dhcp-server network rows to assign different individual options to devices from different vendors in the same subnet (vendor class id → pool → network).