---
title: Kamailio SIP Trunk Registration - Telnyx
canonical: https://telnyx.com/resources/sip-trunk-registration-kamailio
---
# Kamailio SIP Trunk Registration - Telnyx

[Back to blog](https://telnyx.com/resources)

**SIP Trunking**

# Kamailio SIP Trunk Registration

Here we'll guide you through setting up Kamailio to be a SIP registrar. We'll also set up a softphone to register with Kamailio..

By [Sara Weichhand](https://telnyx.com/authors/sara-weichhand)

SIP trunk registration is a method for softphones to register with a VoIP system even when they have dynamic IP addresses or sit behind NAT. This guide walks through setting up Kamailio to function as a SIP registrar, configuring a softphone (Zoiper on Android) to register with Kamailio, and integrating this setup with [Telnyx SIP Trunking](https://telnyx.com/products/sip-trunks) for enterprise-grade voice connectivity.

Once configured, the softphone will register periodically (typically every 60 seconds) with the Kamailio host on port 5060\. Since registration takes place so frequently, Kamailio will be able to detect if the softphone IP changes and continue to route calls to and from it. Additionally, since it's the softphone that's reaching out to Kamailio when sending calls to the softphone, Kamailio can just point to the softphone IP and ephemeral port, allowing it to reach the softphone even if it's behind NAT.

## Why use Kamailio for SIP registration?

Kamailio is an open-source SIP server capable of handling thousands of calls per second. Unlike traditional PBX systems that bundle signaling with media and business logic, Kamailio focuses purely on SIP signaling, making it ideal for large-scale, distributed deployments. Whether you're building a [conversational AI solution](https://telnyx.com/use-cases/conversational-ai) or scaling a [VoIP infrastructure for small business](https://telnyx.com/use-cases/voip-for-small-business), Kamailio provides the flexibility and performance you need.

## Prerequisites

Before getting started, ensure you have:

* A Debian-like server (Ubuntu 20.04+ recommended)
* Root or sudo access
* Basic knowledge of SIP and Linux shell
* A public IP address (if registering remote clients)
* A [Telnyx Mission Control Portal account](https://portal.telnyx.com) for SIP trunk connectivity

For additional setup guidance, refer to the [Telnyx SIP Trunking Quickstart documentation](https://developers.telnyx.com/docs/voice/sip-trunking/get-started).

## Installing Kamailio

Assuming a Debian-like server, Kamailio can be easily installed via apt-get. The registration feature of Kamailio requires a database. For simplicity, SQLite will be used in this example. Start by installing Kamailio and the associated SQLite module, along with the optional command line interface for SQLite (useful for querying the Kamailio database):

sudo apt-get install kamailio kamailio-sqlite-modules sqlite3

## Setting up the SQLite database

Open up the `kamctlrc` file with your preferred editor:

sudo nano /etc/kamailio/kamctlrc

Uncomment and set the following variables:

DBENGINE=SQLITE
DB_PATH="/tmp/kamailio_sqlite.db"

While editing the `kamctlrc` file, also set the `SIP_DOMAIN` variable. This is needed to run Kamailio and have a softphone register with it. The `SIP_DOMAIN` variable should be set to the Kamailio host's public IP or domain name:

SIP_DOMAIN=<Kamailio host's public IP or domain name>

At this point, create the database with the `kamdbctl` command:

kamdbctl create

## Required Kamailio parameters

The following table outlines the essential Kamailio parameters that must be configured for SIP registration to work properly:

| Parameter        | File             | Value                             | Description                           |
| ---------------- | ---------------- | --------------------------------- | ------------------------------------- |
| DBENGINE         | kamctlrc         | SQLITE                            | Database engine selection             |
| DB\_PATH         | kamctlrc         | /tmp/kamailio\_sqlite.db          | Location of SQLite database file      |
| SIP\_DOMAIN      | kamctlrc         | Your public IP or domain          | Domain for SIP URI construction       |
| listen           | kamailio.cfg     | udp:<IP>:5060                     | SIP signaling port and protocol       |
| db\_url          | kamailio.cfg     | sqlite:///tmp/kamailio\_sqlite.db | Database connection string            |
| timer\_interval  | usrloc module    | 60 (default)                      | Seconds between timer runs            |
| db\_mode         | usrloc module    | 0-4                               | Database persistence mode             |
| default\_expires | registrar module | 3600                              | Default registration expiry (seconds) |
| min\_expires     | registrar module | 60                                | Minimum allowed expiry value          |

## Configuring Kamailio for registration

Edit the main Kamailio configuration file:

sudo nano /etc/kamailio/kamailio.cfg

Enable the required modules by uncommenting or adding these lines:

#!define WITH_SQLITE
#!define WITH_USRLOCDB

The key modules you need for registration are:

* **registrar**: Handles SIP REGISTER requests
* **usrloc**: Manages user location records (Address of Record)
* **auth\_db**: Provides authentication against a database

For production deployments, also consider enabling:

* **pike**: Rate limiting to prevent DoS attacks
* **htable**: Hash table for caching
* **permissions**: IP-based access control

## Kamailio usrloc module database modes

The usrloc module supports multiple database modes, each with different performance and persistence trade-offs. Choose based on your deployment requirements:

| Mode          | Value | Behavior                                        | Use Case                               |
| ------------- | ----- | ----------------------------------------------- | -------------------------------------- |
| No DB         | 0     | Memory only, no persistence                     | Development, high-performance testing  |
| Write-Through | 1     | Immediate DB write on every change              | High reliability, slower performance   |
| Write-Back    | 2     | Periodic DB sync via timer                      | Balance of performance and persistence |
| DB-Only       | 3     | No memory cache, DB queries only                | Multi-server with shared DB            |
| DB-Readonly   | 4     | Load from DB at startup, memory only at runtime | Replicated/clustered deployments       |

Configure the mode in your `kamailio.cfg`:

modparam("usrloc", "db_mode", 1)

## Adding users for authentication

To add users for authentication, use the `kamctl` utility:

kamctl add testuser testpassword

This creates a subscriber entry in the database. Users will authenticate using these credentials when their softphone registers.

## Telnyx trunk settings mapping

When connecting Kamailio to [Telnyx SIP Trunks](https://telnyx.com/products/sip-trunks), map these settings in your configuration:

| Telnyx Setting         | Kamailio Equivalent   | Value/Notes                      |
| ---------------------- | --------------------- | -------------------------------- |
| SIP Server             | Outbound proxy        | sip.telnyx.com                   |
| SIP Port               | listen port           | 5060 (UDP) or 5061 (TLS)         |
| Connection Type        | Authentication method | Credentials or IP-based          |
| Username               | uacreg l\_uuid        | From Telnyx portal               |
| Password               | uacreg auth\_password | From Telnyx portal               |
| Codec Priority         | modparam codecs       | G.711, G.729, Opus               |
| AnchorSite             | Outbound routing      | Latency-based or specific region |
| Outbound Voice Profile | Routing rules         | Configured in Telnyx portal      |

For detailed configuration steps, consult the [Telnyx SIP configuration guide](https://support.telnyx.com/en/articles/8096455-how-to-configure-a-sip-trunk) and [developer configuration guides](https://developers.telnyx.com/docs/voice/sip-trunking/get-started).

## Configuration options comparison

When setting up SIP registration, you have several architectural choices. Here's how they compare:

| Feature          | Kamailio Registrar                | Direct Provider Registration | PBX Registration        |
| ---------------- | --------------------------------- | ---------------------------- | ----------------------- |
| NAT Traversal    | Excellent (built-in)              | Provider-dependent           | Good with proper config |
| Scalability      | High (thousands/sec)              | Limited by provider          | Medium                  |
| Customization    | Full control                      | Limited                      | Vendor-specific         |
| Database Options | SQLite, MySQL, PostgreSQL, Redis  | N/A                          | Usually fixed           |
| Authentication   | Digest, TLS, IP-based             | Provider credentials         | Internal                |
| Failover         | Configurable                      | Provider-managed             | Usually built-in        |
| Cost             | Open source                       | Per-trunk fees               | License fees            |
| Complexity       | Higher                            | Low                          | Medium                  |
| Best For         | Large deployments, custom routing | Simple setups                | SMB unified comms       |

## Security best practices

Implement these security measures for production deployments:

### Enable digest authentication

route[AUTH] {
    if (!is_method("REGISTER|INVITE")) return;
    
    if (!auth_check("$fd", "subscriber", "1")) {
        auth_challenge("$fd", "0");
        exit;
    }
    consume_credentials();
}

### Rate limiting with pike module

modparam("pike", "sampling_time_unit", 2)
modparam("pike", "reqs_density_per_unit", 16)
modparam("pike", "remove_latency", 4)

route[PIKE] {
    if (!pike_check_req()) {
        xlog("L_ALERT", "PIKE: Blocking $si\n");
        exit;
    }
}

### Block known malicious user agents

if ($ua =~ "(friendly-scanner|sipvicious|sipcli)") {
    xlog("L_WARN", "Blocked scanner from $si\n");
    exit;
}

For comprehensive security guidance, review the [Kamailio Security Wiki](https://www.kamailio.org/wiki/tutorials/security/kamailio-security) and [NIST SP 800-58: Security Considerations for VoIP Systems](https://nvlpubs.nist.gov/nistpubs/legacy/sp/nistspecialpublication800-58.pdf).

## Starting Kamailio

After completing the configuration, start the Kamailio service:

sudo systemctl start kamailio
sudo systemctl enable kamailio

Check the status to ensure it's running:

sudo systemctl status kamailio

## Setting up Zoiper softphone

1. Download and install Zoiper from the app store on your Android device
2. Open Zoiper and select **Add account**
3. When asked whether there are a username and password, select **Yes**, then **Manual configuration**
4. Choose **SIP Account** and configure:
  * **Account name**: Any descriptive name
  * **Host**: Kamailio host's public IP or domain name
  * **Username**: The username created with `kamctl add`
  * **Password**: The corresponding password

Once saved, registration should be successful. For alternative softphone options, see our guide on [configuring Linphone with Telnyx](https://telnyx.com/resources/using-telnyx-with-linphone).

## Verifying registration

On the Kamailio side, use the SQLite command line interface to verify successful registration:

sqlite3 /tmp/kamailio_sqlite.db
sqlite> SELECT * FROM location;

Successfully registered users will appear in the location table with their contact information, including the device's current IP address and port.

You can also use the `kamcmd` tool to dump user locations:

kamcmd ul.dump

## Integrating with Telnyx for PSTN connectivity

To connect your Kamailio registrar to the PSTN through Telnyx:

1. Create a [Telnyx account](https://portal.telnyx.com) and complete verification
2. Set up a [SIP Connection](https://developers.telnyx.com/docs/voice/sip-trunking/get-started) with credential-based authentication
3. Purchase phone numbers in the Mission Control Portal
4. Configure Kamailio to route outbound calls through Telnyx

## Next steps

This setup provides a foundation for using Kamailio as a SIP registrar. From here, you can:

* Integrate with [FreeSWITCH](https://developer.signalwire.com/freeswitch/) for media handling
* Add TLS encryption for secure signaling (see [Nick vs Networking Kamailio security guide](https://nickvsnetworking.com/kamailio-101-part-8-security-in-practice/))
* Configure [dispatcher module](https://kamailio.org/docs/modules/devel/modules/dispatcher.html) for load balancing
* Set up [presence and instant messaging](https://www.kamailio.org/docs/modules/devel/modules/presence.html)

For additional learning, the [Nick vs Networking Kamailio 101 series](https://nickvsnetworking.com/kamailio-taking-registrations/) provides excellent tutorials on Kamailio configuration.

## Additional resources

* [Telnyx SIP Trunking Product Page](https://telnyx.com/products/sip-trunks)
* [Telnyx Developer Portal](https://developers.telnyx.com/docs/voice/sip-trunking/get-started)
* [Telnyx Support Center](https://support.telnyx.com/en/articles/8096455-how-to-configure-a-sip-trunk)
* [Kamailio Official Documentation](https://www.kamailio.org/docs/modules/devel/modules/usrloc.html)
* [Kamailio GitHub Repository](https://github.com/kamailio/kamailio)

To learn more about SIP Trunking and its uses, explore our [SIP Trunking page](https://telnyx.com/products/sip-trunks) or test it yourself in the [Telnyx Mission Control Portal](https://portal.telnyx.com).

_Have questions about SIP trunk registration in Kamailio? Join our [subreddit](https://www.reddit.com/r/Telnyx/)._

Share on Social

Sara Weichhand

Customer Success Manager

Sara was a former technical writer at Telnyx. She holds a B.A. in Economics from the University of Michigan.

## Jump to:

[Why use Kamailio for SIP registration?](#why-use-kamailio-for-sip-registration)[Prerequisites](#prerequisites)[Installing Kamailio](#installing-kamailio)[Setting up the SQLite database](#setting-up-the-sqlite-database)[Required Kamailio parameters](#required-kamailio-parameters)[Configuring Kamailio for registration](#configuring-kamailio-for-registration)[Kamailio usrloc module database modes](#kamailio-usrloc-module-database-modes)[Adding users for authentication](#adding-users-for-authentication)[Telnyx trunk settings mapping](#telnyx-trunk-settings-mapping)[Configuration options comparison](#configuration-options-comparison)[Security best practices](#security-best-practices)[Starting Kamailio](#starting-kamailio)[Setting up Zoiper softphone](#setting-up-zoiper-softphone)[Verifying registration](#verifying-registration)[Integrating with Telnyx for PSTN connectivity](#integrating-with-telnyx-for-pstn-connectivity)[Next steps](#next-steps)[Additional resources](#additional-resources)

## Sign up for emails of our latest articles and news

[Start building](https://telnyx.com/sign-up)

Related articles

* [**SIP Trunking**SIP response codes: a quick reference to every SIP code and error![Serhii](https://d2efw2akbx8gaf.cloudfront.net/https://dotcom-payload-assets-prod.s3.us-east-1.amazonaws.com/cms-media/_DSC8799-6.jpg?width=96&format=webp)By Serhii Omelchenko14, Oct 2026](https://telnyx.com/resources/sip-response-codes)
* [**SIP Trunking**SIP DID numbers: what they are and how they work![Deniz Yakışıklı](https://d2efw2akbx8gaf.cloudfront.net/https://dotcom-payload-assets-prod.s3.us-east-1.amazonaws.com/cms-media/Deniz_Yakisikli_6b7b420ed4.png?width=96&format=webp)By Deniz Yakışıklı29, Sep 2026](https://telnyx.com/resources/sip-did)
* [**SIP Trunking**HIPAA-compliant voice and fax solutions for healthcare![Fiona McDonnell](https://d2efw2akbx8gaf.cloudfront.net/https://dotcom-payload-assets-prod.s3.us-east-1.amazonaws.com/cms-media/11_5e5b137a78.jpg?width=96&format=webp)By Fiona McDonnell23, Sep 2026](https://telnyx.com/resources/secure-communications-for-healthcare)
* [**Voice**Build vs buy contact center software in 2026: build, buy or extend![Serhii](https://d2efw2akbx8gaf.cloudfront.net/https://dotcom-payload-assets-prod.s3.us-east-1.amazonaws.com/cms-media/_DSC8799-6.jpg?width=96&format=webp)By Serhii Omelchenko26, Oct 2026](https://telnyx.com/resources/contact-center-software-build-vs-buy)
* [**Conversational AI**An omnichannel AI front desk for hotels, built on Telnyx![Deniz Yakışıklı](https://d2efw2akbx8gaf.cloudfront.net/https://dotcom-payload-assets-prod.s3.us-east-1.amazonaws.com/cms-media/Deniz_Yakisikli_6b7b420ed4.png?width=96&format=webp)By Deniz Yakışıklı21, Oct 2026](https://telnyx.com/resources/telnyx-demo-hotel-ai-receptionist)
* [**WhatsApp Business API**WhatsApp AI Voice Agents: How They Work and How to Set One Up![Deniz Yakışıklı](https://d2efw2akbx8gaf.cloudfront.net/https://dotcom-payload-assets-prod.s3.us-east-1.amazonaws.com/cms-media/Deniz_Yakisikli_6b7b420ed4.png?width=96&format=webp)By Deniz Yakışıklı14, Oct 2026](https://telnyx.com/resources/whatsapp-calling-ai-voice-agents)

### Ask AI

* [![GPT](https://d2efw2akbx8gaf.cloudfront.net/https://dotcom-payload-assets-prod.s3.us-east-1.amazonaws.com/cms-media/chatgpt_icon-ea55e09d.jpeg?width=92&format=webp)](https://chat.openai.com/?q=What makes Telnyx's global network different, breakdown call quality for normal phone calls and voice AI calls.)
* [![Claude](https://d2efw2akbx8gaf.cloudfront.net/https://dotcom-payload-assets-prod.s3.us-east-1.amazonaws.com/cms-media/claude_icon-c7c8eef3.webp?width=92&format=webp)](https://claude.ai/new?q=What makes Telnyx's global network different, breakdown call quality for normal phone calls and voice AI calls.)
* [![Perplexity](https://d2efw2akbx8gaf.cloudfront.net/https://dotcom-payload-assets-prod.s3.us-east-1.amazonaws.com/cms-media/perplexity_icon-cd5b74f1.webp?width=92&format=webp)](https://www.perplexity.ai/search?q=What makes Telnyx's global network different, breakdown call quality for normal phone calls and voice AI calls.)
* [![Gemini](https://d2efw2akbx8gaf.cloudfront.net/https://dotcom-payload-assets-prod.s3.us-east-1.amazonaws.com/cms-media/gemini_icon-4ff1cbf4.webp?width=92&format=webp)](https://www.google.com/search?udm=50&aep=11&q=What makes Telnyx's global network different, breakdown call quality for normal phone calls and voice AI calls.)
* [![Grok](https://d2efw2akbx8gaf.cloudfront.net/https://dotcom-payload-assets-prod.s3.us-east-1.amazonaws.com/cms-media/grok_icon-e588e5bd.webp?width=92&format=webp)](https://x.com/i/grok?text=What makes Telnyx's global network different, breakdown call quality for normal phone calls and voice AI calls.)