Bit of help / guidance with a dhcpd.conf file

Glenn Satchell Glenn.Satchell at uniq.com.au
Tue Jul 1 14:05:07 UTC 2008


>Date: Mon, 30 Jun 2008 17:27:11 -0400
>From: "Japhy Bartlett" <japhy at pearachute.com>
>To: dhcp-users at isc.org
>Subject: Bit of help / guidance with a dhcpd.conf file
>
>Hi all -
>
>I'm trying to set up a dhcpd that will hand out IPs in different
>ranges, based on a list of known MAC addresses.
>
>As far as I can tell, the following .conf is the most effective way to
>do this ( though I would certainly appreciate more elegant solutions
>):
>
>###
>
>class "known" {
>   match
>   if ( binary-to-ascii (16,8,":", substring (option agent.remote-id,2,6) )
>        = "00:1b:38:75:a5:ea";
>   );
>}

The error message is spot on. a ';' is not expected or allowed inside the if 
statement! This should work:

   if ( binary-to-ascii (16,8,":", substring (option agent.remote-id,2,6) )
        = "00:1b:38:75:a5:ea"
   );

Also, there is no real need to convert the binary to a string, and then do a 
string comparison. You can use binary comparison:

    match if ( substring (option agent.remote-id,2,6) = 00:1b:38:75:a5:ea);

However, a better way would be to use sub-classes, see man dhcpd.conf:

class "known" {
    match substring (option agent.remote-id,2,6);
}
subclass "known" 00:1b:38:75:a5:ea;
subclass "known" 00:00:00:00:00:01;
# repeat for all sub-class matches.

The other errors are because you define each range twice: once in the
subnet and once in the pool. Because you want to use 'allow members of'
you must only define them in the pool. Despite what others have said it
is ok to have your pool definitions inside the shared subnet. dhcpd
will work out which subnet they correspond to, although it is usual to
define the pools within the subnet:

subnet ... {
  pool {
    ...
  }
}

regards,
-glenn
>
>
>So, restarting gives me:
>
>japhy at c1c1:/var/conf$ sudo dhcpd3 restart
>Internet Systems Consortium DHCP Server V3.0.6
>Copyright 2004-2007 Internet Systems Consortium.
>All rights reserved.
>For info, please visit http://www.isc.org/sw/dhcp/
>/etc/dhcp3/dhcpd.conf line 54: right paren expected
>        = "00:1b:38:75:a5:ea";
>                             ^
>/etc/dhcp3/dhcpd.conf line 101: lease 192.168.1.1 is declared twice!
>     range 192.168.1.1 192.168.1.254;
>                                     ^
>/etc/dhcp3/dhcpd.conf line 101: lease 192.168.1.2 is declared twice!
>     range 192.168.1.1 192.168.1.254;
>                                     ^
>/etc/dhcp3/dhcpd.conf line 106: lease 192.168.2.1 is declared twice!
>     range 192.168.2.1 192.168.2.254;
>                                     ^
>/etc/dhcp3/dhcpd.conf line 106: lease 192.168.2.2 is declared twice!
>     range 192.168.2.1 192.168.2.254;
>                                     ^
>Configuration file errors encountered -- exiting
>
>###
>
>No matter how I count it, I can't figure where or why it's expecting
>another paren.  I'm hoping this is just something silly.
>
>I guess I understand that it doesn't like two range statements.. but I
>don't understand how to tie those together.  Putting the allow/deny
>statements in the subnet {} gives different error messages.  I'm not
>sure I understand the difference between classes and groups either.
>
>In general, I feel like I'm close - I'm going to try a different
>approach using host statements and groups, but I (obviously) have some
>more man reading to do.  Any advice or guidance would be very helpful,
>and for what it's worth the result will be posted in public for all
>the world to see and use.
>
>Thanks for your time,
>
>Japhy
>



More information about the dhcp-users mailing list