Koozali.org: home of the SME Server

dhcpd.conf issue with class by vendor-class-identifier

Offline penguinuk5

  • 3
  • +0/-0
dhcpd.conf issue with class by vendor-class-identifier
« on: March 01, 2013, 08:14:39 PM »
Hello,

I have been using SME since 6/6.5 and have been very pleased with it. I have used several of the how-to and contrib posting to get various things done.
It is a home server, mostly for learning and playing. It has actually recentley been upgraded to V8, and is fairly clean. In fact apart from the playing with the DHCP there isn't anything non-standard.

I am trying to get the dhcpd server provide and option 66 with a tftp server address to several IP phones I have. This is mostly for testing zero config.

I can get the dhcpd to serve the option 66 to all hosts, but I wanted to clean it up and only give the option and a range of address' to the IP phones, and then other hosts are given IP's from the standard range.

Here is the relavant part of the dhcpd.conf . . .
Code: [Select]
# Addresses from 172.16.1.147 to 172.16.1.150 taken for PPTP sessions

authoritative;
ddns-update-style none;
log (info, option vendor-class-identifier);
option wpad-url code 252 = text;

class "ipphones"        {
        match if (
                (substring (option vendor-class-identifier,0,12) = "Cisco SPA504G")
                or
                (substring (option vendor-class-identifier,0,14) = "LINKSYS SPA-942")
        );
        option tftp-server-name "172.16.1.42";
}

class "unknown"        {
        match if (
                (substring (option vendor-class-identifier,0,12) != "Cisco SPA504G")
                or
                (substring (option vendor-class-identifier,0,14) != "LINKSYS SPA-942")
        );
}

subnet 172.16.1.0 netmask 255.255.255.0
{
    option broadcast-address    172.16.1.255;
    deny bootp;
    option domain-name  "icl-net.local";
    option domain-name-servers  172.16.1.2;
    default-lease-time          86400;
    max-lease-time              604800;
    option netbios-dd-server    172.16.1.2;
    option netbios-name-servers 172.16.1.2;
    option netbios-node-type    8;
    option subnet-mask          255.255.255.0;
    pool        {
                range 172.16.1.160 172.16.1.175;
                allow members of "ipphones";
    }
    pool        {
                range    172.16.1.10 172.16.1.146;
                allow members of "unknown";
    }
    option routers 172.16.1.1;
#   option tftp-server-name     "172.16.1.42";
    option wpad-url            "http://wpad.icl-net.local/wpad.dat";

}

I was working on this for some time yesterday and have had a quick look through for syntax issues (rubbish at seeing them in my own work), I am not certian if the order things are sone within the dhcpd.conf is an issue.

I would like some help in seeing if I have any basic faults, spelling, order issues in the attached code.

I have carried out the modifications by using the templates-custom method for creation of new parts of the file and modifying the existing portions (range in particular).

Obviously, if you need any extra information, please just ask.

Thank you for your help, I look forward to hearing from you.

Regards
Penguinuk5

p.s. this is my first post, so it might not be the best.
« Last Edit: March 01, 2013, 08:40:24 PM by penguinuk5 »

Offline penguinuk5

  • 3
  • +0/-0
Re: dhcpd.conf issue with class by vendor-class identifier
« Reply #1 on: March 01, 2013, 08:29:25 PM »
Further details;

It might have helped if I had attached some log entries from /var/log/dhcpd/current, so please find below some entries showing that the log instruction from dhcpd.conf is working . . .
Code: [Select]
@40000000513086463b8e0e3c Cisco SPA504G
@400000005130864700291d64 DHCPREQUEST for 172.16.1.17 from 58:bf:ea:10:52:cd (SPA58BFEA1052CD) via eth0
@400000005130864700292534 DHCPACK on 172.16.1.17 to 58:bf:ea:10:52:cd (SPA58BFEA1052CD) via eth0
---
@40000000512fe5131b85e024 LINKSYS SPA-942
@40000000512fe5131b85e7f4 DHCPDISCOVER from 00:0e:08:dd:01:76 (SipuraSPA) via eth0
@40000000512fe5140023936c DHCPOFFER on 172.16.1.23 to 00:0e:08:dd:01:76 (SipuraSPA) via eth0
@40000000512fe5140036c194 LINKSYS SPA-942
@40000000512fe514008cec2c DHCPREQUEST for 172.16.1.23 (172.16.1.2) from 00:0e:08:dd:01:76 (SipuraSPA) via eth0
@40000000512fe514008cf3fc DHCPACK on 172.16.1.23 to 00:0e:08:dd:01:76 (SipuraSPA) via eth0

I have also tried clearing the lease file.

I find it od that it still actually works as I have configured it to use the pool statment as the only option for handing out IP address. Will actually test to see if I can break it by changing pool conditions.

Regards
Penguinuk5

Offline penguinuk5

  • 3
  • +0/-0
Re: dhcpd.conf issue with class by vendor-class-identifier
« Reply #2 on: March 02, 2013, 01:04:20 AM »
Ok, I know this is not the best way to use the forums, but I seem to have solved it myself. Basically my use of the substring was rubbish.
Code: [Select]
(substring (option vendor-class-identifier,0,12) = "Cisco SPA504G")WRONG

Code: [Select]
(substring (option vendor-class-identifier,0,13) = "Cisco SPA504G")CORRECT !  :-P

Then it became a case of how I was performing the negation in the second class definition.
Code: [Select]
class "unknown"        {
        match if (
                (substring (option vendor-class-identifier,0,12) != "Cisco SPA504G")
                or
                (substring (option vendor-class-identifier,0,14) != "LINKSYS SPA-942")
        );
}

Now reads
Code: [Select]
class "TreeFuTom"        \{
        match if not (substring (option vendor-class-identifier,0,13) = "Cisco SPA504G")
        and not (substring (option vendor-class-identifier,0,15) = "LINKSYS SPA-942");
        log (info, "TreeFuTom");
\}

And yes, I was uncertain if the name of the class was causing the problem. So guess what my 3yr old daughter was watching at the time!  :-)

One useful thing that I did find, was that you can log the fact you have passed though a particular match for a class. I have since seen it documented elsewhere on the internet, but my rudimentry solution worked for me.

As the request passes through the dhcpd server, it throws out the lines starting with log so I was able to see that the IP Phones were being caught by both class definitions.

Hope this is of help to someone, and if there are any questions, please feel free to get back to me.

Regards
Penguinuk5

Offline johnp

  • ****
  • 312
  • +0/-0
Re: dhcpd.conf issue with class by vendor-class-identifier
« Reply #3 on: March 02, 2013, 02:49:18 AM »
I was going to say earlier that your lenght of string wasn't right. Seems you figured that out. :-)