Installing Mediaproxy 2 on CentOS 5 64bit

Mediaproxy 2 is a Python application from AG-Projects which is available as a free download as well as being available as a commercial product from AG-Projects. It is used in combination with the Mediaproxy module of OpenSIPS.

Unlike Mediaproxy 1, the new version has a lot of dependencies and it can be quite tricky to install. The INSTALL instructions that come with the package are very helpful, but unfortunately they are aimed primarily at installers who either have Debian or Ubuntu Linux distributions. If you are using CentOS (or Red Hat), especially the 64 bit versions, then getting Mediaproxy 2 to run could be the cause of much lost sleep (or lost hair or both)!

Having spent at least three days tearing my hair out getting it to work, it seemed like a friendly thing to do would be to let other CentOS OpenSIPS installers have the benefit of my experience. It also provides me with a reference document next time I want to build an OpenSIPS server on CentOS.

So here are the sequential instructions for installing the libraries needed for Mediaproxy 2. If you follow the instructions here, then continue with the instructions already supplied in the INSTALL file that comes with Mediaproxy 2, then you should get a result (much quicker than the first time I tried). ….and many thanks to Dan Pascu of ag-projects for all his help.

If you are installing on CentOS 6

Please note there is an updated version of this article for CentOS 6 at the following location:
https://kb.smartvox.co.uk/opensips/install-mediaproxy-centos-6/

Update and install some packages using YUM

C and C++ compilers
yum install gcc
yum install gcc-c++

Development libraries and headers for some existing packages
yum install libgpg-error-devel.x86_64
yum install python-devel.x86_64

Install Linux libnetfilter_conntrack from RPM

libnfnetlink
Suggested version: libnfnetlink-0.0.40-1.el5.rf.x86_64.rpm
Locating a download: Use Advanced Search here http://rpm.pbone.net
Install: rpm -i libnfnetlink-0.0.40-1.el5.rf.x86_64.rpm

libnfnetlink-devel
Suggested version: libnfnetlink-devel-0.0.40-1.el5.rf.x86_64.rpm
Locating a download: Use Advanced Search here http://rpm.pbone.net
Install: rpm -i libnfnetlink-devel-0.0.40-1.el5.rf.x86_64.rpm

libnetfilter_conntrack
Suggested version: libnetfilter_conntrack-0.0.97-1.el5.rf.x86_64.rpm
Locating a download: Use Advanced Search here http://rpm.pbone.net
Install: rpm -i libnetfilter_conntrack-0.0.97-1.el5.rf.x86_64.rpm

libnetfilter_conntrack-devel
Suggested version: libnetfilter_conntrack-devel-0.0.97-1.el5.rf.x86_64.rpm
Locating a download: Use Advanced Search here http://rpm.pbone.net
Install: rpm -i libnetfilter_conntrack-devel-0.0.97-1.el5.rf.x86_64.rpm

Install libgcrypt (if needed) and gnutls from source tarball

Check your libgcrypt version first. Install v1.2.4 if required
Depending on which release of CentOS you are using, it is possible that your server already has a sufficiently up-to-date version of libgcrypt. Check the existing version using the following yum commands:
yum info libgcrypt
yum info libgcrypt-devel

If yum shows a version later than 1.2.4 then you will not need to install from source. Instead, just make sure that yum shows the library is “installed” rather than just being “available”. Make sure you check for the -devel package as well as the main package. If either package is not installed, use these commands to install it:

yum install libgcrypt
yum install libgcrypt-devel

If you are running on an older CentOS release with a correspondingly old version of libgcrypt, then you will have to install a newer version from source as follows:
Suggested version: libgcrypt-1.2.4.tar.gz
Locating a download site: http://www.gnupg.org/download/mirrors.en.html
Unzip: tar -xzf libgcrypt-1.2.4.tar.gz
Change to the sub-directory created when you unzipped the tarball
Build and install the library:
./configure –libdir=/usr/local/lib64
make
make install

Then install gnutls
Suggested version: gnutls-2.4.2.tar.bz2
Locating a download site: http://www.gnupg.org/download/mirrors.en.html
Unzip: tar -xf gnutls-2.4.2.tar.bz2
Change to the sub-directory created when you unzipped the tarball
Build and install the library:
./configure –with-included-libtasn1 –libdir=/usr/local/lib64
make
make install

Manually copy some run-time libraries to /usr/lib64

Copy the following dynamic libraries from /usr/local/lib64 to /usr/lib64
libgcrypt.so.11.2.3 (only if you installed v1.2.4 from source)
libgnutls.so.26
libgnutls.so.26.4.6
libgnutls-extra.so.26
libgnutls-extra.so.26.4.6
libgnutls-openssl.so.26
libgnutls-openssl.so.26.4.6

You may also need to edit the sym-link /usr/lib64/libgcrypt.so.11
On older releases of CentOS 5 where it was necessary to install libgcrypt 1.2.4 from source, you will probably find remnants of the older version of libgcrypt that was already present on the machine before you installed version 1.2.4. In this case, it may be necessary to modify or replace a sym-link present in /usr/lib64:
libgcrypt.so.11 –> libgcrypt.so.11.2.2
On my server, I used midnight commander to edit the sym-link so it pointed to the new runtime library installed from the tarball. It now looks like this:
libgcrypt.so.11 –> libgcrypt.so.11.2.3

Install some Python packages

Install ctypes
This library is required for Python version 2.4, which is the default version installed by yum at the time of writing. However, if you have Python version 2.5 (or later) then you probably will not need this library as it is included.

Suggested version: ctypes-1.0.2.tar.gz
Locating a download site: http://pypi.python.org/pypi/ctypes/1.0.2
Unzip: tar -xzf ctypes-1.0.2.tar.gz
Change to the sub-directory created when you unzipped the tarball
Build and install the library:
./setup.py build
./setup.py install

Install python-application
Suggested version: python-application-1.1.5.tar.gz
Locating a download site: http://pypi.python.org/pypi/python-application/1.1.5
Unzip: tar -xzf python-application-1.1.5.tar.gz
Change to the sub-directory created when you unzipped the tarball
Build and install the library:
./setup.py build
./setup.py install

Install python-cjson
Suggested version: python-cjson-1.0.5.tar.gz
Locating a download site: http://pypi.python.org/pypi/python-cjson/1.0.5
Unzip: tar -xzf python-cjson-1.0.5.tar.gz
Change to the sub-directory created when you unzipped the tarball
Build and install the library:
./setup.py build
./setup.py install

Install python-gnutls
Suggested version: python-gnutls-1.1.9.tar.gz
Locating a download site: http://pypi.python.org/pypi/python-gnutls/1.1.9
Unzip: tar -xzf python-gnutls-1.1.9.tar.gz
Change to the sub-directory created when you unzipped the tarball
Build and install the library:
./setup.py build
./setup.py install

Install Python-ZopeInterface from RPM

Python-Zopeinterface
Suggested version: python-ZopeInterface-3.3.0-1.el5.pp.x86_64.rpm
Locating a download: Use Advanced Search here http://rpm.pbone.net
Install: rpm -i python-ZopeInterface-3.3.0-1.el5.pp.x86_64.rpm

Install the Twisted Python package

Install the core Twisted package from Twisted Matrix Labs
Suggested version: Twisted-8.1.0.tar.bz2
Locating a download site: http://twistedmatrix.com/trac
Unzip: tar -xf Twisted-8.1.0.tar.bz2
Change to the sub-directory created when you unzipped the tarball
Build and install the library:
./setup.py build
./setup.py install

Install Mediaproxy 2

Mediaproxy 2
Suggested version: mediaproxy-2.3.8.tar.gz
Locating a download site: http://download.ag-projects.com/MediaProxy
Suggested location to copy and then unzip the tarball: /usr/local
Unzip: tar -xzf mediaproxy-2.3.8.tar.gz
Change to the sub-directory created when you unzipped the tarball
Build and install the library (system wide):
./setup.py build
./setup.py install

Build and install the library (standalone in the local directory):
./build_inplace

And finally…

Make sure iptables is installed and running
Mediaproxy depends on iptables to relay IP packets through your server. You can check it is installed using yum:
yum info iptables

You can install is using the command:
yum install iptables

Set ip forwarding with immediate effect
echo “1” > /proc/sys/net/ipv4/ip_forward

Set ip forwarding permanently
Edit the file /etc/sysctl.conf
Change the line “net.ipv4.ip_forward = 0”
to “net.ipv4.ip_forward = 1”

config.ini
Create a config.ini file from the sample template provided (config.ini.sample) and copy it to the appropriate directory. Using the system wide version, put it in /etc/mediaproxy. For standalone build you can also put it in the local directory where media-relay and media-dispatcher are located. If a file exists in both locations, the local one takes precedence.

8 thoughts on “Installing Mediaproxy 2 on CentOS 5 64bit”

  1. I am trying to configure the mediaproxy to act as an SBC for ingress and egress SIP phone calls.
    A free switch will be sending calls to an “opensip” server via the mediaproxy relay box.
    The Freeswitch is on the internal private subnet, and the opensip is on the public network…
    For very basic SIP calls from and to freeswitch, where can I configure the mediaproxy to map private IP of the free swtich to the public IP of the opnesip?
    I am a newbe on the “freeswitch, opensip and media proxy”…

    • Joe,
      Mediaproxy is not the right application. It is designed to be a solution for far-end NAT traversal, not as a bridge for media to enter on one interface and leave on another. You would do better to look at RTP Proxy instead.

      Also note that the basic SBC functionality you describe cannot be separated out into independent solutions for the media and for the SIP signalling. The two work together in so far as the media address information is described by the SDP protocol and the SDP information is sent as a data payload in the SIP messages.

      You say that you are a “newbe”, but you are setting yourself a project (near-end NAT traversal and SBC) that would be quite challenging to many experts. To learn about SIP and OpenSIPS, I suggest you start with something simpler. If, on the other hand, you have a business critical project that needs an SBC then you should consider bringing in experienced assistance.

      John

  2. Package iptables-devel-1.3.5-9.1.el5.i386 already installed and latest version

    When start ./setup.py build
    I receive:
    No valid iptc library was found on the system. Please install iptables development libraries.

  3. Thanks for a great writeup.
    On Centos 6 (64) you need to install (yum) iptables-devel or mediaproxy will not make

    • Thanks for the info about Centos 6, Nik. I haven’t had time to test it yet.

      It’s surprising that Centos 5 didn’t require that package – “yum info” shows that the package is available, but I have never had to install it.

Comments are closed.