Run your own SIP VoIP service on both IPv4 and IPv6

At the date of publishing the article, the world celebrated IPv6 day, a good opportunity to show how to build your own SIP-based VoIP service to run on both IPv4 and IPv6 networks using open source Kamailio SIP server.

Kamailio has support for IPv6 since 2002, but since the presence of IPv6 networks was not a part of reality, its usage was quite limited in the past. Also we tested the core and the most used modules last year at the SIPit event in Sweden. Now the interest has increased substantially, a fact visible also in the subject of the topics discussed on project's forums.

The target with this tutorial is to have a service that is able to handle VoIP traffic:

in IPv4 networks

in IPv6 networks

bridge between IPv4 and IPv6 networks when needed

Kamailio itself is a SIP signaling server, therefore it will take care of bridging the SIP traffic. To bridge the media stream between IPv4 and IPv6, we will use RTPProxy, an application used so far mainly to help with NAT traversal in IPv4 networks.

Did I say NAT? Fortunately it will disappear soon, when (if) IPv6 will take the control in Internet communications.

About the environment

To make the guidelines for this tutorial, I built a local lab environment where I used:

Kamailio devel version running on Ubuntu 11.04 with next IP addresses:

IPv4: 192.168.178.26

IPv6: fec0:0:0:1001::1

Jitsi SIP softphone running on Mac OS X with next IP address:

IPv4: 192.168.178.21

Jitsi SIP softphone running on Ubuntu 10.10 with next IP address:

IPv6: fec0:0:0:1001::3

To install Kamailio devel version (to become 3.2.0 release in Autumn 2011), use following guidelines:

I used Kamailio development version since the plan is to include the IPv6 support in the default configuration file for the next major release 3.2.0, thus making my life easier in the near future.

However, the same concept can be applied to the latest stable v3.1.x, just use the appropriate functions from rtpproxy module - the development version introduced a new function rtpproxy_manage() which is a wrapper around existing functions in v3.1.x: rtpproxy_offer(), rtpproxy_answer() and unforce_rtp_proxy() – the parameters have the same meanings both versions.

Debian/Ubuntu users can install Kamailio development version from the APT repository (nightly builds), see:

FYI: I tested also with Linphone on IPv6 and seemed to be fine – a side not: Linphone for Mac OS X didn't have support for video and I wanted to test also multi-streams IPv4-IPv6 bridging (audio and video in this case).

for this article I installed RTPProxy from Ubuntu default APT repository with:

apt-get install rtpproxy

RTPProxy creates a special user (named rtpproxy) to run under unprivileged permissions. You have to allow Kamailio to communicate with it via control socket. One easy way is to edit /etc/init.d/rtpproxy and set the running user ID to kamailio since it is the only application accessing it, like:

USER=kamailio

Note that RTPProxy has to be started with special parameters in order o bridge between IPv4 and IPv6 addresses:

-l ADDR_IPV4 -6 /ADDR_IPV6

You have to change the /etc/init.d/rtpproxy to add these parameters.

Sample Scenario

I called using one Jitsi phone on IPv6 and one on IPv4, turning on video conversation – this is the most interesting case in my opinion: bridging real-time communication between IPv6 and IPv4 networks.

Here is the result - I is talking to me.

SIP Traffic

For the technical guys, I pasted below the relevant SIP signaling messages for this call (I stripped some of the SDP content since it was too big and irrelevant for this case – just codecs attributes).