Debian Codegraph @

doc/antora/modules/howto/pages/protocols/dhcp/policy_ippool_creation.adoc

raw
1 === Determine the IP pool plan
2
3 Except for cases where all IP allocation is performed using a mapping from the
4 device MAC address to a fixed IP address, the DHCP configuration will involve
5 the use of one or more IP address pools.
6
7 FreeRADIUS stores all the IP addresses in its pools in whichever database has
8 been chosen. An instance of the `sqlippools` module is used to manage all pools
9 within a single table (normally `dhcpippool`). Each row of this table
10 corresponds to an IP address that is a member of some pool. The pools are
11 distinguished by name, so the table has a column (`pool_name`) that denotes
12 this.
13
14 Each pool in this table should be composed of a set of equally valid IP
15 addresses for the devices that are designated to be members of the pool.
16
17 Firstly, consider the network locations to which distinct ranges of IP
18 addresses must be allocated and provisionally assign a pool to each.
19
20 Next, consider that many networks support multiple co-existing subnets without
21 VLAN separation. We will call this a "shared-network" to use the original ISC
22 DHCP parlance. In Microsoft DHCP contexts this is often referred to as a
23 "multinet".
24
25 Often in a shared-network the policy has no regard for which of the network's
26 devices is allocated to which subnet. In this case we must create a single,
27 combined pool containing all of the IP addresses from each subnet in that
28 network. Since all addresses in a pool are treated equally this will mean that
29 any IP address may be allocated to a device that is making a DHCP request from
30 that network. The appropriate DHCP parameters for the subnet to which the IP
31 address belongs is determined after allocation.
32
33 There are sometimes shared-networks (or even single subnets) for which IP
34 addresses belonging to any subnet may be technically suitable for any device,
35 however some local policy wants to assigning them to a particular subnet, for
36 example to provide loose segregation between classes of device. In this case we
37 define multiple pools, one for each range of IP addresses whose devices needs to
38 be differentiated.
39
40 The choice of pool is ordinarily determined based on the network from which the
41 request originates using a mapping from Layer 2 networks to the pool name
42 provided by the user. The indicator for the originating network can be
43 overridden when this alone is insufficient to implement the required pool
44 selection policy such as when you need to differentiate the pool's users with
45 more granularity that their Layer 2 network, such as by considering device
46 attributes ("class" membership in ISC parlance) or Option 82 circuit data.
47
48
49 === Populate the IP Pools
50
51 By this stage you should have derived a list of pools, the IP address ranges
52 contained therein, and the means of selecting the pool to use based on the
53 originating network and/or some additional criteria from the request.
54
55 A helper Perl script is provided with FreeRADIUS that can be used to populate
56 the pools provide that you are using the default schema.
57
58 [source,shell]
59 ----
60 rlm_sqlippool_tool -p <pool_name> -s <range_start> -e <range_end> \
61 -t <table_name> (-d <sql_dialect> | -f <raddb_dir> [ -i <instance> ]) \
62 [ -c <capacity> ] [ -x <existing_ips_file> ]
63 ----
64
65 If, for example, you had a range configured in ISC DHCP as:
66
67 [source,iscdhcp]
68 ----
69 range 10.0.0.5 10.0.0.199
70 ----
71
72 and you are using PostgreSQL as your database, and you wish to refer to this pool
73 using the name `local`, this could be prepared with:
74
75 [source,shell]
76 ----
77 rlm_sqlippool_tool -p local -s 10.0.0.5 -e 10.0.0.199 -t dhcpippool -d postgresql
78 ----
79
80 If the SQL module of FreeRADIUS is already configured then this can
81 be referenced so that the tool is able to use the configured connection
82 parameters to connect to the database and populate the pool:
83
84 [source,shell]
85 ----
86 rlm_sqlippool_tool -p local -s 10.0.0.5 -e 10.0.0.199 -t dhcpippool -f /etc/raddb
87 ----
88
89 For installations that require multiple pools, `rlm_sqlippool_tool` can
90 be called referencing a YAML file defining the pools. Comments at the
91 head of `rlm_sqlippool_tool` explain the options in more detail.
92
93 If static leases are required then these should be set up in the database
94 such that the MAC address of the client should be set as the `pool_key`
95 against the corresponding address and the `status` column of the row
96 representing the address set to `static`. A helper perl script,
97 `rlm_iscfixed2ippool` can be used to read an ISC DHCP config file and produce
98 SQL to perform these changes or directly update the database:
99
100 [source,shell]
101 ----
102 rlm_iscfixed2ippool -c <dhcpd.<raddb> -t <table_name> -k <mac|id> \
103 (-d <sql_dialect> | -f <raddb_dir> [-i <instance>])
104 ----
105
106 For example, to read /etc/dhcp/dhcpd.conf and populate the configured
107 FreeRADIUS database, using the mac as the identifier:
108
109 [source,shell]
110 ----
111 rlm_iscfixed2ippool -c /etc/dhcp/dhcpd.conf -t dhcpippool -k mac -f /usr/local/etc/raddb
112 ----