]> git.pld-linux.org Git - packages/dhcp.git/blame - dhcp-README.ldap
- check networking very early
[packages/dhcp.git] / dhcp-README.ldap
CommitLineData
8c878a4c
ER
1LDAP Support in DHCP
2Brian Masney <masneyb@ntelos.net>
3Last updated 3/23/2003
4
5This document describes setting up the DHCP server to read it's configuration
6from LDAP. This work is based on the IETF document
7draft-ietf-dhc-ldap-schema-01.txt included in the doc directory. For the
8latest version of this document, please see http://home.ntelos.net/~masneyb.
9
10First question on most people's mind is "Why do I want to store my
11configuration in LDAP?" If you run a small DHCP server, and the configuration
12on it rarely changes, then you won't need to store your configuration in LDAP.
13But, if you have several DHCP servers, and you want an easy way to manage your
14configuration, this can be a solution.
15
16The first step will be to setup your LDAP server. I am using OpenLDAP from
17www.openldap.org. Building and installing OpenLDAP is beyond the scope of
18this document. There is plenty of documentation out there about this. Once
19you have OpenLDAP installed, you will have to edit your slapd.conf file. I
20added the following 2 lines to my configuration file:
21
22include /etc/ldap/schema/dhcp.schema
23index dhcpHWAddress eq
24index dhcpClassData eq
25
26The first line tells it to include the dhcp schema file. You will find this
27file under the contrib directory in this distribution. You will need to copy
28this file to where your other schema files are (maybe
29/usr/local/openldap/etc/openldap/schema/). The second line sets up an index
30for the dhcpHWAddress parameter. The third parameter is for reading subclasses
31from LDAP every time a DHCP request comes in. Make sure you run the slapindex
32command and restart slapd to have these changes to into effect.
33
34Now that you have LDAP setup, you should be able to use gq
35(http://biot.com/gq/) to verify that the dhcp schema file is loaded into LDAP.
36Pull up gq, and click on the Schema tab. Go under objectClasses, and you
37should see at least the following object classes listed: dhcpClass, dhcpGroup,
38dhcpHost, dhcpOptions, dhcpPool, dhcpServer, dhcpService, dhcpSharedNetwork,
39dhcpSubClass, and dhcpSubnet. If you do not see these, you need to check over
40your LDAP configuration before you go any further.
41
42You should now be ready to build DHCP. If you would like to enable LDAP over
43SSL, you will need to perform the following steps:
44
45 * Edit the includes/site.h file and uncomment the USE_SSL line
46 or specify "-DUSE_SSL" via CFLAGS.
47 * Edit the dst/Makefile.dist file and remove md5_dgst.c and md5_dgst.o
48 from the SRC= and OBJ= lines (around line 24)
49 * Now run configure in the base source directory. If you chose to enable
50 LDAP over SSL, you must append -lcrypto -lssl to the LIBS= line in the
51 file work.os/server/Makefile (replace os with your operating system,
52 linux-2.2 on my machine). You should now be able to type make to build
53 your DHCP server.
54
55If you choose to not enable LDAP over SSL, then you only need to run configure
56and make in the toplevel source directory.
57
58Once you have DHCP installed, you will need to setup your initial plaintext
59config file. In my /etc/dhcpd.conf file, I have:
60
61ldap-server "localhost";
62ldap-port 389;
63ldap-username "cn=DHCP User, dc=ntelos, dc=net";
64ldap-password "blah";
65ldap-base-dn "dc=ntelos, dc=net";
66ldap-method dynamic;
67ldap-debug-file "/var/log/dhcp-ldap-startup.log";
68
69If SSL has been enabled at compile time using the USE_SSL flag, the dhcp
70server trys to use TLS if possible, but continues without TLS if not.
71
72You can modify this behaviour using following option in /etc/dhcpd.conf:
73
74ldap-ssl <off | ldaps | start_tls | on>
75 off: disables TLS/LDAPS.
76 ldaps: enables LDAPS -- don't forget to set ldap-port to 636.
77 start_tls: enables TLS using START_TLS command
78 on: enables LDAPS if ldap-port is set to 636 or TLS in
79 other cases.
80
81See also "man 5 ldap.conf" for description the following TLS related
82options:
83 ldap-tls-reqcert, ldap-tls-ca-file, ldap-tls-ca-dir, ldap-tls-cert
84 ldap-tls-key, ldap-tls-crlcheck, ldap-tls-ciphers, ldap-tls-randfile
85
86All of these parameters should be self explanatory except for the ldap-method.
87You can set this to static or dynamic. If you set it to static, the
88configuration is read once on startup, and LDAP isn't used anymore. But, if
89you set this to dynamic, the configuration is read once on startup, and the
90hosts that are stored in LDAP are looked up every time a DHCP request comes
91in.
92
93When the optional statement ldap-debug-file is specified, on startup the DHCP
94server will write out the configuration that it generated from LDAP. If you
95are getting errors about your LDAP configuration, this is a good place to
96start looking.
97
98The next step is to set up your LDAP tree. Here is an example config that will
99give a 10.100.0.x address to machines that have a host entry in LDAP.
100Otherwise, it will give a 10.200.0.x address to them. (NOTE: replace
101dc=ntelos, dc=net with your base dn). If you would like to convert your
102existing dhcpd.conf file to LDIF format, there is a script
103contrib/dhcpd-conf-to-ldap.pl that will convert it for you. Type
104dhcpd-conf-to-ldap.pl --help to see the usage information for this script.
105
106# You must specify the server's host name in LDAP that you are going to run
107# DHCP on and point it to which config tree you want to use. Whenever DHCP
108# first starts up, it will do a search for this entry to find out which
109# config to use
110dn: cn=brian.ntelos.net, dc=ntelos, dc=net
111objectClass: top
112objectClass: dhcpServer
113cn: brian.ntelos.net
114dhcpServiceDN: cn=DHCP Service Config, dc=ntelos, dc=net
115
116# Here is the config tree that brian.ntelos.net points to.
117dn: cn=DHCP Service Config, dc=ntelos, dc=net
118cn: DHCP Service Config
119objectClass: top
120objectClass: dhcpService
121dhcpPrimaryDN: dc=ntelos, dc=net
122dhcpStatements: ddns-update-style none
123dhcpStatements: default-lease-time 600
124dhcpStatements: max-lease-time 7200
125
126# Set up a shared network segment
127dn: cn=WV Test, cn=DHCP Service Config, dc=ntelos, dc=net
128cn: WV
129objectClass: top
130objectClass: dhcpSharedNetwork
131
132# Set up a subnet declaration with a pool statement. Also note that we have
133# a dhcpOptions object with this entry
134dn: cn=10.100.0.0, cn=WV Test, cn=DHCP Service Config, dc=ntelos, dc=net
135cn: 10.100.0.0
136objectClass: top
137objectClass: dhcpSubnet
138objectClass: dhcpOptions
139dhcpOption: domain-name-servers 10.100.0.2
140dhcpOption: routers 10.100.0.1
141dhcpOption: subnet-mask 255.255.255.0
142dhcpOption: broadcast-address 10.100.0.255
143dhcpNetMask: 24
144
145# Set up a pool for this subnet. Only known hosts will get these IPs
146dn: cn=Known Pool, cn=10.100.0.0, cn=WV Test, cn=DHCP Service Config, dc=ntelos, dc=net
147cn: Known Pool
148objectClass: top
149objectClass: dhcpPool
150dhcpRange: 10.100.0.3 10.100.0.254
151dhcpPermitList: deny unknown-clients
152
153# Set up another subnet declaration with a pool statement
154dn: cn=10.200.0.0, cn=WV Test, cn=DHCP Service Config, dc=ntelos, dc=net
155cn: 10.200.0.0
156objectClass: top
157objectClass: dhcpSubnet
158objectClass: dhcpOptions
159dhcpOption: domain-name-servers 10.200.0.2
160dhcpOption: routers 10.200.0.1
161dhcpOption: subnet-mask 255.255.255.0
162dhcpOption: broadcast-address 10.200.0.255
163dhcpNetMask: 24
164
165# Set up a pool for this subnet. Only unknown hosts will get these IPs
166dn: cn=Known Pool, cn=10.200.0.0, cn=WV Test, cn=DHCP Service Config, dc=ntelos, dc=net
167cn: Known Pool
168objectClass: top
169objectClass: dhcpPool
170dhcpRange: 10.200.0.3 10.200.0.254
171dhcpPermitList: deny known clients
172
173# Set aside a group for all of our known MAC addresses
174dn: cn=Customers, cn=DHCP Service Config, dc=ntelos, dc=net
175objectClass: top
176objectClass: dhcpGroup
177cn: Customers
178
179# Host entry for my laptop
180dn: cn=brianlaptop, cn=Customers, cn=DHCP Service Config, dc=ntelos, dc=net
181objectClass: top
182objectClass: dhcpHost
183cn: brianlaptop
184dhcpHWAddress: ethernet 00:00:00:00:00:00
185
186You can use the command slapadd to load all of these entries into your LDAP
187server. After you load this, you should be able to start up DHCP. If you run
188into problems reading the configuration, try running dhcpd with the -d flag.
189If you still have problems, edit the site.conf file in the DHCP source and
190add the line: COPTS= -DDEBUG_LDAP and recompile DHCP. (make sure you run make
191clean and rerun configure before you rebuild).
192
This page took 0.098331 seconds and 4 git commands to generate.