To add some filter rules in conf file

Simon Hobson dhcp1 at thehobsons.co.uk
Tue Oct 20 16:12:43 UTC 2009


Ashmath Khan wrote:

>class "red" {
>        match if (option color = "red");
>}
>
>class "fat" {
>        match if (option color != "red") && (option weight = "fat");
>}
>
>class "tall" {
>        match if (option color != "red") && (option weight != "fat") 
>&& (option height = "tall");
>}
>
>class "cold" {
>        match if (option color != "red") && (option weight != "fat") 
>&& (option height != "tall");
>}
>
>        ...
>        pool {
>                range 10.0.0.1 10.0.0.254;
>                allow members of "red";
>        }
>        pool {
>                range 10.0.1.1 10.0.1.254;
>                allow members of "fat";
>        }
>        pool {
>                range 10.0.2.1 10.0.2.254;
>                allow members of "tall";
>        }
>        pool {
>                range 10.0.3.1 <http://10.0.3.254>10.0.3.254:
>                allow members of "cold";
>        }
>        ...
>
>No variables required, I think.
>
>
>How do I choose a pool say if option height is absent ? I would have 
>to use deny etc
>I think I can't achieve this because I have to choose pool sometimes 
>when there is no match(option is absent).  Or sometimes I have to 
>discard a client if a match is found etc.

It will work for ANY combination of tests you want. If you look 
carefully then you've :

a class that matches if colour is red
a class that matches if colour isn't red and weight is fat
a class that matches if colour isn't red, weight isn't fat, and height is tall
and the fourth class that matches if none of the above are true.

Notice that the last class matches if none of the previous classes 
match - by definition ANY client will match exactly ONE class.

If you want a test for "option is not present" then you can do something like :
match if option colour is not present
match if option colour is present and colour is red
match if option colour is present and not colour is red and ...

-- 
Simon Hobson

Visit http://www.magpiesnestpublishing.co.uk/ for books by acclaimed
author Gladys Hobson. Novels - poetry - short stories - ideal as
Christmas stocking fillers. Some available as e-books.



More information about the dhcp-users mailing list