Bit of help / guidance with a dhcpd.conf file

Simon Hobson dhcp1 at thehobsons.co.uk
Mon Jun 30 22:13:17 UTC 2008


Japhy Bartlett wrote:

>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
>):

Far off, your conf won't work.

>###
>
>class "known" {
>    match
>    if ( binary-to-ascii (16,8,":", substring (option agent.remote-id,2,6) )
>         = "00:1b:38:75:a5:ea";
>    );
>}
>
>shared-network pearachute.net {
>
>authoritative;
>option domain-name "bh.pearachute.net";
>option domain-name-servers 216.163.32.51, 216.163.32.52,
>207.179.71.27, 207.179.70.27;
>default-lease-time 600;
>max-lease-time 7200;
>
>#This subnet should be statically assigned IPs, for servers, etc.
>subnet 192.168.0.0 netmask 255.255.255.0 {
>      range 192.168.0.1 192.168.0.2;
>      option broadcast-address 192.168.0.255;
>    }
>
>## known subnet:
>subnet 192.168.1.0 netmask 255.255.255.0 {
>      range 192.168.1.1 192.168.1.2;
>      option broadcast-address 192.168.1.255;
>    }
>
>## public subnet:
>    subnet 192.168.2.0 netmask 255.255.255.0 {
>      range 192.168.2.1 192.168.2.2;
>      option broadcast-address 192.168.2.255;
>    }
>
>    pool {
>      allow members of "known";
>      range 192.168.1.1 192.168.1.254;
>    }
>
>pool {
>      deny members of "known";
>      range 192.168.2.1 192.168.2.254;
>    {
>
>}
>
>###
>
>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.

If you read your config you will see that you have indeed defined 
multiple ranges with the same IP addresses. Also, several of your 
range statements are for addresses that are NOT valid for the subnet 
they are defined in.

In your subnet for static servers etc, you don't need a range defined.

For the other subnets, just define the range ONCE inside the subnet. 
Make it part of a pool with appropriate allow/deny statements.


More information about the dhcp-users mailing list