add DHCP-Do-Not-Respond value to make it easier to not respond
[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 solution is to use the "setfib" command.
82 #  If you have a network "10.10.0/24" on LAN1, you will need to do:
83 #
84 #  Pick any IP on the 10.10.0/24 network
85 #       $ setfib 1 route add default 10.10.0.1
86 #
87 #  Edit /etc/rc.local, and add a line:
88 #       setfib 1 /path/to/radiusd
89 #
90 #  The kern must be built with the following options:
91 #       options    ROUTETABLES=2
92 #  or any value larger than 2.
93 #
94 # The other only solution is to update FreeRADIUS to use BPF sockets.
95 #
96 listen {
97         ipaddr = 127.0.0.1
98         port = 6700
99         type = dhcp
100 #       interface = lo0
101
102         # The DHCP server defaults to allowing broadcast packets.
103         # Set this to "no" only when the server receives *all* packets
104         # from a relay agent.  i.e. when *no* clients are on the same
105         # LAN as the DHCP server.
106         #
107         # It's set to "no" here for testing.
108         broadcast = no
109
110         # On Linux if you're running the server as non-root, you
111         # will need to do:
112         #
113         #       sudo setcap cap_net_admin=ei /path/to/radiusd
114         #
115         # This will allow the server to set ARP table entries
116         # for newly allocated IPs
117 }
118
119 #  Packets received on the socket will be processed through one
120 #  of the following sections, named after the DHCP packet type.
121 #  See dictionary.dhcp for the packet types.
122
123 #  Return packets will be sent to, in preference order:
124 #     DHCP-Gateway-IP-Address
125 #     DHCP-Client-IP-Address
126 #     DHCP-Your-IP-Address
127 #  At least one of these attributes should be set at the end of each
128 #  section for a response to be sent.
129
130 dhcp DHCP-Discover {
131
132         #  Set the type of packet to send in reply.
133         #
134         #  The server will look at the DHCP-Message-Type attribute to
135         #  determine which type of packet to send in reply. Common
136         #  values would be DHCP-Offer, DHCP-Ack or DHCP-NAK. See
137         #  dictionary.dhcp for all the possible values.
138         #
139         #  DHCP-Do-Not-Respond can be used to tell the server to not
140         #  respond.
141         #
142         #  In the event that DHCP-Message-Type is not set then the
143         #  server will fall back to determining the type of reply
144         #  based on the rcode of this section.
145
146         update reply {
147                DHCP-Message-Type = DHCP-Offer
148         }
149
150         #  The contents here are invented.  Change them!
151         update reply {
152                 DHCP-Domain-Name-Server = 127.0.0.1
153                 DHCP-Domain-Name-Server = 127.0.0.2
154                 DHCP-Subnet-Mask = 255.255.255.0
155                 DHCP-Router-Address = 192.0.2.1
156                 DHCP-IP-Address-Lease-Time = 86400
157                 DHCP-DHCP-Server-Identifier = 192.0.2.1
158         }
159
160         #  Do a simple mapping of MAC to assigned IP.
161         #
162         #  See below for the definition of the "mac2ip"
163         #  module.
164         #
165         #mac2ip
166
167         #  If the MAC wasn't found in that list, do something else.
168         #  You could call a Perl, Python, or Java script here.
169
170         #if (notfound) {
171         # ...
172         #}
173
174         #  Or, allocate IPs from the DHCP pool in SQL.
175 #       dhcp_sqlippool
176
177         #  If DHCP-Message-Type is not set, returning "ok" or
178         #  "updated" from this section will respond with a DHCP-Offer
179         #  message.
180         #
181         #  Other rcodes will tell the server to not return any response.
182         ok
183 }
184
185 dhcp DHCP-Request {
186
187         # Response packet type. See DHCP-Discover section above.
188         update reply {
189                DHCP-Message-Type = DHCP-Ack
190         }
191
192         #  The contents here are invented.  Change them!
193         update reply {
194                 DHCP-Domain-Name-Server = 127.0.0.1
195                 DHCP-Domain-Name-Server = 127.0.0.2
196                 DHCP-Subnet-Mask = 255.255.255.0
197                 DHCP-Router-Address = 192.0.2.1
198                 DHCP-IP-Address-Lease-Time = 86400
199                 DHCP-DHCP-Server-Identifier = 192.0.2.1
200         }
201
202         #  Do a simple mapping of MAC to assigned IP.
203         #
204         #  See below for the definition of the "mac2ip"
205         #  module.
206         #
207         #mac2ip
208
209         #  If the MAC wasn't found in that list, do something else.
210         #  You could call a Perl, Python, or Java script here.
211
212         #if (notfound) {
213         # ...
214         #}
215
216         #  Or, allocate IPs from the DHCP pool in SQL.
217 #       dhcp_sqlippool
218
219         #  If DHCP-Message-Type is not set, returning "ok" or
220         #  "updated" from this section will respond with a DHCP-Ack
221         #  packet.
222         #
223         #  "handled" will not return a packet, all other rcodes will
224         #  send back a DHCP-NAK.
225         ok
226 }
227
228 #  If there's no named section for the packet type, then the packet
229 #  is processed through this section.
230 dhcp {
231         #  The DHCP-Message-Type attribute will tell the server which
232         #  type of packet to respond with. If this is not set, then
233         #  "handled" will not return a response, whereas all other
234         #  rcodes will return a "NAK".
235         #
236         #  Send a DHCP NAK.
237         reject
238 }
239
240
241 }
242
243 ######################################################################
244 #
245 #  This next section is a sample configuration for the "passwd"
246 #  module, that reads flat-text files.  It should go into
247 #  radiusd.conf, in the "modules" section.
248 #
249 #  The file is in the format <mac>,<ip>
250 #
251 #       00:01:02:03:04:05,192.0.2.100
252 #       01:01:02:03:04:05,192.0.2.101
253 #       02:01:02:03:04:05,192.0.2.102
254 #
255 #  This lets you perform simple static IP assignment.
256 #
257 ######################################################################
258
259 #passwd mac2ip {
260 #       filename = ${confdir}/mac2ip
261 #       format = "*DHCP-Client-Hardware-Address:=DHCP-Your-IP-Address"
262 #       delimiter = ","
263 #}