Adding via logic multiple devices to a CLASS

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Adding via logic multiple devices to a CLASS

Tom Priore
I have a dhcpd.conf file thats getting very hard to manage.  Part of the problem is I'm building alot of classes base on matching MAC address of remote agent IDs.  Is there a way to make a single class that will multiple mac matches?

Here is what I have for example:

class "WAP-CM-13104A" {
  match if ((substring(option vendor-class-identifier,0,6) != "docsis") and (binary-to-ascii(16, 8, ":", suffix( option agent.remote-id, 6)) = "78:71:9c:f5:ea:db"));
  spawn with hardware;
}

class "WAP-CM-512A" {
  match if ((substring(option vendor-class-identifier,0,6) != "docsis") and (binary-to-ascii(16, 8, ":", suffix( option agent.remote-id, 6)) = "7c:b2:1b:9e:3:26"));
  spawn with hardware;
}

class "WAP-CM-514A" {
  match if ((substring(option vendor-class-identifier,0,6) != "docsis") and (binary-to-ascii(16, 8, ":", suffix( option agent.remote-id, 6)) = "7c:b2:1b:9d:7e:fc"));
  spawn with hardware;
}

I would like to have a single class with all 3 macs in it.

Is that possible? Does anyone know the syntax?  Would something like this work?  Is there a less clunky way?  Note, I still need multiple classes. I cant dump all the docis devices into on class.


class "MODEMCLIENT" {
   match if ((substring(option vendor-class-identifier,0,6) != "docsis") and ((binary-to-ascii(16, 8, ":", suffix( option agent.remote-id, 6)) = "7c:b2:1b:9d:7e:fc") or (binary-to-ascii(16, 8, ":", suffix( option agent.remote-id, 6)) = "7c:b2:1b:9e:3:26") or (binary-to-ascii(16, 8, ":", suffix( option agent.remote-id, 6)) = "78:71:9c:f5:ea:db"));
  spawn with hardware;
}

Thanks
Tom

_______________________________________________
dhcp-users mailing list
[hidden email]
https://lists.isc.org/mailman/listinfo/dhcp-users
Reply | Threaded
Open this post in threaded view
|

Re: Adding via logic multiple devices to a CLASS

Simon Hobson
Tom Priore <[hidden email]> wrote:

> I have a dhcpd.conf file thats getting very hard to manage.  Part of the problem is I'm building alot of classes base on matching MAC address of remote agent IDs.  Is there a way to make a single class that will multiple mac matches?

I suspect that subclasses are what you are after. Not sure from looking at the examples in the man page how it would work with two match clauses (ie substring(option vendor-class-identifier,0,6) != "docsis" and a MAC address) as the examples only show a single match on MAC address. I suspect you might end up with something like :

class "MODEMCLIENT" {
  match concat ( substring(option vendor-class-identifier,0,6), suffix( option agent.remote-id, 6) )
  ...
}

subclass "MODEMCLIENT" concat("??????", 1:7c:b2:1b:9d:7e:fc) ;

Do you know what the vendor class identifiers are for the devices you are trying to serve (ie the ?????? above) ? I take it you can't just use the agent.remote-id on it's own ?

_______________________________________________
dhcp-users mailing list
[hidden email]
https://lists.isc.org/mailman/listinfo/dhcp-users
Reply | Threaded
Open this post in threaded view
|

Re: Adding via logic multiple devices to a CLASS

Tom Priore
Thanks for the help. I have no way of controlling or predicting the vendor identifiers.  Anything from that agent.id will end up in the same range.  

On Jun 28, 2017 4:49 AM, "Simon Hobson" <[hidden email]> wrote:
Tom Priore <[hidden email]> wrote:

> I have a dhcpd.conf file thats getting very hard to manage.  Part of the problem is I'm building alot of classes base on matching MAC address of remote agent IDs.  Is there a way to make a single class that will multiple mac matches?

I suspect that subclasses are what you are after. Not sure from looking at the examples in the man page how it would work with two match clauses (ie substring(option vendor-class-identifier,0,6) != "docsis" and a MAC address) as the examples only show a single match on MAC address. I suspect you might end up with something like :

class "MODEMCLIENT" {
  match concat ( substring(option vendor-class-identifier,0,6), suffix( option agent.remote-id, 6) )
  ...
}

subclass "MODEMCLIENT" concat("??????", 1:7c:b2:1b:9d:7e:fc) ;

Do you know what the vendor class identifiers are for the devices you are trying to serve (ie the ?????? above) ? I take it you can't just use the agent.remote-id on it's own ?

_______________________________________________
dhcp-users mailing list
[hidden email]
https://lists.isc.org/mailman/listinfo/dhcp-users


_______________________________________________
dhcp-users mailing list
[hidden email]
https://lists.isc.org/mailman/listinfo/dhcp-users
Reply | Threaded
Open this post in threaded view
|

Re: Adding via logic multiple devices to a CLASS

Patrick Trapp
Sorry, I have not been following this closely and may not be understanding your requirements. I had a problem in my dhcp.conf where I needed to isolate specific MAC addresses and did so with host entries.

To make them more manageable, I am using an include file consisting of only related host entries, as in all devices of type X are in the same include file. When I need to add a new one, I can copy one of the existing entries, very important for those folks that assist me irregularly that don't know why or how it works. I name the device to facilitate finding it later (they are end-user devices associated with customer accounts and occasionally need to be removed or rarely modified) and use grep on all files in the parent directory to find them. 

If this is sounding remotely pertinent, I would be happy to share specifics when I return to my office tomorrow.

Patrick

On Jul 2, 2017, at 4:13 PM, Tom Priore <[hidden email]> wrote:

Thanks for the help. I have no way of controlling or predicting the vendor identifiers.  Anything from that agent.id will end up in the same range.  

On Jun 28, 2017 4:49 AM, "Simon Hobson" <[hidden email]> wrote:
Tom Priore <[hidden email]> wrote:

> I have a dhcpd.conf file thats getting very hard to manage.  Part of the problem is I'm building alot of classes base on matching MAC address of remote agent IDs.  Is there a way to make a single class that will multiple mac matches?

I suspect that subclasses are what you are after. Not sure from looking at the examples in the man page how it would work with two match clauses (ie substring(option vendor-class-identifier,0,6) != "docsis" and a MAC address) as the examples only show a single match on MAC address. I suspect you might end up with something like :

class "MODEMCLIENT" {
  match concat ( substring(option vendor-class-identifier,0,6), suffix( option agent.remote-id, 6) )
  ...
}

subclass "MODEMCLIENT" concat("??????", 1:7c:b2:1b:9d:7e:fc) ;

Do you know what the vendor class identifiers are for the devices you are trying to serve (ie the ?????? above) ? I take it you can't just use the agent.remote-id on it's own ?

_______________________________________________
dhcp-users mailing list
[hidden email]
https://lists.isc.org/mailman/listinfo/dhcp-users

_______________________________________________
dhcp-users mailing list
[hidden email]
https://lists.isc.org/mailman/listinfo/dhcp-users

_______________________________________________
dhcp-users mailing list
[hidden email]
https://lists.isc.org/mailman/listinfo/dhcp-users
Reply | Threaded
Open this post in threaded view
|

Re: Adding via logic multiple devices to a CLASS

Simon Hobson
In reply to this post by Tom Priore

On 2 Jul 2017, at 22:11, Tom Priore <[hidden email]> wrote:

> Thanks for the help. I have no way of controlling or predicting the vendor identifiers.  Anything from that agent.id will end up in the same range.

I think I have another idea that will work. You'll need to check the man pages for the syntax - I believe man dhcp-eval will be the most pertinent - as it's an area I've not used myself. But, if you do a bit of variable setting I think it might work, like this pseudo-code :

if substring(option vendor-class-identifier,0,6) != "docsis"
then
  set device = suffix( option agent.remote-id, 6)
else
  set device = ""

class "MODEMCLIENT" {
  match device
  ...
}

subclass "MODEMCLIENT" 7c:b2:1b:9d:7e:fc ;

So what this is doing is looking at your vendor class and if it's not "docsis" then it's setting the variable device to be the remote ID (else it sets it to blank). You then define a class which matches on that variable, and use subclasses to simplify matching devices into the class.

_______________________________________________
dhcp-users mailing list
[hidden email]
https://lists.isc.org/mailman/listinfo/dhcp-users