Kamailio with MySQL,Nat support and RTPProxy

From open-voip.org

Jump to: navigation, search

backup your kamailio.conf file:

cp /etc/kamailio/kamailio.cfg /etc/kamailio/kamailio.cfg_orig

run the scripts to start kamailio with mysql, authentication and NAT traversal:

sed -i 's/#m#//g' kamailio.cfg
sed -i 's/#a#//g' kamailio.cfg
sed -i 's/#n#//g' kamailio.cfg

edit the kamailio.conf file in order to configure the sql parameters and the rtpproxy: at the auth db param change the following line with your mysql host user and pass:

# ----- auth_db params -----
modparam("auth_db", "db_url","mysql://openser:asterisk@localhost/openser")

Install RTPProxy

We will install the rtpproxy on the same host of he Kamailio, same procedure goes for remote RTPProxy. It is recommended to NOT install the RTPProxy on Fedora 9. Centos 5.4 worked fine for me.

cd /opt/
wget http://b2bua.org/chrome/site/rtpproxy-1.2.1.tar.gz
tar -zxvf rtpproxy-1.2.1.tar.gz 
cd rtpproxy-1.2.1
make install

Run the RTP proxy

./rtpproxy -F -l localhost -s udp:*:7722

in oreder to stop rtpproxy, check the process id and kill it:

 ps -aux | grep rtpproxy
 kill <proccess number>

In the Kamailio.conf change the following RTP configuration (for local and remote RTPproxy)

# -- nathelper
modparam("nathelper", "rtpproxy_sock", "udp:localhost:7722")

for multiple RTP proxy just add to the list as follow:

modparam("nathelper", "rtpproxy_sock", "udp:firsthost:12221 udp:secondhost:12221")

make sure mysql is running and start kamailio:

/etc/init.d/mysqld start
kamctl start

in order to verify that kamailio is workin with rtpproxy look for the following line in the log:

tail -f /var/log/messages
INFO:nathelper:rtpp_test: rtp proxy <udp:localhost:7722> found, support for it enabled

RTPProxy Confiuration options in kamailio.cfg

Socket used to connect to RTPProxy.

modparam("nathelper", "rtpproxy_sock", "udp:localhost:12221")

If true (set to a non 0 value), the RTPProxy support will be desabled

rtpproxy_disable (integer)

Once RTPProxy was found unreachable and marked as disable, nathelper will not attempt to establish communication to RTPProxy for rtpproxy_disable_tout seconds. Default value is "60".

modparam("nathelper", "rtpproxy_disable_tout", 20)

Timeout value in waiting for reply from RTPProxy. Default value is "1".

rtpproxy_tout (integer)

How many times nathelper should retry to send and receive after timeout was generated. Default value is "5".

rtpproxy_retr (integer)

Personal tools