RTPProxy is an open-source RTP (Real-time Transport Protocol) media relay designed for SIP infrastructure. It sits between call endpoints and relays audio/video streams, solving NAT traversal problems that plague VoIP deployments. SIP proxies like Kamailio and OpenSIPS use RTPProxy to anchor media through a known public IP when endpoints are behind NAT or firewalls.
This guide covers installing RTPProxy on Ubuntu 24.04 and Rocky Linux 10, configuring it as a systemd service, setting up firewall rules for the RTP port range, and integrating it with both Kamailio and OpenSIPS. The latest stable release is RTPProxy 3.2.0 (March 2025) from the Sippy Software GitHub repository.
Prerequisites
- A server running Ubuntu 24.04 LTS or Rocky Linux 10 with root or sudo access
- A public IP address if relaying media for endpoints behind NAT
- UDP ports 35000-65000 open for RTP traffic (configurable)
- A SIP proxy (Kamailio or OpenSIPS) installed if you plan to integrate RTPProxy with your signaling layer
Step 1: Install RTPProxy Build Dependencies
RTPProxy is not available in the default Ubuntu 24.04 or Rocky Linux 10 package repositories, so we build it from source. Start by installing the required development tools and libraries.
On Ubuntu 24.04, install the build toolchain:
sudo apt update
sudo apt install -y build-essential git autoconf automake libtool pkg-config
On Rocky Linux 10, install the equivalent packages:
sudo dnf groupinstall -y "Development Tools"
sudo dnf install -y git autoconf automake libtool pkgconf-pkg-config
Step 2: Build and Install RTPProxy from Source
Clone the RTPProxy repository and build from the main branch to get the latest features including WebRTC/WSS support. The build uses standard GNU autotools, so the process is identical on both Ubuntu and Rocky Linux.
cd /usr/local/src
sudo git clone https://github.com/sippy/rtpproxy.git
cd rtpproxy
sudo git submodule update --init --recursive
If you prefer a specific stable release instead, check out a tag before building:
sudo git checkout v3.2.0
Generate the configure script and compile:
sudo autoreconf -fi
sudo ./configure
sudo make -j$(nproc)
sudo make install
Verify the installation by checking the binary version:
rtpproxy -V
The output shows the version and commit hash. Building from main shows the latest development version, while a tagged release shows the release number:
3.2.0.b26b09b3
The binary installs to /usr/local/bin/rtpproxy by default. Create a dedicated system user for the RTPProxy process:
sudo useradd -r -s /usr/sbin/nologin rtpproxy
Step 3: Configure RTPProxy Options
RTPProxy accepts all configuration through command-line flags. The key options control the listening address, control socket, and RTP port range. Here is a reference of the most important flags:
| Flag | Description | Default |
|---|---|---|
-l addr | IPv4 listen address for RTP streams | 0.0.0.0 |
-6 addr | IPv6 listen address | none |
-s sock | Control socket (unix, udp, tcp) | unix:/var/run/rtpproxy.sock |
-m port | Minimum UDP port for RTP | 35000 |
-M port | Maximum UDP port for RTP | 65000 |
-T seconds | RTP session inactivity timeout | 60 |
-t tos | IP Type of Service for RTP packets | 0xB8 (EF/DSCP 46) |
-d level | Log level (DBUG, INFO, WARN, ERR) | DBUG |
-F | Run without root privilege warning | off |
-f | Run in foreground (for systemd) | off |
-u user | Run as specified user | root |
Create an environment file to store the RTPProxy runtime options. This keeps configuration separate from the systemd unit and makes tuning easy.
sudo vi /etc/default/rtpproxy
Add the following configuration – replace YOUR_PUBLIC_IP with your server’s actual public IP address:
# RTPProxy configuration
# Listen address - use your server's public IP for NAT traversal
LISTEN_ADDR=YOUR_PUBLIC_IP
# Control socket - UDP socket for SIP proxy communication
# Use udp:127.0.0.1:7722 for Kamailio/OpenSIPS on the same host
# Use unix:/var/run/rtpproxy.sock for UNIX socket (lower latency)
CONTROL_SOCKET=udp:127.0.0.1:7722
# RTP port range - each concurrent call uses 4 ports (RTP+RTCP per leg)
# 30000 ports supports ~7500 concurrent calls
MIN_PORT=35000
MAX_PORT=65000
# Inactivity timeout in seconds - drop idle sessions
TIMEOUT=60
# Log level: DBUG, INFO, WARN, ERR, CRIT
LOG_LEVEL=INFO
# Additional flags
# -F = no root warning, -t 184 = EF DSCP marking for QoS
EXTRA_OPTS=-F -t 184
Step 4: Create a Systemd Service for RTPProxy
RTPProxy does not ship with a systemd unit file when built from source, so we create one. This ensures RTPProxy starts on boot and restarts on failure.
sudo vi /etc/systemd/system/rtpproxy.service
Add the following service definition:
[Unit]
Description=RTPProxy media relay
After=network.target
Documentation=https://www.rtpproxy.org/
[Service]
Type=simple
EnvironmentFile=/etc/default/rtpproxy
ExecStart=/usr/local/bin/rtpproxy -f \
-l $LISTEN_ADDR \
-s $CONTROL_SOCKET \
-m $MIN_PORT -M $MAX_PORT \
-T $TIMEOUT \
-d $LOG_LEVEL \
-u rtpproxy \
$EXTRA_OPTS
Restart=on-failure
RestartSec=5
LimitNOFILE=65536
[Install]
WantedBy=multi-user.target
Reload systemd, enable the service to start at boot, and start it:
sudo systemctl daemon-reload
sudo systemctl enable --now rtpproxy
Check the service status to confirm RTPProxy is running:
sudo systemctl status rtpproxy
The output should show the service as active and running:
● rtpproxy.service - RTPProxy media relay
Loaded: loaded (/etc/systemd/system/rtpproxy.service; enabled; preset: enabled)
Active: active (running) since Sun 2026-03-22 10:30:00 UTC
Main PID: 12345 (rtpproxy)
CGroup: /system.slice/rtpproxy.service
└─12345 /usr/local/bin/rtpproxy -f -l 203.0.113.10 -s udp:127.0.0.1:7722 ...
Step 5: Integrate RTPProxy with Kamailio
Kamailio has a native rtpproxy module that communicates with the RTPProxy control socket to manage media sessions. If you already have Kamailio installed, add the RTPProxy module to your configuration.
Open your Kamailio configuration file:
sudo vi /etc/kamailio/kamailio.cfg
Load the rtpproxy module and set the control socket to match what you configured in /etc/default/rtpproxy:
# Load RTPProxy module
loadmodule "rtpproxy.so"
# Point to the RTPProxy control socket
modparam("rtpproxy", "rtpproxy_sock", "udp:127.0.0.1:7722")
In your routing logic, call rtpproxy_manage() to handle SDP rewriting for both the initial INVITE and subsequent replies. This single function handles offer, answer, and session teardown automatically:
route[RELAY] {
# Enable RTP relay for calls with SDP
if (is_method("INVITE") && has_body("application/sdp")) {
rtpproxy_manage("co");
}
t_on_reply("MANAGE_REPLY");
t_relay();
}
onreply_route[MANAGE_REPLY] {
if (has_body("application/sdp")) {
rtpproxy_manage("co");
}
}
# Clean up RTPProxy session on BYE
route[HANDLE_BYE] {
if (is_method("BYE")) {
rtpproxy_destroy();
}
}
The "co" flags passed to rtpproxy_manage() mean: c – create a new session if one does not exist, o – use the original direction of the SDP offer. After modifying the configuration, restart Kamailio:
sudo systemctl restart kamailio
You can check that Kamailio connects to RTPProxy by looking at the Kamailio rtpproxy module logs:
journalctl -u kamailio --no-pager | grep -i rtpproxy
Step 6: Integrate RTPProxy with OpenSIPS
OpenSIPS also ships with an rtpproxy module. The integration follows a similar pattern – load the module, configure the control socket, and call media relay functions in your routing logic.
Open the OpenSIPS configuration:
sudo vi /etc/opensips/opensips.cfg
Load the rtpproxy module and configure the socket:
# Load RTPProxy module
loadmodule "rtpproxy.so"
# Control socket matching /etc/default/rtpproxy
modparam("rtpproxy", "rtpproxy_sock", "udp:127.0.0.1:7722")
Add RTP relay handling to your routing logic. OpenSIPS provides rtpproxy_engage() which manages the full dialog lifecycle automatically – it handles the offer on INVITE, the answer on 200 OK, and teardown on BYE:
route {
if (is_method("INVITE") && has_body("application/sdp")) {
# Engage RTPProxy for the entire dialog
rtpproxy_engage();
}
# Route the request
t_relay();
}
onreply_route {
if (has_body("application/sdp")) {
rtpproxy_answer();
}
}
# Unforce on BYE to release RTP ports
route[handle_bye] {
if (is_method("BYE")) {
rtpproxy_unforce();
}
}
Restart OpenSIPS and verify the connection:
sudo systemctl restart opensips
journalctl -u opensips --no-pager | grep -i rtpproxy
Step 7: Configure Firewall for RTP Port Range
RTPProxy needs the full RTP port range open on UDP. Each active call leg uses two ports (one for RTP audio, one for RTCP control), so a single bridged call consumes four ports total. The default range of 35000-65000 supports thousands of concurrent calls.
On Ubuntu 24.04 with UFW:
sudo ufw allow 35000:65000/udp comment "RTPProxy RTP media"
sudo ufw reload
sudo ufw status | grep 35000
On Rocky Linux 10 with firewalld:
sudo firewall-cmd --permanent --add-port=35000-65000/udp
sudo firewall-cmd --reload
sudo firewall-cmd --list-ports
The firewall output should include 35000-65000/udp in the listed ports. If your SIP proxy runs on a separate host, also open the RTPProxy control socket port:
# Only needed if SIP proxy is on a different server
sudo firewall-cmd --permanent --add-port=7722/udp
sudo firewall-cmd --reload
Step 8: Verify RTPProxy Media Relay
Test that RTPProxy responds to control commands from the SIP proxy. The control protocol uses a simple text-based format over the configured socket. Use echo and nc (netcat) to query the RTPProxy version through the UDP control socket:
echo -n "V" | nc -u -w 1 127.0.0.1 7722
RTPProxy should respond with its version string, confirming the control socket is active:
20250316
Check that RTPProxy is listening on the expected ports. The process should have the RTP port range available:
ss -ulnp | grep rtpproxy
To verify end-to-end media relay during a live call, use SIPp to generate test calls through your SIP proxy. While a test call is active, confirm RTPProxy has allocated ports:
ss -ulnp | grep rtpproxy | head -20
You should see multiple UDP sockets bound in the 35000-65000 range, each pair representing one call leg. Monitor RTPProxy logs for session activity:
journalctl -u rtpproxy -f
Healthy log output shows session creation and teardown messages as calls connect and disconnect through the proxy.
Conclusion
RTPProxy is now installed, running as a systemd service, and ready to relay RTP media for your SIP infrastructure on Ubuntu 24.04 or Rocky Linux 10. The integration with Kamailio or OpenSIPS gives your VoIP platform reliable NAT traversal and media anchoring for endpoints behind firewalls.
For production deployments, consider running multiple RTPProxy instances behind a load-balanced set for high availability, enabling call recording with the -r flag for compliance requirements, and monitoring port utilization to size your RTP range appropriately for peak concurrent call volume.