| 1 |
== Enabling the DHCP service |
| 2 |
|
| 3 |
A major difference between configuring FreeRADIUS as a DHCP server versus most |
| 4 |
other DHCP software such as ISC DHCP is that other software typically uses a |
| 5 |
single monolithic configuration file whereas FreeRADIUS has a collection of |
| 6 |
configuration files. This reflects the modularity of FreeRADIUS; attempting to |
| 7 |
put the entire configuration in a single file would result in a very difficult |
| 8 |
to read configuration. |
| 9 |
|
| 10 |
The root of the FreeRADIUS configuration may be in a different location on the |
| 11 |
filesystem depending on how FreeRADIUS has been installed. This directory will |
| 12 |
be referred to as `<raddb>` below. The sample configuration files are well |
| 13 |
commented describing what each configuration option does. |
| 14 |
|
| 15 |
FreeRADIUS compiled from source will default to `/usr/local/etc/raddb`. |
| 16 |
Pre-built packages will default to either `/etc/raddb` or |
| 17 |
`/etc/freeradius`. |
| 18 |
|
| 19 |
|
| 20 |
=== Enable the DHCP virtual server |
| 21 |
|
| 22 |
The FreeRADIUS configuration separates each network service that it provides |
| 23 |
into "virtual servers". A number of sample virtual server definitions are |
| 24 |
provided in `<raddb>/sites-available`, one of which is the sample |
| 25 |
configuration for a DHCP service. |
| 26 |
|
| 27 |
Sites may be added to the working configuration by either creating a symlink to |
| 28 |
them or copying them to `<conf>/sites-enabled` depending on how you wish to |
| 29 |
manage future upgrades. |
| 30 |
|
| 31 |
[TIP] |
| 32 |
==== |
| 33 |
As with other package-managed configuration files, package upgrades will not |
| 34 |
automatically replace files that you have edited but you will need to resolve |
| 35 |
any local differences. Creating copies avoids the need to resolve conflicts |
| 36 |
during a package upgrade. |
| 37 |
==== |
| 38 |
|
| 39 |
Add the DHCP virtual server to the active configuration: |
| 40 |
|
| 41 |
[source,shell] |
| 42 |
---- |
| 43 |
cd <raddb>/sites-enabled |
| 44 |
ln -s ../sites-available/dhcp . |
| 45 |
---- |
| 46 |
|
| 47 |
or: |
| 48 |
|
| 49 |
[source,shell] |
| 50 |
---- |
| 51 |
cd <raddb>/sites-enabled |
| 52 |
cp ../sites-available/dhcp . |
| 53 |
---- |
| 54 |
|
| 55 |
The sample configuration has been set up in such a way that it is initially |
| 56 |
safe. It will not actually take over live DHCP serving on the network when it |
| 57 |
is simply enabled until it is configured to do so. Rather is set up for testing |
| 58 |
prior to going live. |
| 59 |
|
| 60 |
The virtual server begins with a `listen` section. In this section your need to |
| 61 |
modify the following configuration items: |
| 62 |
|
| 63 |
`ipaddr`:: The IP address to listen on. |
| 64 |
`src_ipaddr`:: The source IP for unicast packets. |
| 65 |
`port`:: The port to listen on. Setting this to `67` will make the DHCP service live on the network. |
| 66 |
`interface`:: The network interface to listen on. |
| 67 |
`broadcast`:: Allow broadcast packets. For most live systems this will need to be set to `yes`. |
| 68 |
|
| 69 |
Below the `listen` section, there are sections that define how to respond to |
| 70 |
each of the DHCP packet types. Most installations will require that you review |
| 71 |
the settings for `DHCP-Discover` and `DHCP-Request`. |
| 72 |
|
| 73 |
Their contents contain directives in the FreeRADIUS policy language, "unlang". |
| 74 |
Many examples are provided which have been carefully described. |
| 75 |
|
| 76 |
|
| 77 |
=== Enable SQL and IP pool modules |
| 78 |
|
| 79 |
FreeRADIUS has many modules to support different aspects of the functionality |
| 80 |
required for the network protocols it can process. The two of most significance |
| 81 |
for DHCP are `dhcp_sql` and `dhcp_sqlippool`. As with virtual servers, a |
| 82 |
number of example module configurations are available in |
| 83 |
`<raddb>/mods-available`. |
| 84 |
These should be symlinked or copied into `<raddb>/mods-enabled` in order to |
| 85 |
enable them. |
| 86 |
|
| 87 |
|
| 88 |
==== Configure the `dhcp_sql` module |
| 89 |
|
| 90 |
Add the `dhcp_sql` module to the active configuration: |
| 91 |
|
| 92 |
[source,shell] |
| 93 |
---- |
| 94 |
cd <raddb>/mods-enabled |
| 95 |
ln -s ../mods-available/dhcp_sql . |
| 96 |
---- |
| 97 |
|
| 98 |
or: |
| 99 |
|
| 100 |
[source,shell] |
| 101 |
---- |
| 102 |
cd <raddb>/mods-enabled |
| 103 |
cp ../mods-available/dhcp_sql . |
| 104 |
---- |
| 105 |
|
| 106 |
The `dhcp_sql` module should be configured with the connection parameters for |
| 107 |
whichever database is to be used. The key configuration items are: |
| 108 |
|
| 109 |
`dialect`:: Which SQL dialect is in use. |
| 110 |
`driver`:: Which driver to use to access the database. For most databases this |
| 111 |
is `rlm_sql_<dialect>`, however Microsoft SQL Server has a choice of |
| 112 |
drivers. |
| 113 |
|
| 114 |
Then, there are configuration options that are unique to each database, |
| 115 |
including connection details. For most databases these are: |
| 116 |
|
| 117 |
`server`:: The host name or IP address of the database server. |
| 118 |
`port`:: The port to connect to the database server on. |
| 119 |
`login`:: The user name used to connect to the database. |
| 120 |
`password`:: The password for authenticating to the database. |
| 121 |
`radius_db`:: The name of the database. |
| 122 |
|
| 123 |
[NOTE] |
| 124 |
==== |
| 125 |
SQLite does not use these connection options, rather the `filename` |
| 126 |
option within the `sqlite` section is used to determine where the database |
| 127 |
will be stored. |
| 128 |
==== |
| 129 |
|
| 130 |
|
| 131 |
==== Configure the `dhcp_sqlippool` module |
| 132 |
|
| 133 |
Add the `dhcp_sqlippool` module to the active configuration: |
| 134 |
|
| 135 |
[source,shell] |
| 136 |
---- |
| 137 |
cd <raddb>/mods-enabled |
| 138 |
ln -s ../mods-available/dhcp_sqlippool . |
| 139 |
---- |
| 140 |
|
| 141 |
or |
| 142 |
|
| 143 |
[source,shell] |
| 144 |
---- |
| 145 |
cd <raddb>/mods-enabled |
| 146 |
cp ../mods-available/dhcp_sqlippool . |
| 147 |
---- |
| 148 |
|
| 149 |
The `dhcp_sqlippool` module must be configured. The key configuration |
| 150 |
items are: |
| 151 |
|
| 152 |
`dialect`:: Set this to the same SQL dialect as in the `sql` module. |
| 153 |
`offer_duration`:: How long an IP is offered to the client in a DHCP OFFER. |
| 154 |
`lease_duration`:: How long an IP is leased to the client in a DHCP ACK. |
| 155 |
|
| 156 |
|
| 157 |
=== Provision the database |
| 158 |
|
| 159 |
You should provision your database by creating a user for FreeRADIUS (matching |
| 160 |
the configuration that you have previously provided) and then loading the |
| 161 |
schema. The procedure for doing this will vary according to the database |
| 162 |
server. |
| 163 |
|
| 164 |
The schema, stored procedure definition and any additional setup scripts for |
| 165 |
your database are in `<raddb>/mods-config/sql/ippool-dhcp/{dialect}/`. |
| 166 |
|
| 167 |
=== Test FreeRADIUS startup |
| 168 |
|
| 169 |
Once you have provisioned your schema, created a user account and granted |
| 170 |
access to the user, you should be able to start FreeRADIUS. |
| 171 |
|
| 172 |
If FreeRADIUS has been configured correctly then the output of `ss` will |
| 173 |
contain a line showing that FreeRADIUS is listening for DHCP packets on the |
| 174 |
designated interface on port 67: |
| 175 |
|
| 176 |
.Example of FreeRADIUS listening on `<interface>` for DHCP packets |
| 177 |
================================================================== |
| 178 |
# ss -lunp |
| 179 |
Netid Recv-Q Send-Q Local Address:Port ... |
| 180 |
udp 0 0 0.0.0.0%<interface>:67 ... users:(("radiusd",...)) |
| 181 |
================================================================== |
| 182 |
|
| 183 |
Note that if the database is inaccessible then FreeRADIUS will normally refuse |
| 184 |
to start. |
| 185 |
|
| 186 |
The FreeRADIUS wiki contains extensive information about debugging FreeRADIUS |
| 187 |
startup issues that we do not repeat in any detail here. |
| 188 |
|
| 189 |
Essentially, stop your init system from repeatedly trying to launch FreeRADIUS: |
| 190 |
|
| 191 |
[source,shell] |
| 192 |
---- |
| 193 |
service radiusd stop |
| 194 |
---- |
| 195 |
|
| 196 |
Then start FreeRADIUS manually in debug mode: |
| 197 |
|
| 198 |
[source,shell] |
| 199 |
---- |
| 200 |
radiusd -X |
| 201 |
---- |
| 202 |
|
| 203 |
Carefully read the output since this will tell you why FreeRADIUS was unable to |
| 204 |
start. |
| 205 |
|
| 206 |
Once you have fixed the issue start FreeRADIUS as normal: |
| 207 |
|
| 208 |
[source,shell] |
| 209 |
---- |
| 210 |
service radiusd start |
| 211 |
---- |
| 212 |
|
| 213 |
Now xref:protocols/dhcp/test.adoc[test the DHCP service] to ensure that it is responding to requests. |