I have installed kamailio 5.1.4 version in ubuntu server. I need to route RTP packets through kamailio with SIP packets. I will explain the way i have set up everything.

I have installed rtpproxy by apt-get install rtpproxy.

i have edited "/etc/default/rtpproxy" file with the line 'EXTRA_OPTS="-F -s udp:127.0.0.1:7722 -l  34.201.122.249   -d DBUG:LOG_LOCAL0"'

i have edited "/etc/init.d/rtpproxy" file as follows,
DAEMON=/usr/bin/$NAME
PIDFILE="/run/$NAME/$NAME.pid


I have provided "#!define WITH_NAT" and "modparam("rtpproxy", "rtpproxy_sock", "udp:127.0.0.1:7722")" in my cfg file.

started rtpproxy "service rtpproxy start"

when i try "netstat -tulpn | grep rtp" it shows 
udp        0      0 127.0.0.1:7722          0.0.0.0:*                           1437/rtpproxy


So i think the rtpproxy is currently running fine.


Now we can go to kamailio part.  

I have gone through the document "https://www.kamailio.org/docs/modules/5.0.x/modules/rtpproxy.html" to set up rtpproxy in the cfg file.

checking the rtp ports "kamcmd rtpproxy.list" showing
{
        setid: 0
        url: udp:127.0.0.1:7722
        index: 0
        disabled: 0
        weight: 1
        recheck: 0
}





I have enabled rtp proxy using "kamcmd rtpproxy.enable udp:127.0.0.1:7722     1".

So i think ports are ready for rtp proxy.

Now i will explain the call flow. I have enabled log using L_BUG.

when i try a call from hangout number through my twilio trunk to my asterisk freepbx extension, 
set_rtp_proxy_set("1"); giving true value. But  rtpproxy_offer(); giving -1 as result. syslog shows some errors like below,
Aug 13 10:28:57 ip-172-30-0-10 rtpproxy[1437]: DBUG:handle_command: received command "1934_4 Uc0,8,3,111,9,101 52001b5b71435b1c5392b39f2f6c975b@asterisk_ip:5060 asterisk_ip 14540 as4083c85f;1"
Aug 13 10:28:57 ip-172-30-0-10 rtpproxy[1437]: INFO:handle_command: new session 52001b5b71435b1c5392b39f2f6c975b@asterisk_ip:5060, tag as4083c85f;1 requested, type strong
Aug 13 10:28:57 ip-172-30-0-10 rtpproxy[1437]: ERR:create_twinlistener: can't bind to the IPv4 port 47926: Cannot assign requested address
Aug 13 10:28:57 ip-172-30-0-10 rtpproxy[1437]: ERR:handle_command: can't create listener
Aug 13 10:28:57 ip-172-30-0-10 rtpproxy[1437]: DBUG:doreply: sending reply "1934_4 E10#012"

 And also my header is not changed. As a result actuall rtp is going end to end between asterisk and twilio not through kamailio. Please help me with the details.