Capture Media IP In CDR

Home » Asterisk Users » Capture Media IP In CDR
Asterisk Users 7 Comments

I am not proxying the media, but never the less I am forced to store the source media IP in my CDR, for regulatory reasons. Asterisk gets that information when the reinvite comes, but how do I store it?
If I don’t figure this out my next email will be from Federal Prison. Kindly help me stay away from those guys. Eventually we all need to save that information or we shall not be able to stay in business.

7 thoughts on - Capture Media IP In CDR

  • You can add custom fields to your CDR records using Set(CDR(customfieldname)=foobar). I don’t know the name of the variable you want that specifically contains the source media IP, but I imagine you can pull it with the SIP_HEADER function, or possibly the CHANNEL(recvip)

  • hi, you have not mentioned which cdr backend you are using. peer ip is saved in variable CHANNEL(peerip). if you are using mysql for cdr backend you can create a field in cdr table
    (field name can b any of your choice)
    in dialplan assign the value of CHANNEL(peerip) to you ip field and asterisk will fill ip field. if you name ip feild “Peer_ip” you can use this example.


  • The CHANNEL() function has no idea about the media IP, and also SIP_HEADER(), since the media IP is not known until the call has been established and a reinvite has been received and dispatched. I am using of course, directmedia=yes and directrtpsetup=yes. Hence my question to the group.

  • That information isn’t available via a dialplan function or application;
    about the only place it is communicated is in some log messages when SIP
    debugging is enabled.

    I’m rather surprised at this requirement – when you say that your next e-mail will be from “Federal Prison”, I’m going to go out on a limb and assume that you’re referring to the United States government. Given that Asterisk is widely deployed in the U.S. and recording of remote and/or local media addresses have never been a requirement for CDRs – ever – I
    have to wonder, what is prompting this request?


  • Federal Prision v.s. hiring an Asterisk Programmer to write a patch to suit your needs. I think the choice is clear.

  • Right now,there is no way know to capture the Media IP. The channel variable does not know about it. It requires adding anew variable to CHANNEL(), and also it entails to force every channel to update that variable. New channels like PJSIP do not even update the known variables like CHANNEL(recvip). So this is not trivial and in my opinion, only Digium may do this. Also, please remember that this IP
    can change dynamically along the way, via re-invites. More than once?
    Don’t now the answer. If that is the case, then let’s create a large variable and keep adding to it via concatenation and a field separator. I am not an officer, but I can see clearly when this patch will save maybe hundreds of lives. A crucial call will come and if we know where it came from, somebody is going to walk back home safe.

  • 2013-10-14 20:05, CDR skrev:

    I’ve seen serval suggestions for you on the list. I suggest you go back and read them again.

    Gareth Blades even handed you a solution to get sip-traces with all the signaling. That’s a good solution. (I think I will use that myself for some cases – like integrated debuging in web-gui, thanks!) The sip callid doesn’t change and you can filter the pcap for this.

    Otherwise you have more full-fledged solutions like, or kamilio with Homer. More complex but also more capable.