<?xml version='1.0'?>
<!DOCTYPE book PUBLIC "-//OASIS//DTD Docbook XML V4.1.2//EN" "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd">
<chapter id="node-1389">
<chapterinfo>
<releaseinfo>
md5-hash:9ee7465da21a16424dfb356aa55f4828
weight:-5
depth:2
</releaseinfo>
</chapterinfo>
<title>iptrtpproxy</title>
<literallayout><![CDATA[<A NAME="lbAB">&nbsp;</A>
<H2>NAME</H2>

iptrtpproxy - management tool for RTP/RTCP sessions
<A NAME="lbAC">&nbsp;</A>
<H2>SYNOPSIS</H2>

<B>iptrtpproxy -h </B>[command]

<P>
<B>iptrtpproxy info </B>[other_options] [common_options]

<P>
<B>iptrtpproxy list </B>[switchboard] [session_range] [list_verbosity] [other_options] [common_options]

<P>
<B>iptrtpproxy alloc </B>[switchboard] RTP_params [other_options] [common_options]

<P>
<B>iptrtpproxy update </B>switchboard [session_range] [other_options] [common_options]

<P>
<B>iptrtpproxy delete </B>[switchboard] [session_range] [other_options] [common_options]

<A NAME="lbAD">&nbsp;</A>
<H2>DESCRIPTION</H2>

<B>iptrtpproxy</B>

is used to set up, maintain, and inspect the RTP/RTCP sessions in netfilter
<B>RTPPROXY</B>

target. The seesions behave as proxy for RTP/RTCP packets enabling
smooth streaming for clients hidden behind NAT. The range of
dedicated ports at particular IP is called `gate'. Because we
have two clients in RTP/RTCP we must have also two gates.
Two gates are permanently connected at the `switchboard'. One or
two IP addresses may be used for connected gates. Each of RTP/RTCP clients will
send packets to gate's IP:port and receive packet from the same gate's IP:port as well.
It's called the `session'. The switchbord is responsible for routing to opposite client.
<P>
<B>ibtrtpproxy </B>

makes call to kernel and requires 
<I>CAP_NET_ADMIN,CAP_NET_RAW </I>

capabilities, i.e. it requires to execute 
as root. Capabilities may be limited by a
<B>libcap</B>

utility (
<B>sucap, execcap</B>

).
<A NAME="lbAE">&nbsp;</A>
<H2>OPTIONS</H2>

The options that are recognized by
<B>iptrtpproxy</B>

can be divided into several different groups.
<A NAME="lbAF">&nbsp;</A>
<H3>COMMANDS</H3>

These options specify the specific action to perform.  Only one of them
can be specified on the command line.
<DL COMPACT>
<DT><B>info </B>

<DD>
Get uptime, total number of switchboards and sessions and global statistics.
<DT><B>list </B>

<DD>
List switchboards and sessions, switchboards may be filtered using 
<I>switchboard</I>

parameter.
<I>Session_range</I>

may specify sessions to be listed. 
<DT><B>alloc </B>

<DD>
Allocate new session, i.e. two couples of ports will be dedicated. At least one source address
or learning timeout must be provided. Session id is returned.
<DT><B>update </B>

<DD>
Update specified session(s) at specified switchboard. Unless 
<I>session_range</I>

specified then affects all sessions having state non-expired and non-destroyed.
<DT><B>delete </B>

<DD>
Destroy specified session(s). Unless
<I>switchboard</I>

specified affects all switchboards, unless
<I>session_range</I>

specified then affects all sessions.
</DL>
<A NAME="lbAG">&nbsp;</A>
<H3>SWITCHBOARD</H3>

The switchboard is identified by gate IP:port. Unless specified
identification of both gates
<I>gate-a</I>

and 
<I>gate-b</I>

then 
<I>gate-b</I>

is equal to
<I>gate-b</I>

. If both addresses and ports are equal then 
<B>lib_RTPPROXY </B>

module will try to find correct switchboard too. It simplifies 
life slightly.
<DL COMPACT>
<DT><B>--addr-a </B><I>ip</I>

<DD>

<DT><B>--addr-b </B><I>ip</I>

<DD>
IP address of gate
<DT><B>--port-a </B><I>port</I>

<DD>

<DT><B>--port-b </B><I>port</I>

<DD>
The lowest port of dedicated port range
</DL>
<A NAME="lbAH">&nbsp;</A>
<H3>SESSION RANGE</H3>

Identifies sessions to be affected by command.
<DL COMPACT>
<DT><B>--sess-id-lo </B><I>id</I>

<DD>
Low session id, default value is 0.
<DT><B>--sess-id-hi </B><I>id</I>

<DD>
Hi session id value, unless specified 
<I>--sess-id-lo</I>

is taken as default value.
</DL>
<A NAME="lbAI">&nbsp;</A>
<H3>RTP PARAMS</H3>

Specify parameters of RTP/RTCP client. We can specify 
params of both RTP and RTCP streams separately. Default values
of RTCP are based on corresponding RTP param.
<DL COMPACT>
<DT><B>--rtp-addr-a </B><I>ip</I>

<DD>

<DT><B>--rtcp-addr-a </B><I>ip</I>

<DD>

<DT><B>--rtp-addr-b </B><I>ip</I>

<DD>

<DT><B>--rtcp-addr-b </B><I>ip</I>

<DD>
IP address of RTP/RTCP client.
<DT><B>--rtp-port-a </B><I>port</I>

<DD>

<DT><B>--rtcp-port-a </B><I>port</I>

<DD>

<DT><B>--rtp-port-b </B><I>port</I>

<DD>

<DT><B>--rtcp-port-b </B><I>port</I>

<DD>
Port of RTP/RTCP client.
<DT><B>--rtp-learning-timeout-a </B><I>msec</I>

<DD>

<DT><B>--rtp-learning-timeout-b </B><I>msec</I>

<DD>

<DT><B>--rtcp-learning-timeout-a </B><I>msec</I>

<DD>

<DT><B>--rtcp-learning-timeout-b </B><I>msec</I>

<DD>
Time how long the session will try to learn source address of RTP/RTCP packets.
<DT><B>--always-learn-a</B>

<DD>

<DT><B>--always-learn-b</B>

<DD>
The session will try to learn always source address of RTP/RTCP packets even in the case 
the address:port is known. Malicious packets may silently redirect stream.
</DL>
<A NAME="lbAJ">&nbsp;</A>
<H3>LIST VERBOSITY</H3>

<DL COMPACT>
<DT><B>--no-switchboard</B>

<DD>
Do not list switchboards. It also implies
<I>--no-session</I>

<DT><B>--no-session</B>

<DD>
Do not list sessions. 
</DL>
<A NAME="lbAK">&nbsp;</A>
<H3>OTHER OPTIONS</H3>

The following options can be specified:
<DL COMPACT>
<DT><B>--reset-global-stat</B>

<DD>
Reset global statistics
<DT><B>--reset-switchboard-stat</B>

<DD>
Reset switchboard statistics
<DT><B>--reset-packet-stat</B>

<DD>
Reset switchboard packet statistics
<DT><B>--force-switchboard-audit</B>

<DD>
Force switchboard audit, i.e. checking expirations and update statistics
</DL>
<A NAME="lbAL">&nbsp;</A>
<H3>COMMON OPTIONS</H3>

The following common options can be specified:
<DL COMPACT>
<DT><B>-v, --verbose</B>

<DD>
Verbose output.  The most of verbose output goes to stderr.
<DT><B>-V</B>

<DD>
Print version.
<DT><B>-h, --help</B>

<DD>
If 
<I>command</I>

is specified then prints help regarding the command
otherwise prints list of possible commands. Note that option may 
be specified almost at any position of command line.
</DL>
<A NAME="lbAM">&nbsp;</A>
<H2>PREREQUISITIES</H2>

<B>lib_RTPPROXY </B>

kernel module must be loaded and a switchboard defined using 
<B>iptables </B>

tool.
<P>
Examples:
<P>
# load kernel module
<BR>&nbsp;&nbsp;modprobe&nbsp;-i&nbsp;xt_RTPPROXY&nbsp;
<P>
# define switchboard
<BR>&nbsp;&nbsp;iptables&nbsp;-t&nbsp;mangle&nbsp;-N&nbsp;my_rtpproxy
<BR>&nbsp;&nbsp;iptables&nbsp;-t&nbsp;mangle&nbsp;-A&nbsp;my_rtpproxy&nbsp;-j&nbsp;RTPPROXY&nbsp;--addr-a&nbsp;1.2.3.4&nbsp;--port-a&nbsp;50000&nbsp;--max-sess&nbsp;100
<P>
# add it to a chain in PREROUTING, POSTROUTING and OUTPUT, specify matching conditions, etc.
<BR>&nbsp;&nbsp;iptables&nbsp;-t&nbsp;mangle&nbsp;-A&nbsp;PREROUTING&nbsp;-p&nbsp;udp&nbsp;-j&nbsp;my_rtpproxy
<BR>&nbsp;&nbsp;iptables&nbsp;-t&nbsp;mangle&nbsp;-A&nbsp;OUTPUT&nbsp;-p&nbsp;udp&nbsp;-j&nbsp;my_rtpproxy
<BR>&nbsp;&nbsp;iptables&nbsp;-t&nbsp;mangle&nbsp;-A&nbsp;POSTROUTING&nbsp;-p&nbsp;udp&nbsp;-j&nbsp;my_rtpproxy
<P>
# run as root  with limited set of capabilities
<BR>&nbsp;&nbsp;execcap&nbsp;'CAP_DAC_READ_SEARCH,CAP_NET_ADMIN,CAP_NET_RAW=eip'&nbsp;iptrtpproxy&nbsp;info
<P>
# run as non root user, it requires CAP_SETPCAP to provide a root capability to plain user
<BR>&nbsp;&nbsp;sucap&nbsp;my_user&nbsp;my_group&nbsp;execcap&nbsp;'CAP_DAC_READ_SEARCH,CAP_NET_ADMIN,CAP_NET_RAW=eip'&nbsp;iptrtpproxy&nbsp;info
<P>
<A NAME="lbAN">&nbsp;</A>
<H2>DIAGNOSTICS</H2>

Various error messages are printed to standard error.  The exit code
is 0 for correct functioning.  Errors which appear to be caused by
invalid or abused command line parameters cause an exit code of 2, and
other errors cause an exit code of 1.
<A NAME="lbAO">&nbsp;</A>
<H2>BUGS</H2>

Bugs?  Many. ;-)
<A NAME="lbAP">&nbsp;</A>
<H2>SEE ALSO</H2>

<B>iptables</B>(8)

<B>capabilities</B>(7)

<B>cap_from_text</B>(3)


The netfilter-rtpproxy-HOWTO details usage for RTP/RTCP proxy. The libcap FAQ capfaq-x.y.txt.
<BR>

See
<BR>

<B><A HREF="http://www.2p.cz/en/netfilter_rtp_proxy">http://www.2p.cz/en/netfilter_rtp_proxy</A></B>

<BR>

<B><A HREF="http://www.netfilter.org/">http://www.netfilter.org/</A></B>

<BR>

<B><A HREF="http://www1.us.kernel.org/linux/libs/security/linux-privs/">http://www1.us.kernel.org/linux/libs/security/linux-privs/</A></B>

]]></literallayout>
</chapter>

