1

Using isc-dhcp-server on Debian Jessie, I'd like to block DHCP requests based on parts of their hostnames - specifically, if the hostname contains the RegEx string somewhere "iPhone|android-". My current solution is to wait until they have a lease, and monitor for those devices, and manually add the MAC address to the Blacklist file.

This black list method is getting quite large (almost 256 entries), and getting harder to maintain.

I understand how to check the beginning of the hostname to determine the class, but how do I check from any part of the hostname to determine which class to assign it?

Canadian Luke
  • 885
  • 14
  • 41

1 Answers1

3

It sounds like you're after the dhcp-client-identifier field, which may or may not be what you call the hostname. According to dhcp-eval(5), there may be a regex option available. If so,

class "iBan" {
    match if option dhcp-client-identifier ~= "iPhone";
}
class "bandroid" {
    match if option dhcp-client-identifier ~= "andriod-";
}

And then elsewhere deny members of those classes under the appropriate pool statement. (Or use a more complicated regex to do it in one class.)

thrig
  • 1,626
  • 9
  • 9