aboutsummaryrefslogtreecommitdiffstats
path: root/notes/projects/radius/sql/ippool-demo.sql
blob: 08a4157c54a04662d50a72753b50874052acd966 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
/*
 *  IP Engineering RADIUS Servers
 *
 *  ippool-demo.sql - inserts demo data into  RADIUS IP Pools database
 *
 *  Usage:  psql -f ippool-demo.sql radius_ippool
 *
 */


SET ROLE radius;


-- create example pools
INSERT INTO pool ( name ) VALUES ( 'DHCP' );
INSERT INTO pool ( name ) VALUES ( 'PPPoE' );
INSERT INTO pool ( name ) VALUES ( 'reserved' );


-- create example regions
INSERT INTO region ( name ) VALUES ( 'Anchorage' );
INSERT INTO region ( name ) VALUES ( 'Soldotna' );
INSERT INTO region ( name ) VALUES ( 'Fairbanks' );
INSERT INTO region ( name ) VALUES ( 'Juneau' );
INSERT INTO region ( name ) VALUES ( 'Lab' );


-- create example NAS clients
SELECT nas_add( nasName := 'br1.cwc',  regionName := 'Anchorage' );
SELECT nas_add( nasName := 'bras.eng', regionName := 'Lab' );
SELECT nas_add( nasName := 'br1.sol',  regionName := 'Soldotna' );


-- Create example netblocks
SELECT              netblock_add
                    ( netAddress    := '209.193.4.0/28',
                      poolName      := 'DHCP',
                      regionName    := 'Soldotna'
                    );
SELECT              netblock_add
                    ( netAddress    := '209.193.4.0/29',
                      poolName      := 'DHCP',
                      regionName    := 'Soldotna',
                      netDesc       := 'Reserved for engineering test accounts',
                      netBusyout    := TRUE
                    );
SELECT              netblock_add
                    ( netAddress    := '209.193.4.4/30',
                      poolName      := 'DHCP',
                      regionName    := 'Soldotna'
                    );
--
SELECT              netblock_add
                    ( netAddress    := '209.193.4.16/28',
                      poolName      := 'PPPoE',
                      regionName    := 'Soldotna'
                    );
SELECT              netblock_add
                    ( netAddress    := '209.193.4.32/28',
                      poolName      := 'DHCP',
                      regionName    := 'Anchorage'
                    );
SELECT              netblock_add
                    ( netAddress    := '209.193.4.48/28',
                      poolName      := 'PPPoE',
                      regionName    := 'Anchorage'
                    );
SELECT              netblock_add
                    ( netAddress    := '209.193.4.64/28',
                      poolName      := 'DHCP'
                    );
SELECT              netblock_add
                    ( netAddress    := '209.193.4.80/28',
                      poolName      := 'PPPoE'
                    );
SELECT              netblock_add
                    ( netAddress    := '209.193.4.96/28',
                      poolName      := 'DHCP',
                      netBusyout    := TRUE,
                      addIpEntries  := FALSE
                    );
SELECT              netblock_add
                    ( netAddress    := '209.193.4.112/28',
                      poolName      := 'PPPoE',
                      netBusyout    := TRUE,
                      addIpEntries  := FALSE
                    );
SELECT              netblock_add
                    ( netAddress    := '209.193.4.128/25',
                      poolName      := 'Reserved',
                      netBusyout    := TRUE,
                      addIpEntries  := TRUE
                    );


-- create example explicit IP reservations
SELECT              ip_assign
                    ( assignIp      := '209.193.4.3/32',
                      assignNas     := 'br1.sol',
                      assignUser    := 'busy1@example.net',
                      assignForce   := TRUE
                    );
SELECT              ip_assign
                    ( assignIp      := '209.193.4.8/32',
                      assignNas     := 'br1.sol',
                      assignUser    := 'jdoe8@example.net'
                    );
SELECT              ip_assign
                    ( assignIp      := '209.193.4.9/32',
                      assignNas     := 'br1.sol',
                      assignUser    := 'jdoe9@aexample.net'
                    );
SELECT              ip_assign
                    ( assignIp      := '209.193.4.10/32',
                      assignNas     := 'br1.sol',
                      assignUser    := 'jdoe10@example.net'
                    );
SELECT              ip_assign
                    ( assignIp      := '209.193.4.11/32',
                      assignNas     := 'br1.sol',
                      assignUser    := 'jdoe11@example.net'
                    );
SELECT              ip_assign
                    ( assignIp      := '209.193.4.12/32',
                      assignNas     := 'br1.sol',
                      assignUser    := 'jdoe12@example.net'
                    );
SELECT              ip_assign
                    ( assignIp      := '209.193.4.13/32',
                      assignNas     := 'br1.sol',
                      assignUser    := 'jdoe13@example.net'
                    );


-- auto-assign IP reservations
SELECT              ip_autoassign
                    ( assignUser    := 'autoassign1@example.net',
                      assignNas     := 'br1.sol',
                      assignPool    := 'dhcp'
                    );
SELECT              ip_autoassign
                    ( assignUser    := 'autoassign2@example.net',
                      assignNas     := 'br1.sol',
                      assignPool    := 'dhcp'
                    );
SELECT              ip_autoassign
                    ( assignUser    := 'autoassign3@example.net',
                      assignNas     := 'br1.sol',
                      assignPool    := 'dhcp'
                    );
SELECT              ip_autoassign
                    ( assignUser    := 'autoassign4@example.net',
                      assignNas     := 'br1.sol',
                      assignPool    := 'dhcp'
                    );


-- load large blocks
SELECT              netblock_add
                    ( netAddress    := '209.193.0.0/22',
                      poolName      := 'DHCP',
                      regionName    := 'Anchorage'
                    );
SELECT              netblock_add
                    ( netAddress    := '209.193.5.0/24',
                      poolName      := 'DHCP',
                      regionName    := 'Anchorage'
                    );
SELECT              netblock_add
                    ( netAddress    := '209.193.6.0/23',
                      poolName      := 'DHCP',
                      regionName    := 'Anchorage'
                    );
SELECT              netblock_add
                    ( netAddress    := '209.193.8.0/21',
                      poolName      := 'DHCP',
                      regionName    := 'Anchorage'
                    );
SELECT              netblock_add
                    ( netAddress    := '209.193.16.0/20',
                      poolName      := 'DHCP',
                      regionName    := 'Anchorage'
                    );
SELECT              netblock_add
                    ( netAddress    := '209.193.32.0/19',
                      poolName      := 'DHCP',
                      regionName    := 'Anchorage'
                    );
SELECT              netblock_add
                    ( netAddress    := '209.112.128.0/18',
                      poolName      := 'DHCP',
                      regionName    := 'Soldotna'
                    );
SELECT              netblock_add
                    ( netAddress    := '209.112.192.0/19',
                      poolName      := 'DHCP',
                      regionName    := 'Soldotna'
                    );
SELECT              netblock_add
                    ( netAddress    := '66.230.80.0/20',
                      poolName      := 'DHCP',
                      regionName    := 'Fairbanks'
                    );
SELECT              netblock_add
                    ( netAddress    := '66.230.96.0/19',
                      poolName      := 'DHCP',
                      regionName    := 'Anchorage'
                    );
SELECT              netblock_add
                    ( netAddress    := '69.161.0.0/19',
                      poolName      := 'DHCP',
                      regionName    := 'Juneau'
                    );
SELECT              netblock_add
                    ( netAddress    := '63.140.64.0/18',
                      poolName      := 'DHCP'
                    );


-- add missing IP addresses to netblock
-- SELECT              ip_add_network( ipNetwork := '209.112.192.0/19' );
-- SELECT              ip_add_network( ipNetwork := '209.112.128.0/18' );


/* end of sql */