# Using UniFi Talk with a Kamailio SIP Trunk

Table of Contents

In recent days, I’ve been experimenting with UniFi Talk and wanted a SIP trunk that’s not part of the PSTN - something I could play with without limitations.

What Is a SIP Trunk?

A SIP trunk is a connection to a SIP provider that handles inbound and outbound call routing - traditionally to and from the PSTN.

To simulate that environment, we’ll need to create a local SIP provider.

What Does a SIP Provider Do?

  • Routes calls between multiple SIP endpoints or trunks
  • Allocates numbers (DIDs) to subscribers
  • Authenticates users and prevents number hijacking

Why Kamailio?

Kamailio can handle all of these roles - it’s an open-source SIP server designed for flexibility and scalability.

Setting Up Kamailio

We’ll run Kamailio using Docker Compose with a minimal config.

docker-compose.yml
services:
kamailio:
image: ghcr.io/kamailio/kamailio:6.0.1-noble
ports:
- 5060:5060
- 5060:5060/udp
volumes:
- ./kamailio.cfg:/etc/kamailio/kamailio.cfg

There are two important things here:

  1. Port 5060 TCP+UDP is used for SIP traffic
  2. A kamailio.cfg file needs to be create alongside the docker compose file

My basic Kamailio config is actually borrowed from NickVsNetworking who has a great tutorial series on Kamailio configuration

Configuring UniFi Talk

Firstly we need to make sure the Static Signalling port is enabled:

  1. Go to: Talk > Settings > System > General
  2. Then tick the box Static Signalling Port, any number is fine but 6767 is the default.
  3. Make sure to appropriately forward this port

Finally we can now configure the SIP trunk:

  1. Go to: Talk > Settings > System > Third-party SIP
  2. Create New
  3. Set Provider to Custom
  4. Set the provider name to whatever you want.
  5. Add the custom fields:
Field NameValue
proxyKamailio IP or domain
realmSame as proxy
domainSame as proxy
dtmfmoderfc2833
passwordAny placeholder (or real password if using auth)
registertrue
usernameYour E.164 phone number
extensionauto_to_user
from-domainlocation
auth-usernameSame as username

UniFi Talk expects E.164-format numbers for proper routing. For isolated, non-PSTN use, I recommend numbers like +999xxxxxxxx as +999 is reserved for testing and documentation.

  1. Add your phone number in the Phone Numbers list.
  2. Add the IP addresses of your Kamailio server in to the IP Address Range, if you have a single IP you can use /32 in your range.

Conclusion

You now have a fully functional, non-PSTN SIP trunk integrated into UniFi Talk. All calls will route through Kamailio just like a real SIP provider - but with no subscription, no upstream carrier, and total control.

This setup lets you:

  • Test call flows, IVRs, and voicemail
  • Simulate users and devices
  • Experiment with SIP signaling and Kamailio scripting
  • Do it all without touching the real telephone network
ajh123

Thanks for reading my blog post! Feel free to check out my other posts or contact me via the social links in the footer.


More Posts

Comments