e1b942022c44584d8930920f8e9ad777bf6a755f
[freeradius.git] / raddb / sites-available / dhcp
1 # -*- text -*-
2 ######################################################################
3 #
4 #       This is a virtual server that handles DHCP.
5 #
6 #               !!!! WARNING !!!!
7 #
8 #       This code is experimental, and SHOULD NOT be used in a
9 #       production system.  It is intended for validation and
10 #       experimentation ONLY.
11 #
12 #       In order for this to work, you will need to run configure:
13 #
14 #               $ ./configure --with-dhcp
15 #               $ make
16 #               $ vi share/dictionary
17 #
18 #       ## Un-comment the line containing $INCLUDE dictionary.dhcp
19 #       ## Then, save the file.
20 #
21 #               $ make install
22 #
23 #       DHCP is NOT enabled by default.
24 #
25 #       The goal of this effort is to get the code in front of
26 #       people who are interested in another DHCP server.
27 #       We NEED FEEDBACK, patches, bug reports, etc.  Especially patches!
28 #
29 #       Please contribute, or this work will be nothing more than
30 #       a curiosity.
31 #
32 #
33 #       Q: What does it do?
34 #       A: It allows the server to receive DHCP packets, and to
35 #          respond with static, pre-configured DHCP responses.
36 #
37 #       Q: Does it do static/dynamic IP assignment?
38 #       A: No.  Or, maybe.  Try it and see.
39 #
40 #       Q: Does it read ISC configuration or lease files?
41 #       A: No.  Please submit patches.
42 #
43 #       Q: Does it have DHCP feature X?
44 #       A: No.  Please submit patches.
45 #
46 #       Q: Does it support option 82?
47 #       A: Yes.
48 #
49 #       Q: Does it support other options?
50 #       A: Maybe.  See dictionary.dhcp.  Please submit patches.
51 #
52 #       Q: It doesn't seem to do much of anything!
53 #       A: Exactly.
54 #
55 #       $Id$
56 #
57 ######################################################################
58
59 #
60 #  The DHCP functionality goes into a virtual server.
61 #
62 server dhcp {
63
64 #  Define a DHCP socket.
65 #
66 #  The default port below is 6700, so you don't break your network.
67 #  If you want it to do real DHCP, change this to 67, and good luck!
68 #
69 #  You can also bind the DHCP socket to an interface.
70 #  See below, and raddb/radiusd.conf for examples.
71 #
72 #  This lets you run *one* DHCP server instance and have it listen on
73 #  multiple interfaces, each with a separate policy.
74 #
75 #  If you have multiple interfaces, it is a good idea to bind the
76 #  listen section to an interface.  You will also need one listen
77 #  section per interface.
78 #
79 #  FreeBSD does *not* support binding sockets to interfaces.  Therefore,
80 #  if you have multiple interfaces, broadcasts may go out of the wrong
81 #  one, or even all interfaces.  The only solution is to update FreeRADIUS
82 #  to use BPF sockets.
83 #
84 listen {
85         ipaddr = 127.0.0.1
86         port = 6700
87         type = dhcp
88 #       interface = lo0
89
90         # The DHCP server defaults to allowing broadcast packets.
91         # Set this to "no" only when the server receives *all* packets
92         # from a relay agent.  i.e. when *no* clients are on the same
93         # LAN as the DHCP server.
94         #
95         # It's set to "no" here for testing.
96         broadcast = no
97 }
98
99 #  Packets received on the socket will be processed through one
100 #  of the following sections, named after the DHCP packet type.
101 #  See dictionary.dhcp for the packet types.
102 dhcp DHCP-Discover {
103         update reply {
104                DHCP-Message-Type = DHCP-Offer
105         }
106
107         #  The contents here are invented.  Change them!
108         update reply {
109                 DHCP-Domain-Name-Server = 127.0.0.1
110                 DHCP-Domain-Name-Server = 127.0.0.2
111                 DHCP-Subnet-Mask = 255.255.255.0
112                 DHCP-Router-Address = 192.168.1.1
113                 DHCP-IP-Address-Lease-Time = 86400
114                 DHCP-DHCP-Server-Identifier = 192.168.1.1
115         }
116
117         #  Do a simple mapping of MAC to assigned IP.
118         #
119         #  See below for the definition of the "mac2ip"
120         #  module.
121         #
122         #mac2ip
123
124         #  If the MAC wasn't found in that list, do something else.
125         #  You could call a Perl, Python, or Java script here.
126
127         #if (notfound) {
128         # ...
129         #}
130
131         ok
132 }
133
134 dhcp DHCP-Request {
135         update reply {
136                DHCP-Message-Type = DHCP-Ack
137         }
138
139         #  The contents here are invented.  Change them!
140         update reply {
141                 DHCP-Domain-Name-Server = 127.0.0.1
142                 DHCP-Domain-Name-Server = 127.0.0.2
143                 DHCP-Subnet-Mask = 255.255.255.0
144                 DHCP-Router-Address = 192.168.1.1
145                 DHCP-IP-Address-Lease-Time = 86400
146                 DHCP-DHCP-Server-Identifier = 192.168.1.1
147         }
148
149         #  Do a simple mapping of MAC to assigned IP.
150         #
151         #  See below for the definition of the "mac2ip"
152         #  module.
153         #
154         #mac2ip
155
156         #  If the MAC wasn't found in that list, do something else.
157         #  You could call a Perl, Python, or Java script here.
158
159         #if (notfound) {
160         # ...
161         #}
162
163         ok
164 }
165
166 #  If there's no named section for the packet type, then the packet
167 #  is processed through this section.
168 dhcp {
169         # send a DHCP NAK.
170         reject
171 }
172
173
174 }
175
176 ######################################################################
177 #
178 #  This next section is a sample configuration for the "passwd"
179 #  module, that reads flat-text files.  It should go into
180 #  radiusd.conf, in the "modules" section.
181 #
182 #  The file is in the format <mac>,<ip>
183 #
184 #       00:01:02:03:04:05,192.168.1.100
185 #       01:01:02:03:04:05,192.168.1.101
186 #       02:01:02:03:04:05,192.168.1.102
187 #
188 #  This lets you perform simple static IP assignment.
189 #
190 ######################################################################
191
192 #passwd mac2ip {
193 #       filename = ${confdir}/mac2ip
194 #       format = "*DHCP-Client-Hardware-Address:=DHCP-Your-IP-Address"
195 #       delimiter = ","
196 #}