| 1 |
The IMS IPSec-Registrar Module |
| 2 |
|
| 3 |
Dragos Vingarzan |
| 4 |
|
| 5 |
FhG Fokus |
| 6 |
<[email protected]> |
| 7 |
|
| 8 |
Jason Penton |
| 9 |
|
| 10 |
Smile Communications |
| 11 |
<[email protected]> |
| 12 |
|
| 13 |
Richard Good |
| 14 |
|
| 15 |
Smile Communications |
| 16 |
<[email protected]> |
| 17 |
|
| 18 |
Carsten Bock |
| 19 |
|
| 20 |
ng-voice GmbH |
| 21 |
<[email protected]> |
| 22 |
|
| 23 |
Tsvetomir Dimitrov |
| 24 |
|
| 25 |
<[email protected]> |
| 26 |
|
| 27 |
Copyright © 2007 FhG FOKUS |
| 28 |
|
| 29 |
Copyright © 2012 Smile Communications |
| 30 |
|
| 31 |
Copyright © 2015 ng-voice GmbH |
| 32 |
__________________________________________________________________ |
| 33 |
|
| 34 |
Table of Contents |
| 35 |
|
| 36 |
1. Admin Guide |
| 37 |
|
| 38 |
1. Overview |
| 39 |
2. Dependencies |
| 40 |
|
| 41 |
2.1. Kamailio Modules |
| 42 |
2.2. External Libraries or Applications |
| 43 |
|
| 44 |
3. Parameters |
| 45 |
|
| 46 |
3.1. ipsec_listen_addr (string) |
| 47 |
3.2. ipsec_listen_addr6 (string) |
| 48 |
3.3. ipsec_client_port (int) |
| 49 |
3.4. ipsec_server_port (int) |
| 50 |
3.5. ipsec_listen_name (string) |
| 51 |
3.6. ipsec_listen_agname (string) |
| 52 |
3.7. ipsec_max_connections (int) |
| 53 |
3.8. ipsec_reuse_server_port (int) |
| 54 |
3.9. ipsec_spi_id_start (int) |
| 55 |
3.10. ipsec_spi_id_range (int) |
| 56 |
3.11. ipsec_preferred_alg (string) |
| 57 |
3.12. ipsec_preferred_ealg (string) |
| 58 |
|
| 59 |
4. Functions |
| 60 |
|
| 61 |
4.1. ipsec_create(domain) |
| 62 |
4.2. ipsec_forward(domain, flags) |
| 63 |
4.3. ipsec_destroy(domain [, aor]) |
| 64 |
4.4. ipsec_destroy_by_contact(domain, aor, recv_host, |
| 65 |
recv_port) |
| 66 |
|
| 67 |
List of Examples |
| 68 |
|
| 69 |
1.1. Systemd override configuration |
| 70 |
1.2. ipsec_listen_addr parameter usage |
| 71 |
1.3. ipsec_listen_addr6 parameter usage |
| 72 |
1.4. ipsec_client_port parameter usage |
| 73 |
1.5. ipsec_server_port parameter usage |
| 74 |
1.6. ipsec_listen_name parameter usage |
| 75 |
1.7. ipsec_listen_agname parameter usage |
| 76 |
1.8. ipsec_max_connections parameter usage |
| 77 |
1.9. ipsec_reuse_server_port parameter usage |
| 78 |
1.10. ipsec_spi_id_start parameter usage |
| 79 |
1.11. ipsec_spi_id_range parameter usage |
| 80 |
1.12. ipsec_preferred_alg parameter usage |
| 81 |
1.13. ipsec_preferred_ealg parameter usage |
| 82 |
1.14. ipsec_create |
| 83 |
1.15. ipsec_forward |
| 84 |
1.16. ipsec_destroy |
| 85 |
1.17. ipsec_destroy_by_contact() |
| 86 |
|
| 87 |
Chapter 1. Admin Guide |
| 88 |
|
| 89 |
Table of Contents |
| 90 |
|
| 91 |
1. Overview |
| 92 |
2. Dependencies |
| 93 |
|
| 94 |
2.1. Kamailio Modules |
| 95 |
2.2. External Libraries or Applications |
| 96 |
|
| 97 |
3. Parameters |
| 98 |
|
| 99 |
3.1. ipsec_listen_addr (string) |
| 100 |
3.2. ipsec_listen_addr6 (string) |
| 101 |
3.3. ipsec_client_port (int) |
| 102 |
3.4. ipsec_server_port (int) |
| 103 |
3.5. ipsec_listen_name (string) |
| 104 |
3.6. ipsec_listen_agname (string) |
| 105 |
3.7. ipsec_max_connections (int) |
| 106 |
3.8. ipsec_reuse_server_port (int) |
| 107 |
3.9. ipsec_spi_id_start (int) |
| 108 |
3.10. ipsec_spi_id_range (int) |
| 109 |
3.11. ipsec_preferred_alg (string) |
| 110 |
3.12. ipsec_preferred_ealg (string) |
| 111 |
|
| 112 |
4. Functions |
| 113 |
|
| 114 |
4.1. ipsec_create(domain) |
| 115 |
4.2. ipsec_forward(domain, flags) |
| 116 |
4.3. ipsec_destroy(domain [, aor]) |
| 117 |
4.4. ipsec_destroy_by_contact(domain, aor, recv_host, recv_port) |
| 118 |
|
| 119 |
1. Overview |
| 120 |
|
| 121 |
This module contains methods for IPSec initialisation/deinitialisation |
| 122 |
related for usage of Kamailio as a Proxy-CSCF. |
| 123 |
|
| 124 |
Kamailio process needs specific permssions in order to manage IPSec |
| 125 |
tunnels, if executed by non-root user be sure to allow needed |
| 126 |
capabilities. |
| 127 |
|
| 128 |
Example 1.1. Systemd override configuration |
| 129 |
[Service] |
| 130 |
AmbientCapabilities=CAP_NET_ADMIN CAP_NET_RAW |
| 131 |
|
| 132 |
2. Dependencies |
| 133 |
|
| 134 |
2.1. Kamailio Modules |
| 135 |
2.2. External Libraries or Applications |
| 136 |
|
| 137 |
2.1. Kamailio Modules |
| 138 |
|
| 139 |
The Following modules must be loaded before this module: |
| 140 |
* Usrloc PCSCF |
| 141 |
* TM |
| 142 |
|
| 143 |
2.2. External Libraries or Applications |
| 144 |
|
| 145 |
This module requires the internal IMS library and libmnl for operating |
| 146 |
with netlink sockets. |
| 147 |
|
| 148 |
3. Parameters |
| 149 |
|
| 150 |
3.1. ipsec_listen_addr (string) |
| 151 |
3.2. ipsec_listen_addr6 (string) |
| 152 |
3.3. ipsec_client_port (int) |
| 153 |
3.4. ipsec_server_port (int) |
| 154 |
3.5. ipsec_listen_name (string) |
| 155 |
3.6. ipsec_listen_agname (string) |
| 156 |
3.7. ipsec_max_connections (int) |
| 157 |
3.8. ipsec_reuse_server_port (int) |
| 158 |
3.9. ipsec_spi_id_start (int) |
| 159 |
3.10. ipsec_spi_id_range (int) |
| 160 |
3.11. ipsec_preferred_alg (string) |
| 161 |
3.12. ipsec_preferred_ealg (string) |
| 162 |
|
| 163 |
3.1. ipsec_listen_addr (string) |
| 164 |
|
| 165 |
IP address which the Proxy-CSCF will use for incoming/outgoing SIP |
| 166 |
traffic over IPSec. |
| 167 |
|
| 168 |
Default value is empty string (null) - IPv4 listen interface will not |
| 169 |
be added |
| 170 |
|
| 171 |
Example 1.2. ipsec_listen_addr parameter usage |
| 172 |
... |
| 173 |
modparam("ims_ipsec_pcscf", "ipsec_listen_addr", "") |
| 174 |
... |
| 175 |
|
| 176 |
3.2. ipsec_listen_addr6 (string) |
| 177 |
|
| 178 |
IPv6 address which the Proxy-CSCF will use for incoming/outgoing SIP |
| 179 |
traffic over IPSec. |
| 180 |
|
| 181 |
Default value is empty string (null) - IPv6 listen interface will not |
| 182 |
be added |
| 183 |
|
| 184 |
Example 1.3. ipsec_listen_addr6 parameter usage |
| 185 |
... |
| 186 |
modparam("ims_ipsec_pcscf", "ipsec_listen_addr6", "") |
| 187 |
... |
| 188 |
|
| 189 |
3.3. ipsec_client_port (int) |
| 190 |
|
| 191 |
Port number which will be bound for incoming (server) IPSec traffic. |
| 192 |
|
| 193 |
Default value is 5062. |
| 194 |
|
| 195 |
Example 1.4. ipsec_client_port parameter usage |
| 196 |
... |
| 197 |
modparam("ims_ipsec_pcscf", "ipsec_client_port", 5062) |
| 198 |
... |
| 199 |
|
| 200 |
3.4. ipsec_server_port (int) |
| 201 |
|
| 202 |
Port number which will be bound for incoming (server) IPSec traffic. |
| 203 |
|
| 204 |
Default value is 5063. |
| 205 |
|
| 206 |
Example 1.5. ipsec_server_port parameter usage |
| 207 |
... |
| 208 |
modparam("ims_ipsec_pcscf", "ipsec_server_port", 5063) |
| 209 |
... |
| 210 |
|
| 211 |
3.5. ipsec_listen_name (string) |
| 212 |
|
| 213 |
Set a common prefix to build listen socket names. Default value: not |
| 214 |
set. |
| 215 |
|
| 216 |
Example 1.6. ipsec_listen_name parameter usage |
| 217 |
... |
| 218 |
modparam("ims_ipsec_pcscf", "ipsec_listen_name", "ims") |
| 219 |
... |
| 220 |
|
| 221 |
3.6. ipsec_listen_agname (string) |
| 222 |
|
| 223 |
Set async (action) workers group name for udp sockets for |
| 224 |
multi-threaded reading. Default value: not set. |
| 225 |
|
| 226 |
Example 1.7. ipsec_listen_agname parameter usage |
| 227 |
... |
| 228 |
modparam("ims_ipsec_pcscf", "ipsec_listen_agname", "imsudp") |
| 229 |
... |
| 230 |
|
| 231 |
3.7. ipsec_max_connections (int) |
| 232 |
|
| 233 |
Maximum simultaneous IPSec connections |
| 234 |
|
| 235 |
Default value is 2. |
| 236 |
|
| 237 |
Example 1.8. ipsec_max_connections parameter usage |
| 238 |
... |
| 239 |
modparam("ims_ipsec_pcscf", "ipsec_max_connections", 10) |
| 240 |
... |
| 241 |
|
| 242 |
3.8. ipsec_reuse_server_port (int) |
| 243 |
|
| 244 |
Reuse (1) or not (0) the P-CSCF IPSec information for Re-registration |
| 245 |
for one UA. When set to 0 - During Re-registration P-CSCF will create |
| 246 |
new IPSec tunnels. When set to 1 - During Re-registration P-CSCF will |
| 247 |
reuse the old IPSec tunnels. |
| 248 |
|
| 249 |
Default value is 1. |
| 250 |
|
| 251 |
Example 1.9. ipsec_reuse_server_port parameter usage |
| 252 |
... |
| 253 |
modparam("ims_ipsec_pcscf", "ipsec_reuse_server_port", 1) |
| 254 |
... |
| 255 |
|
| 256 |
3.9. ipsec_spi_id_start (int) |
| 257 |
|
| 258 |
Each IPSec tunnel has a unique system-wide identifier. This and the |
| 259 |
following option allows to tune the SPIs used by Kamailio in order to |
| 260 |
avoid collisions with other IPSec useres. If Kamailio is the only |
| 261 |
process on the system which uses IPSec, don't bother with this option. |
| 262 |
|
| 263 |
Default value is 100. |
| 264 |
|
| 265 |
Example 1.10. ipsec_spi_id_start parameter usage |
| 266 |
... |
| 267 |
modparam("ims_ipsec_pcscf", "ipsec_spi_id_start", 100) |
| 268 |
... |
| 269 |
|
| 270 |
3.10. ipsec_spi_id_range (int) |
| 271 |
|
| 272 |
How many SPIs to be allocated for the process. E.g. if |
| 273 |
ipsec_spi_id_start = 100 and ipsec_spi_id_range = 1000, SPIs between |
| 274 |
100 and 1100 will be used. |
| 275 |
|
| 276 |
Default value is 1000. |
| 277 |
|
| 278 |
Example 1.11. ipsec_spi_id_range parameter usage |
| 279 |
... |
| 280 |
modparam("ims_ipsec_pcscf", "ipsec_spi_id_range", 1000) |
| 281 |
... |
| 282 |
|
| 283 |
3.11. ipsec_preferred_alg (string) |
| 284 |
|
| 285 |
A name of an authentication algorithm which the Proxy-CSCF will prefer |
| 286 |
when creating IPSec tunnels. |
| 287 |
|
| 288 |
Default value is empty string (null) - the last algorithm in the |
| 289 |
Sec-Agree header will be used. |
| 290 |
|
| 291 |
Example 1.12. ipsec_preferred_alg parameter usage |
| 292 |
... |
| 293 |
modparam("ims_ipsec_pcscf", "ipsec_preferred_alg", "hmac-sha-1-96") |
| 294 |
... |
| 295 |
|
| 296 |
3.12. ipsec_preferred_ealg (string) |
| 297 |
|
| 298 |
A name of an encrytion algorithm which the Proxy-CSCF will prefer when |
| 299 |
creating IPSec tunnels. |
| 300 |
|
| 301 |
Default value is empty string (null) - the last algorithm in the |
| 302 |
Sec-Agree header will be used. Note that the possibility of it being |
| 303 |
the "null" algorithm is not insignificant. |
| 304 |
|
| 305 |
Example 1.13. ipsec_preferred_ealg parameter usage |
| 306 |
... |
| 307 |
modparam("ims_ipsec_pcscf", "ipsec_preferred_ealg", "aes-cbc") |
| 308 |
... |
| 309 |
|
| 310 |
4. Functions |
| 311 |
|
| 312 |
4.1. ipsec_create(domain) |
| 313 |
4.2. ipsec_forward(domain, flags) |
| 314 |
4.3. ipsec_destroy(domain [, aor]) |
| 315 |
4.4. ipsec_destroy_by_contact(domain, aor, recv_host, recv_port) |
| 316 |
|
| 317 |
4.1. ipsec_create(domain) |
| 318 |
|
| 319 |
This function creates IPSec SA and Policy based on the parameters sent |
| 320 |
in Security-Client header in the REGISTER message. It's called when OK |
| 321 |
is received. The function also adds Security-Server header to the |
| 322 |
REGISTER. |
| 323 |
|
| 324 |
Meaning of the parameters is as follows: |
| 325 |
* domain - Logical domain within the registrar. If a database is used |
| 326 |
then this must be name of the table which stores the contacts. |
| 327 |
flags - bitwise flag: 0x01 - if set - delete unused tunnels before |
| 328 |
every registration. This is an optional parameter, default value - |
| 329 |
0. |
| 330 |
|
| 331 |
Example 1.14. ipsec_create |
| 332 |
... |
| 333 |
ipsec_create("location"); |
| 334 |
# or |
| 335 |
ipsec_create("location", "1"); |
| 336 |
... |
| 337 |
|
| 338 |
4.2. ipsec_forward(domain, flags) |
| 339 |
|
| 340 |
The function processes redirects outgoing message via the IPSec tunnel |
| 341 |
initiated with ipsec_create(). |
| 342 |
|
| 343 |
Meaning of the parameters is as follows: |
| 344 |
* domain - Logical domain within the registrar. If a database is used |
| 345 |
then this must be name of the table which stores the contacts. |
| 346 |
flags - bitwise flag: |
| 347 |
+ 0x01 (1) - set force socket for request messages. Useful for |
| 348 |
ipsec and TCP/TLS. |
| 349 |
+ 0x02 (2) - reverse search for a contact in the memory. Useful |
| 350 |
when contact alias is disabled. |
| 351 |
+ 0x04 (4) - use destination URI for IPSec tunnel search. Useful |
| 352 |
for routing requests within dialog. |
| 353 |
+ 0x08 (8) - use new R-URI for IPSec tunnel search. |
| 354 |
+ 0x10 (16) - do not look for alias parameter to set received |
| 355 |
details. |
| 356 |
+ 0x20 (32) - do not reset the destination URI. |
| 357 |
+ 0x40 (64) - use user equipment client port as target for |
| 358 |
TCP/TLS requests (try to reuse the UE client connection). |
| 359 |
+ 0x80 (128) - set transport parameter in the new dst uri for |
| 360 |
TCP/TLS requests. |
| 361 |
+ 0x100 (256) - use Via attributes (port and protocol) for |
| 362 |
routing UDP reply, and protocol from next hop address for |
| 363 |
request (otherwise it taken from saved contact). |
| 364 |
+ 0x200 (512) - try TCP if corresponding UDP socket is not |
| 365 |
found. |
| 366 |
This is an optional parameter, default value - 0. |
| 367 |
|
| 368 |
Example 1.15. ipsec_forward |
| 369 |
... |
| 370 |
ipsec_forward("location"); |
| 371 |
# or |
| 372 |
ipsec_forward("location", "1"); |
| 373 |
... |
| 374 |
|
| 375 |
4.3. ipsec_destroy(domain [, aor]) |
| 376 |
|
| 377 |
The function destroys IPSec tunnel, created with ipsec_create. |
| 378 |
|
| 379 |
Meaning of the parameters is as follows: |
| 380 |
* domain - Logical domain within the registrar. If a database is used |
| 381 |
then this must be name of the table which stores the contacts. |
| 382 |
aor - SIP URI to match the record. If not provided, then R-URI is |
| 383 |
used. |
| 384 |
|
| 385 |
Example 1.16. ipsec_destroy |
| 386 |
... |
| 387 |
ipsec_destroy("location"); |
| 388 |
... |
| 389 |
|
| 390 |
4.4. ipsec_destroy_by_contact(domain, aor, recv_host, recv_port) |
| 391 |
|
| 392 |
The function destroys IPSec tunnel, created with ipsec_create. |
| 393 |
|
| 394 |
Meaning of the parameters is as follows: |
| 395 |
* domain - Logical domain within the registrar. If a database is used |
| 396 |
then this must be name of the table which stores the contacts. |
| 397 |
aor - SIP URI to match the record. |
| 398 |
recv_host - received host to match the record. |
| 399 |
recv_port - received port to match the record. |
| 400 |
|
| 401 |
The last three parameters have to be string values and can contain |
| 402 |
variables. |
| 403 |
|
| 404 |
Example 1.17. ipsec_destroy_by_contact() |
| 405 |
... |
| 406 |
ipsec_destroy_by_contact("location", "...", "...", "..."); |
| 407 |
... |