How to provision a test user in kamailio?

blueFast picture blueFast · Jul 1, 2013 · Viewed 9.7k times · Source

I have just (for the first time) compiled and installed kamailio, following this guide. For configuration, I am following the documentation here

I am trying to test a new SIP user. I have created it with:

» kamctl add test testpasswd

The user is there:

» kamctl db show subscriber
|----+----------+--------------------+------------+---------------+----------------------------------+----------------------------------+------|
| id | username | domain             | password   | email_address | ha1                              | ha1b                             | rpid |
|----+----------+--------------------+------------+---------------+----------------------------------+----------------------------------+------|
|  5 | test     | tethys.wavilon.net | testpasswd |               | 5cf40781f33c6f43a26244046564b67e | eb898de815bc16092e4c2e8c04bfe188 | NULL |
|----+----------+--------------------+------------+---------------+----------------------------------+----------------------------------+------|

I try to connect with my sip client, and the registration times out (Request Timeout (408)). I have tried to verify what is going on by doing:

» kamailio -l <my-ip> -E -ddddd -D 1

And I see lots of messages, one of them interesting:

0(15818) DEBUG: auth [api.c:86]: pre_auth(): auth:pre_auth: Credentials with realm '<my-ip>' not found

But I do not know how to solve this problem. How can I verify what credentials associated to realm <my-ip> are configured? What is a "realm"? I do not find any beginners guide for kamailio. Is there a simple how-to on how to setup a simple kamailio configuration?

Answer

miconda picture miconda · Jul 5, 2013

The log message you pasted in the question is for debug purposes (hence DEBUG level) and it could be printed for first SIP requests that come with no credentioals (e.g., first REGISTER) -- in such case it is all ok. Those requests are challenged for authentication with 401 replies, then they are resent by phone with credentials in Autorization header.

If for those requests with credentials you don't get the same realm as used in challenge function parameters (e.g., www_challenge(), auth_challenge()...), then the SIP phone might be misconfigured. Typically the realm is the same as SIP domain in order to ensure it is unique, but that is not a must. With default kamailio configuration, the realm is the From header URI domain.

However, you say you get 408 timeout for registration, then the issues might be something else. When the credentials matching the realm are not found, then 401reply is sent back, not 408.

The reason for timeout could be that the REGISTER didn't get to kamailio or kamailio tries to send it somewhere else. You should look at the SIP traffic on the kamailio server to see what happens. You can use ngrep for that purpose, like:

ngrep -d any -qt -W byline . port 5060

Watch to see if the REGISTER comes to kamailio server and if it is attempted to be sent to another IP.