| 1 |
= Accounting Requests |
| 2 |
|
| 3 |
*Goal*: To send the server accounting requests and to have the server |
| 4 |
log the accounting requests. |
| 5 |
|
| 6 |
*Time:* 20-30 minutes |
| 7 |
|
| 8 |
*Files:* |
| 9 |
|
| 10 |
- `/var/radacct/127.0.0.1/detail*` |
| 11 |
|
| 12 |
*Modules:* detail |
| 13 |
|
| 14 |
In addition to authorization and authentication, one of the primary roles of a |
| 15 |
RADIUS server is to record accounting information supplied by an NAS. In this |
| 16 |
exercise, you should create accounting requests to send to the server and see what |
| 17 |
the server does with those requests. This process simulates the actions taken by |
| 18 |
an NAS when a user logs in. |
| 19 |
|
| 20 |
Use the entry in the file from the exercise in |
| 21 |
xref:new_user.adoc[New User] for user "bob". |
| 22 |
|
| 23 |
You may create accounting packets by hand for this exercise, but we suggest that |
| 24 |
the follow test packets from the `exercises/packets` directory be used in this |
| 25 |
exercise: |
| 26 |
|
| 27 |
[source, bash] |
| 28 |
----------------- |
| 29 |
bob-login-one.sh |
| 30 |
bob-acct-start.sh |
| 31 |
bob-acct-stop.sh |
| 32 |
----------------- |
| 33 |
|
| 34 |
If you do create accounting packets by hand, then the attributes listed in the |
| 35 |
above scripts should be used as a guide. |
| 36 |
|
| 37 |
First, run the `bob-login-one.sh` script. |
| 38 |
|
| 39 |
Observe that the server has replied with an authentication accept to an |
| 40 |
authentication request for user "bob", who has logged in on a particular NAS |
| 41 |
port. |
| 42 |
|
| 43 |
If the server does not reply with an authentication accept, then check the |
| 44 |
attributes in the test packet and the file entry. |
| 45 |
|
| 46 |
You should now read the `man` pages for the `radwho` and `radlast` programs. Run |
| 47 |
each program in turn: |
| 48 |
|
| 49 |
[source, bash] |
| 50 |
--------- |
| 51 |
$ radwho |
| 52 |
$ radlast |
| 53 |
--------- |
| 54 |
|
| 55 |
Observe that both programs do not report user "bob" as being logged in. |
| 56 |
|
| 57 |
Now run the `bob-acct-start.sh` script, and observe the response of the server. |
| 58 |
You should see output containing lines similar to the following: |
| 59 |
|
| 60 |
----------------------------------------------------------------------------------- |
| 61 |
(0) Received Accounting-Request packet from host 127.0.0.1 port 57470, id=35, length=53 |
| 62 |
(0) User-Name = 'bob' |
| 63 |
(0) Acct-Status-Type = Start |
| 64 |
(0) Acct-Session-Id = '01020304' |
| 65 |
(0) NAS-IP-Address = 127.0.0.1 |
| 66 |
(0) NAS-Port = 501 |
| 67 |
(0) # Executing section preacct from file /etc/raddb/sites-enabled/default |
| 68 |
(0) preacct { |
| 69 |
(0) [preprocess] = ok |
| 70 |
----------------------------------------------------------------------------------- |
| 71 |
|
| 72 |
Other modules that should be referenced for "accounting" are the |
| 73 |
"preprocess", "suffix", "detail", and "sql" modules. We |
| 74 |
will work through the operation of these modules in a moment. |
| 75 |
|
| 76 |
Now, run the `radwho` and `radlast` programs again: |
| 77 |
|
| 78 |
[source, bash] |
| 79 |
--------- |
| 80 |
$ radwho |
| 81 |
$ radlast |
| 82 |
--------- |
| 83 |
|
| 84 |
Observe that both programs now see "bob" as being logged in. |
| 85 |
|
| 86 |
To tell the server that user "bob" has logged out, run the `bob-acct-stop.sh` |
| 87 |
script. Observe the server output, and then run `radwho` and `radlast` again. |
| 88 |
|
| 89 |
The `radwho` program should not display any logged-in users. The `radlast` |
| 90 |
program should now display both the last login time and the last logout time for |
| 91 |
user "bob". |
| 92 |
|
| 93 |
Now run the `bob-acct-stop.sh` program again. Observe how the server's output |
| 94 |
differs from the previous accounting stop packet. |
| 95 |
|
| 96 |
You should now read the `man` pages for the rlm_unix, rlm_radutmp, and |
| 97 |
rlm_unix modules, along with their configuration entries in |
| 98 |
`raddb/mods-available/radutmp` and `raddb/mods-available/unix`. |
| 99 |
|
| 100 |
In short, the "unix" module manages the database used by the `radlast` |
| 101 |
command. The "radutmp" module manages a separate database, which is used by |
| 102 |
the `radwho` command. |
| 103 |
|
| 104 |
The "detail" module simply logs every accounting request to a file in a simple |
| 105 |
textual format. |
| 106 |
|
| 107 |
== Questions |
| 108 |
|
| 109 |
1. Why do accounting messages require less configuration of the server |
| 110 |
than authentication methods? |
| 111 |
2. Why is the "detail" module useful? |
| 112 |
3. Where is the "detail" file located? Why is the "detail" file in this location? Where is it configured? |
| 113 |
4. What parts of the servers manage user session information? |
| 114 |
5. What module other than "radutmp" can manage user session |
| 115 |
information? |
| 116 |
6. Why is it useful to record which users are currently logged in? |
| 117 |
7. What attributes that are found in the accounting request are not found in the |
| 118 |
authentication request? Why? |
| 119 |
8. Which attributes are required to be in an accounting request? |
| 120 |
9. What error message is produced on the second accounting stop, and |
| 121 |
why is it produced? |
| 122 |
|
| 123 |
// Copyright (C) 2021 Network RADIUS SAS. Licenced under CC-by-NC 4.0. |
| 124 |
// This documentation was developed by Network RADIUS SAS. |