The server OS is Ubuntu 18.04 LTS
In our example we will Install OpenSIPS v.2.4.3 from sources although the setup should be similar for any series v2.x.x version.
Make sure we have all prerequisites:
Download from official sources and build:
When build finished, verify if opensips binary starts. It may complain about incorrect configuration and exit:
Download RTPProxy from Github and compile from sources:
OpenSIPS configuration file is located at /usr/local/etc/opensips/opensips.cfg
It can be generated automatically from installation option make menuconfig
The following sections below are relavant for our setup of full SIP/RTP proxy. Add/modify them to your opensips.cfg file:
Addresses. Public and private IP addresses of server instance:
Connection to RTPProxy. OpenSIPS needs to know the socket where RTPProxy listens to communicate with it to do address rewrite:
Now, inside your "route" section you have your main routing script. Your configuration may vary depending on your setup, so we will just add a call to a subroutine whenever valid route is found and selected by script:
And add the subrouting block which will handle it:
As you can see from the piece above, for every inbound call OpenSIPS will request RTPProxy to rewrite SDP body.
Below code block is responsible for modifying all replies in the dialog. It makes RTPProxy to offer external public IP to the remote client.
Finally, add the failure block if not present:
RTPProxy does not have configuration file. Instead it takes options as CLI parameters.
For our current setup, RTPProxy should be started like this:
Important options to configure:
-s - UDP socket to connect to OpenSIPS. Should match with the setting in OpenSIPS configuration file
-A - Internal / external IP addresses
-l - IP addresses of RTPProxy itself
The configuration is complete. Start opensips in foreground mode and check its output. It should be able to establish the connection with RTPProxy :
Once done, start OpenSIPS as a daemon: