Kamailio - Getting up and running with rtpproxy

Note: Ubuntu 14.04 & Kamailio 4.0.X (default config) was used for this guide

After being constantly stumped by RTPProxy and Kamailio, I’ve finally figured it out. In retrospect I’m not sure why it took me so long to figure out how to use them together. To save anyone else from future headaches, I’ll document how I got RTPProxy to work with Kamailio.

As a quick note, here’s how I use Kamailio.

Zoiper (NAT) => Kamailio (Public) => Carrier

With that, let’s get started by installing RTPProxy.

# apt-get install rtpproxy

We need to make a few changes to the RTPProxy config file. With your editor of choice open “/etc/default/rtpproxy”. You should see a line that starts with “EXTRA_OPTS”. Modify that line to look like this.


Here’s a quick explanation.

  • -F = Force to run as root

  • -s = Specify the protocol and address that RTPProxy should bind to

  • -l = Specify the address RTPProxy should address as

  • -d = First option is the log level. The second option is the log facility RTPProxy should use

Save and exit the file. Next, we need to change the init file for RTPProxy. Thankfully, we only need to make a couple of changes.Open “/etc/init.d/rtpproxy”.

Change the “DAEMON” line to look like:


Then change the “PIDFILE” line to:


Save and exit the file. Next, we need to make a couple of modifications to the Kamailio config file. Open the file, in my case, “/etc/kamailio/kamailio.cfg”.

Towards the top of the file, append the following line so Kamailio knows we plan on dealing with NAT.

#!define WITH_NAT

Further down, we will need to modify the rtpproxy_sock value to match the -s option we set for RTPProxy.

modparam("rtpproxy", "rtpproxy_sock", "udp:")

Save and exit the file. All the necessary changes have been made. Let’s start up RTPProxy.

# service rtpproxy start

Verify it’s listening on the correct interface

# netstat -tulpn | grep rtp

You should get a response similar to this.

udp 0 0* 11726/rtpproxy

Start Kamailio up

# kamctl start

We can verify that Kamailio and RTPProxy can communicate with each other by checking the log files. If you’ve followed my previous post, you should already have Kamailio logging to it’s own file. If you don’t, take a brief moment and implement it. In the log file you should see a line like this

Feb 12 13:58:38 dev /usr/sbin/kamailio[6926]: INFO: rtpproxy [rtpproxy.c:1559]: rtpp_test(): rtp proxy <udp:> found, support for it enabled

Looking at the SIP messages, you should notice that Kamailio changed a couple headers and part of the SDP body. The VIA, Contact, and Record-Route headers are all modified to include the users public IP address. In the SDP body, the c and o options should now have the IP address that we gave the -l parameter earlier.

Question or comment ? Let me know on twitter or email.