<html>
<head>
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">On 11/9/16 2:28 PM, <a
class="moz-txt-link-abbreviated"
href="mailto:mrobti@insiberia.net">mrobti@insiberia.net</a>
wrote:<br>
</div>
<blockquote
cite="mid:0b5c5c7b341345c276d6f30f603e74a8@insiberia.net"
type="cite">On 2016-11-09 07:56, Thomas Markwalder wrote: <br>
<blockquote type="cite">On 11/9/16 4:20 AM, <a
class="moz-txt-link-abbreviated"
href="mailto:mrobti@insiberia.net">mrobti@insiberia.net</a>
wrote: <br>
<blockquote type="cite">On 2016-11-08 15:44, <a
class="moz-txt-link-abbreviated"
href="mailto:mrobti@insiberia.net">mrobti@insiberia.net</a>
wrote: <br>
<blockquote type="cite">I want to assign a client-class using
hwaddr, from MySQL backend, and <br>
restrict a subnet for that client-class. In other words,
only allow <br>
clients with known MAC addresses to use the subnet they are
trying to <br>
connect to. <br>
<br>
DB hosts table has an entry for the client: <br>
dhcp4_subnet_id = 1 <br>
dhcp_identifier_type = 0 <br>
dhcp_identifier = UNHEX(REPLACE('aa:bb:cc:dd:ee:ff', ':',
'')) <br>
hostname = test.local <br>
dhcp4_client_classes = test_class <br>
<br>
Config file has: <br>
"client-classes": [ { <br>
"name": "test_class" <br>
} ], <br>
"subnet4": [ { <br>
"id": 1, <br>
"subnet": "192.168.1.0/24", <br>
"pools": [ { "pool": "192.168.1.10 - 192.168.1.20" } ], <br>
"client-class": "test_class" <br>
} ], <br>
<br>
But Kea says (debug level 50): <br>
: client packet has been assigned to the following
class(es): <br>
VENDOR_CLASS_MSFT 5.0 <br>
: failed to select subnet for the client <br>
: no suitable subnet configured for a direct client <br>
<br>
It works if I remove "client-class" from the subnet
definition, so <br>
something is not synchronizing the class somewhere. <br>
<br>
Could it be a problem that the DB hosts entry has no
ipv4_address <br>
listed? (that column is NULL) I don't have any other ideas.
<br>
</blockquote>
<br>
I've found this in the logs: <br>
<br>
: HOSTS_CFG_GET_ALL_IDENTIFIER get all hosts with reservations
using <br>
identifier: hwaddr=aa:bb:cc:dd:ee:ff <br>
: HOSTS_CFG_GET_ALL_IDENTIFIER_COUNT using identifier <br>
hwaddr=aa:bb:cc:dd:ee:ff, found 0 host(s) <br>
<br>
Why would this happen? Yes, I double checked the MAC address.
I <br>
enabled MySQL logging, and I can't match up timestamps
exactly, but I <br>
do find a query: <br>
<br>
SELECT host_id, dhcp_identifier, dhcp_identifier_type, <br>
dhcp4_subnet_id, dhcp6_subnet_id, ipv4_address, hostname, <br>
dhcp4_client_classes, dhcp6_client_classes FROM hosts WHERE <br>
dhcp4_subnet_id = ? AND dhcp_identifier_type = ? AND <br>
dhcp_identifier = ? <br>
<br>
I don't know if it's possible to see the executed version of
this <br>
prepared query(?). Is it possible that the value Kea is
placing in the <br>
query is not the correct binary string? <br>
_______________________________________________ <br>
Kea-users mailing list <br>
<a class="moz-txt-link-abbreviated"
href="mailto:Kea-users@lists.isc.org">Kea-users@lists.isc.org</a>
<br>
<a class="moz-txt-link-freetext"
href="https://lists.isc.org/mailman/listinfo/kea-users">https://lists.isc.org/mailman/listinfo/kea-users</a>
<br>
</blockquote>
<br>
Hello: <br>
<br>
We are looking into this for you. As you probably know, Kea
will look <br>
first for hosts defined its configuration file and then within
the hosts <br>
database (if it is specified). Any log statements you see that
contain <br>
"HOSTS_CFG_" pertain to looking at hosts defined via the
configuration <br>
file. In your case, since there are none, you see none found.
When Kea <br>
accesses the host database the logs should contain <br>
HOSTS_MGR_ALTERNATIVE_. The following is a snippet from of the
log in <br>
a setup I am testing with: <br>
<br>
2016-11-09 10:18:45.018 DEBUG [kea-dhcp4.hosts/24940] <br>
HOSTS_CFG_GET_ONE_SUBNET_ID_ADDRESS4 get one host with
reservation for <br>
subnet id 1 and IPv4 address 178.16.1.101 <br>
2016-11-09 10:18:45.018 DEBUG [kea-dhcp4.hosts/24940] <br>
HOSTS_CFG_GET_ALL_ADDRESS4 get all hosts with reservations for
IPv4 <br>
address 178.16.1.101 <br>
2016-11-09 10:18:45.018 DEBUG [kea-dhcp4.hosts/24940] <br>
HOSTS_CFG_GET_ALL_ADDRESS4_COUNT using address 178.16.1.101,
found 0 host(s) <br>
2016-11-09 10:18:45.018 DEBUG [kea-dhcp4.hosts/24940] <br>
HOSTS_CFG_GET_ONE_SUBNET_ID_ADDRESS4_NULL host not found using
subnet id <br>
1 and address 178.16.1.101 <br>
2016-11-09 10:18:45.018 DEBUG [kea-dhcp4.hosts/24940] <br>
HOSTS_MGR_ALTERNATE_GET4_SUBNET_ID_ADDRESS4 trying alternate
source for <br>
host using subnet id 1 and address 178.16.1.101 <br>
<br>
The last log statement indicates that Kea is looking in MySQL
for hosts <br>
that have the allocated address. It just so happens that Kea
actually <br>
conducted a search in MySQL prior to the last one show above.
This <br>
search is done by subnet id and dhcp identifier. However the
function <br>
that performs this search happens to be missing a log entry.
This is <br>
why you see the two selects you cited in the MySQL log but
only one <br>
log message against the alternate. The original function we
used <br>
was deprecated without the new one getting a log message. Sorry
about <br>
that. <br>
<br>
On the surface, it looks like Kea should be matching your host,
we're <br>
still researching it. You might try defining your host in the <br>
configuration file, for testing purposes. Do you have a packet
capture <br>
and what version of Kea are you running? <br>
</blockquote>
<br>
Thank you for your response. I don't have a packet capture at the
moment, but I do see the HOSTS_MGR_ALTERNATE_ line just like
yours. I'm running the ubuntu package which shows version 1.0.0,
the package name is version 1.0.0-1build1. I know that's behind
the curve, but sometimes don't these packages include bugfixes
from newer versions than they report? <br>
<br>
I can begrudgingly compile from source, but would not be happy
taking it outside the system package manager. <br>
<br>
I just tried to test by putting the host in the config file, got
this startup error: <br>
DHCP4_PARSER_FAIL failed to create or run parser for configuration
element subnet4: unsupported configuration parameter
'client-classes' <br>
<br>
</blockquote>
I think you meant client-classes failed to parse as part of the host
element (not subnet4) ? But yes, "client-classes" was added in
1.1.0. 1.1.0 added a good deal more functionality to the RDBMS Host
Reservations implementations, as well as a lot more with
classification expression matching. <br>
<blockquote
cite="mid:0b5c5c7b341345c276d6f30f603e74a8@insiberia.net"
type="cite">Looks like assigning client-classes to host
reservations was a feature only added after version 1.0? Can you
please confirm when it was added? <br>
_______________________________________________ <br>
Kea-users mailing list <br>
<a class="moz-txt-link-abbreviated"
href="mailto:Kea-users@lists.isc.org">Kea-users@lists.isc.org</a>
<br>
<a class="moz-txt-link-freetext"
href="https://lists.isc.org/mailman/listinfo/kea-users">https://lists.isc.org/mailman/listinfo/kea-users</a>
<br>
</blockquote>
<p>When an inbound packet is received things happen in this order:</p>
<p>1. The packet is classified by evaluating it against the test
expression for defined classes</p>
<p>2. Subnet matching is conducted based on packet content. This
includes comparing the classes matched to the packet in step 1
against the classes specified by the subnet's "client-class" list.</p>
<p>3. Look for host reservations</p>
<p>The problem you have is two fold. First, your "test-class" does
not define a "test" expression and thus matching it against a
packet always fails. This causes the subnet selection to fail
and the server drops the packet. The second issue is that you are
assigning a class to the host reservation, but associating the
client to a reservation occurs after the subnet selection. This
is something of a chicken-and-the-egg situation.<br>
</p>
<p>So while you can specify that a host belongs to one or more
classes, this currently only means the host inherits options from
those classes. <br>
</p>
<p>I think it would help to understand what problem you are trying
to solve. Are you trying to ensure that only known clients get
addresses? Are you trying to map specific hosts to specific
subnets? How any hosts in how many subnets do you anticipate
having?<br>
</p>
<p>If your network isn't large, you could define a class for each
host whose "test" expression matches the host's hardware address.
Then add these classes to the desired subnet4 client-class list.
Not ideal but it would work. This would be akin to ISC DHCP
sub-classing, though not quite as neat. Another alternative
would be to write a hook but we would need to understand your
problem to offer a more detailed suggestion. Our example hook
library, user-chk, does something similar to what you're after
and is a good starting point for what is possible,
<a class="moz-txt-link-freetext" href="http://kea.isc.org/docs/kea-guide.html#idp54000992">http://kea.isc.org/docs/kea-guide.html#idp54000992</a>. Hooks are
described in detail in our developer's guide:
<a class="moz-txt-link-freetext" href="https://jenkins.isc.org/job/Kea_doc/doxygen/df/d46/hooksdgDevelopersGuide.html">https://jenkins.isc.org/job/Kea_doc/doxygen/df/d46/hooksdgDevelopersGuide.html</a>.</p>
<p><br>
</p>
<p>Thomas Markwalder</p>
<p>ISC Software Engineering<br>
</p>
</body>
</html>