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 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622
|
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
"http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [
<!-- Include general documentation entities -->
<!ENTITY % docentities SYSTEM "../../docbook/entities.xml">
%docentities;
]>
<section id="ser_radius" xmlns:xi="http://www.w3.org/2001/XInclude">
<sectioninfo>
<authorgroup>
<author>
<firstname>Jan</firstname>
<surname>Janak</surname>
<email>jan@iptel.org</email>
</author>
</authorgroup>
<copyright>
<year>2003</year>
<holder>FhG FOKUS</holder>
</copyright>
<revhistory>
<revision>
<revnumber>$Revision$</revnumber>
<date>$Date$</date>
</revision>
</revhistory>
</sectioninfo>
<title>SIP-router RADIUS Howto</title>
<section id="radius_intro">
<title>Introduction</title>
<simpara>
SIP-router can be configured to use RADIUS server for authentication,
accounting, and group membership checking. Since configuration of
RADIUS seems to be a common source of problems, we decided to put
together this HOWTO.
</simpara>
<simpara>
The HOWTO covers installation and configuration of FreeRADIUS
server only. There are other RADIUS servers available and as
long as they support digest authentication, they should work
too. Any volunteers willing to describe setup of other RADIUS
servers are encouraged to contact the author.
</simpara>
<section id="prerequisities">
<title>Prerequisites</title>
<simpara>
To set up RADIUS support in SIP-router you will need the following:
</simpara>
<itemizedlist>
<listitem>
<simpara>
FreeRADIUS server, you can get it from <ulink
url="http://www.freeradius.org">FreeRADIUS
website</ulink>. The HOWTO describes installation
and setup of release 0.9.1.
</simpara>
</listitem>
<listitem>
<simpara>
Radiusclient library. In version 0.8.14 we started to
use the new version of radiusclient library developed
by Maxim Sobolev called radiusclient-ng. The homepage
of the library is <ulink
url="http://developer.berlios.de/projects/radiusclient-ng/">http://developer.berlios.de/projects/radiusclient-ng/</ulink>
</simpara>
</listitem>
<listitem>
<simpara>
SIP-router, get it from <ulink url="&serhome;">&serhome;</ulink>
</simpara>
</listitem>
<listitem>
<simpara>
You should also have some experience in configuring
SIP-router. Before you enable RADIUS authentication or
accounting make sure that the basic server is running
and that you know how to customize it to your taste.
</simpara>
</listitem>
<listitem>
<simpara>
If you want to use RADIUS accounting then you will have
to compile SIP-router from sources so you should know how to
do it.
</simpara>
</listitem>
</itemizedlist>
<simpara>
Various Unix/Linux distributions might include binary packages
of the mentioned applications. In that case you can safely use
the packages, there shouldn't be any problem. Location of some
files may be different, though. We will describe how to install
the software from sources only.
</simpara>
<warning>
<simpara>
Configuration of FreeRADIUS server described in the
document is in no way exhaustive. This document is a sort
of quick-start-guide, it shows how to get things running,
but you should definitely read FreeRADIUS documentation and
configure the server properly ! You have been warned.
</simpara>
</warning>
</section>
</section>
<section id="radiusclient">
<title>Radiusclient Library</title>
<simpara>
Untar the source tarball.
</simpara>
<screen>
root@localhost:/usr/local/src# tar xvfz radiusclient-0.4.3.tar.gz
</screen>
<simpara>
Compile and install the library.
</simpara>
<screen>
root@localhost:/usr/local/src# cd radiusclient-0.3.2
root@localhost:/usr/local/src/radiusclient-0.3.2# ./configure
root@localhost:/usr/local/src/radiusclient-0.3.2# make
root@localhost:/usr/local/src/radiusclient-0.3.2# make install
</screen>
<simpara>
By default all the configuration files of the radiusclient library
will be in <filename>/usr/local/etc/radiusclient</filename>
directory.
</simpara>
<simpara>
If you use binary packages then the configuration files will be
probably in <filename>/etc/radiusclient</filename>.
</simpara>
<section>
<title>File <filename>radiusclient.conf</filename></title>
<simpara>
The main configuration file of the library is
<filename>/usr/local/etc/radiusclient/radiusclient.conf</filename>,
open the file in your favorite text editor and find lines
containing the following:
</simpara>
<programlisting>
authserver localhost
</programlisting>
<simpara>
This is the hostname or IP address of the RADIUS server used
for authentication. You will have to change this unless the
server is running on the same host as your SIP proxy.
</simpara>
<programlisting>
acctserver localhost
</programlisting>
<simpara>
This is the hostname or IP address of the RADIUS server used
for accounting. You will have to change this unless the server
is running on the same host as your SIP proxy.
</simpara>
</section>
<section id="servers">
<title>File <filename>servers</filename></title>
<simpara>
RADIUS protocol uses simple access control mechanism based on
shared secrets that allows RADIUS servers to limit access from
RADIUS clients. A RADIUS server is configured with a secret
string and only RADIUS clients that have the same secret will
be accepted.
</simpara>
<simpara>
You need to configure a shared secret for each server you have
configured in <filename>radiusclient.conf</filename> file in
the previous step. The shared secrets are stored in
<filename>/usr/local/etc/radiusclient/servers</filename> file.
</simpara>
<simpara>
Each line contains hostname of a RADIUS server and shared
secret used in communication with that server. The two values
are separated by whitespaces. Configure shared secrets for
every RADIUS server you are going to use.
</simpara>
<warning>
<simpara>
RADIUS servers and clients must be configured with the same
shared secret, otherwise they will not accept RADIUS
messages from each other and neither authentication nor
accounting will work !
</simpara>
</warning>
</section>
<section id="dictionary_client">
<title>File <filename>dictionary</filename></title>
<simpara>
Radiusclient library contains file called
<filename>dictionary.ser</filename>. That file includes all the
attributes that are needed by SIP-router. Include the file in the
main <filename>dictionary</filename> file. To
include the file, put the following line at the end of
<filename>dictionary</filename> file:
</simpara>
<screen>
$INCLUDE /usr/local/etc/radiuclient/dictionary.ser
</screen>
</section>
</section>
<section id="freeradius">
<title>FreeRADIUS Server</title>
<simpara>
Untar, configure, build, and install the server:
</simpara>
<screen>
root@localhost:/usr/local/src# tar xvfz freeradius-0.9.1.tar.gz
root@localhost:/usr/local/src# cd freeradius-0.9.1
root@localhost"/usr/local/src/freeradius-0.9.1# ./configure
root@localhost"/usr/local/src/freeradius-0.9.1# make
root@localhost"/usr/local/src/freeradius-0.9.1# make install
</screen>
<simpara>
All the configuration files of FreeRADIUS server will be in
<filename>/usr/local/etc/raddb</filename> directory. If you install
a binary package then you will probably find them in
<filename>/etc/raddb</filename>.
</simpara>
<simpara>
The following sections describe how to configure freeradius
server. First we describe the common configuration that must be
done in any case. Configuration specific for authentication,
accounting, and group membership checking will be described in
separate sections.
</simpara>
<section id="common_configuration">
<title>Common configuration</title>
<section>
<title>File <filename>clients.conf</filename></title>
<simpara>
File <filename>/usr/local/etc/raddb/clients.conf</filename>
contains description of RADIUS clients that are allowed to
use the server. For each of the clients you need to specify
its hostname or IP address and also a shared secret. The
shared secret must be the same string you configured in
radiusclient library.
</simpara>
<simpara>
Suppose that your SIP server is running on host
proxy.foo.bar and radiusclient library on that machine has
been configure with "foobarsecret" as the shared
secret. You need to put the following section into the
file:
</simpara>
<programlisting>
client proxy.foo.bar {
secret = foobarsecret
shortname = foo
}
</programlisting>
<simpara>
This fragment allows access from RADIUS clients on
proxy.foo.bar if they use "foobarsecret" as the shared
secret.
</simpara>
<note>
<simpara>
The file already contains an entry for localhost (127.0.0.1), so if you are
running the RADIUS server on the same host as your SIP server, then modify
the existing entry instead. By default it contains shared secret
"testing123".
</simpara>
</note>
</section>
<section id="dictionary_server">
<title>File <filename>dictionary</filename></title>
<simpara>
File <filename>/usr/local/etc/raddb/dictionary</filename>
contains the dictionary of FreeRADIUS server. You have to
add the same dictionary file
(<filename>dictionary.ser</filename>), which you added to
the dictionary of radiusclient library, also here. In this
case you don't have to append the contents of the file, you
can include it into the main file. Add the following line
at the end of
<filename>/usr/local/etc/raddb/dictionary</filename>:
</simpara>
<programlisting>
$INCLUDE /usr/local/etc/radiusclient/dictionary.ser
</programlisting>
<simpara>
That will include the same attribute definitions that are
used in radiusclient library so the client and server will
understand each other.
</simpara>
</section>
<section id="radiusd.conf">
<title>File <filename>radiusd.conf</filename></title>
<simpara>
Digest authentication is disabled by default and you must
enable it in this file. There are two sections, "authorize"
and "authenticate". Both sections contain line containing
word "digest". Both of them are commented and you must
un-comment them to enable digest authentication.
</simpara>
<note>
<simpara>
There is also another line containing word "digest"
followed by curly braces and it is enabled by
default. The section is supposed to contain digest
module parameters but because digest module has no
parameters, it is empty. This is not the line you are
supposed to uncomment ! There are two more.
</simpara>
</note>
</section>
<section id="users">
<title>File <filename>users</filename></title>
<simpara>
This file contains authentication information for each
user. For testing purposes we will create user "test". Put
the following into the file:
</simpara>
<programlisting>
test Auth-Type := Digest, User-Password == "test"
Reply-Message = "Hello, test with digest"
</programlisting>
<simpara>
The username and password is for testing only, you can
safely remove the entry once your RADIUS server works and
you are able to authenticate.
</simpara>
</section>
</section>
<section id="test">
<title>Test The Server</title>
<note>
<simpara>
This step is optional.
</simpara>
</note>
<simpara>
The basic configuration of FreeRADIUS server is done it now we
are going to test if it really works. Start the server with
parameter -X. That will cause the server to stay in the
foreground (it will not turn into daemon) and produce a lot of
debugging information on the standard output:
</simpara>
<screen>
root@/usr/local/src# radiusd -X
</screen>
<simpara>
Create file <filename>digest</filename> and put the following
into the file:
</simpara>
<programlisting>
User-Name = "test", Digest-Response = "631d6d73147add2f9e437f59bbc3aeb7",
Digest-Realm = "testrealm", Digest-Nonce = "1234abcd" ,
Digest-Method = "INVITE", Digest-URI = "sip:5555551212@example.com",
Digest-Algorithm = "MD5", Digest-User-Name = "test"
</programlisting>
<simpara>
All the attributes must be on a single line.
</simpara>
<simpara>
Run <command>radclient</command> to test the server:
</simpara>
<screen>
root@/usr/local/src# radclient -f digest localhost auth <shared_secret>
</screen>
<note>
<simpara>
I suppose that you run the test utility directly on the
RADIUS server since it comes with the FreeRADIUS server
package. That also means that you have to enable access
from localhost in your <filename>clients.conf</filename>
file. Don't forget to replace <shared_secret> with
the shared secret configured for localhost clients in
<filename>clients.conf</filename>.
</simpara>
</note>
<simpara>
If your server works properly then you should see the following response:
</simpara>
<screen>
Received response ID 224, code 2, length = 45
Reply-Message = "Hello, test with digest"
</screen>
</section>
<section id="auth_configuration">
<title>Authentication Configuration</title>
<simpara>
To create user "joe" in domain "sip-router.org" with password
"heslo" put the following into file
<filename>/usr/local/etc/raddb/users</filename>:
</simpara>
<programlisting>
joe@sip-router.org Auth-Type := Digest, User-Password == "heslo"
Reply-Message = "Authenticated",
Sip-Rpid = "1234"
</programlisting>
<simpara>
Attribute "Sip-Rpid" is optional. The attribute
contains a phone number associated to the user. SIP-router can be
configured to put the phone number into Remote-Party-ID header
field of the SIP message. The header field can be then used
by PSTN gateways to display the number as the number of the
caller on regular phones. You can omit the attribute if you
don't need it.
</simpara>
</section>
<section id="accounting_configuration_server">
<title>Accounting Configuration</title>
<simpara>
By default the FreeRADIUS server will log all accounting requests
into <filename>/usr/local/var/log/radius/radacct</filename>
directory in form of plain text files. The server will
create one file for each hostname in the directory. The
following example shows how the log files look like.
</simpara>
<example>
<title>Example of Accounting Report</title>
<programlisting>
Tue Jun 24 00:20:55 2003
Acct-Status-Type = Start
Service-Type = 15
Sip-Response-Code = 200
Sip-Method = 1
User-Name = "gh@192.168.2.16"
Calling-Station-Id = "sip:gh@192.168.2.16"
Called-Station-Id = "sip:jiri@192.168.2.16"
Sip-Translated-Request-URI = "sip:jiri@192.168.2.36"
Acct-Session-Id = "b9a2ffaa-0458-42e1-b5fd-59656b795d29@192.168.2.32"
Sip-To-Tag = "cb2cfe2e-3659-28c7-a8cc-ab0b8cbd3012"
Sip-From-Tag = "a783bd2f-bb8d-46fd-84a9-00a9833f189e"
Sip-CSeq = "1"
NAS-IP-Address = 192.168.2.16
NAS-Port = 5060
Acct-Delay-Time = 0
Client-IP-Address = 127.0.0.1
Acct-Unique-Session-Id = "9b323e6b2f5b0f33"
Timestamp = 1056406855
Tue Jun 24 00:20:56 2003
Acct-Status-Type = Stop
Service-Type = 15
Sip-Response-Code = 200
Sip-Method = 8
User-Name = "jiri@192.168.2.16"
Calling-Station-Id = "sip:jiri@192.168.2.16"
Called-Station-Id = "sip:gh@192.168.2.16"
Sip-Translated-Request-URI = "sip:192.168.2.32:9576"
Acct-Session-Id = "b9a2ffaa-0458-42e1-b5fd-59656b795d29@192.168.2.32"
Sip-To-Tag = "a783bd2f-bb8d-46fd-84a9-00a9833f189e"
Sip-From-Tag = "cb2cfe2e-3659-28c7-a8cc-ab0b8cbd3012"
Sip-CSeq = "4580"
NAS-IP-Address = 192.168.2.16
NAS-Port = 5060
Acct-Delay-Time = 0
Client-IP-Address = 127.0.0.1
Acct-Unique-Session-Id = "b2c2479a07b17c95"
Timestamp = 1056406856
</programlisting>
</example>
</section>
<section id="group_checking">
<title>Group Checking Configuration</title>
<simpara>
If you want to make user "joe" in domain "sip-router.org" member of
group "pstn" then add the following to your
<filename>/usr/local/etc/raddb/users</filename> file:
</simpara>
<programlisting>
joe@sip-router.org Sip-Group == "pstn", Auth-Type := Accept
Reply-Message = "Authorized"
</programlisting>
</section>
</section>
<section id="ser_config">
<title>SIP-router Configuration</title>
<simpara>
We will describe installation from sources here. If you use binary
packages then there is an additional package containing RADIUS
related modules. You will need to install the package.
</simpara>
<simpara>
RADIUS-related modules are not compiled by default. To compile
them, edit <filename>Makefile</filename>, find variable
<varname>exclude_modules</varname> and you should see
"auth_radius", "acc_radius", and "misc_radius" among excluded
modules. Simply remove the three modules from the list.
</simpara>
<simpara>
If you need RADIUS accounting then edit also sip_router/modules/acc/Makefile and
uncomment lines containing:
</simpara>
<programlisting>
DEFS+=-DRAD_ACC
LIBS=-L$(LOCALBASE)/lib -lradiusclient
</programlisting>
<simpara>
Then recompile and re-install SIP-router:
</simpara>
<screen>
root@localhost:/usr/local/src/sip_router# make proper
root@localhost:/usr/local/src/sip_router# make all
root@localhost:/usr/local/src/sip_router# make install
</screen>
<section id="auth_configuration_client">
<title>Authentication Configuration</title>
<simpara>
Edit configuration file of SIP-router and instead of
<filename>auth_db.so</filename> load
<filename>auth_radius.so</filename> and also replace
<function>www_authorize</function> with
<function>radius_www_authorize</function>.
</simpara>
<note>
<simpara>
<function>radius_www_authorize</function> takes just one
parameter (as opposed to <function>www_authorize</function>
which takes 2).
</simpara>
</note>
</section>
<section id="acc_configuration">
<title>Accounting Configuration</title>
<simpara>
To enable RADIUS accounting simply use
<varname>radius_log_flag</varname> and
<varname>radius_log_missed_flag</varname> parameters instead of
<varname>log_flag</varname> and
<varname>log_missed_flag</varname>. Mark transactions that
should be logged with flags configured in the parameters.
</simpara>
</section>
<section id="group_membership_checking">
<title>Group Membership Checking</title>
<simpara>
Instead of <filename>group.so</filename> load
<filename>group_radius.so</filename>. The module exports the
same functions as <filename>group.so</filename>, the only
difference is that all the function names exported by
<filename>group_radius.so</filename> have "radius_" prefix.
</simpara>
</section>
</section>
<section id="faq">
<title>Frequently Asked Questions</title>
<qandaset>
<qandaentry>
<question>
<simpara>
I compiled SIP-router RADIUS modules and installed
radiusclient library, but when I try to start the server I get
the following error message:
</simpara>
<programlisting>
libradiusclient.so.0: cannot open shared object file: No such file or directory
</programlisting>
</question>
<answer>
<simpara>
Make sure that the directory which contains the library
(usually <filename>/usr/local/lib</filename>) is listed
in <filename>/etc/ld.so.conf</filename> and run
<command>ldconfig -v</command> (as root).
</simpara>
</answer>
</qandaentry>
<qandaentry>
<question>
<simpara>
I configured everything as described in this HOWTO, but
I get the following message from radiusclient library
"check_radius_reply: received invalid reply digest from
RADIUS server". What does that mean ?
</simpara>
</question>
<answer>
<simpara>
That means that radiusclient library was unable to
verify digest of the RADIUS message (it is not related
to SIP digest) because shared secret of the client
and server do not match.
</simpara>
<note>
<simpara>
FreeRADIUS server has two files that can contain
definitions of clients and corresponding shared
secrets--<filename>clients</filename> and
<filename>clients.conf</filename>.
</simpara>
<simpara>
If you have proper shared secret in one file and you still get the
mentioned error message then check also the other file. This can easily
happen to clients running on the same host (127.0.0.1 or localhost),
because <filename>clients.conf</filename> contains
definition for localhost by default with secret "testing123".
</simpara>
</note>
</answer>
</qandaentry>
</qandaset>
</section>
</section>
|