7 thoughts on - Dynamically Setting From Domain When Calling Friends

  • I’m a little confused about what you want to do, however I’ll throw some information at you in hopes that it will help out.

    I did a little research and found that you can set the outbound From header domain and From header user through two channel variables:
    SIPFROMDOMAIN, SIPFROMUSER

    They are sparsely documented, but there is an example in extensions.conf

    same => n(from),Set(__SIPFROMUSER=${CALLERID(num)})
    same => n,GotoIf($[“${GLOBAL(FREENUMDOMAIN)}” = “”]?dial)
    ; check if we set the FREENUMDOMAIN global variable in [global]
    same => n,Set(__SIPFROMDOMAIN=${GLOBAL(FREENUMDOMAIN)})
    ; if we did set it, then we’ll use it for our outbound dialing domain

    It looks like they were added in 1.6.2.X of Asterisk, so if you are using 1.8.X or above, you should have them.

    On your inbound call, you could use the function SIP_HEADER[1] to gather the domain and store it for later use when you want to set it on the outbound call. Though I’m not sure how you could tell that the call was a redial.

    [1]: https://wiki.asterisk.org/wiki/display/AST/Asterisk+11+Function_SIP_HEADER

    I’m assuming when your SIP client redials that it calls through Asterisk and is not dialing the previously caller directly.

    Hope any of that helps. *Goes off to document SIPFROMDOMAIN and SIPFROMUSER on the wiki*


    Rusty Newton Digium, Inc. | Community Support Manager
    445 Jan Davis Drive NW – Huntsville, AL 35806 – US
    direct: +1 256 428 6200

    Check us out at: http://digium.com & http://asterisk.org

  • Thank you very much. I will try this! It seems to be what I’m looking for. I’m in most cases working with 1.2 asterisks, so I’m not up to date on newer features. My current project however needed a newer version. I tried some googleing, but I did not find these variables.

    Thanks, Torbjörn Abrahamsson

    —–Original Message—–
    From: asterisk-users-bounces@lists.digium.com [mailto:asterisk-users-bounces@lists.digium.com] —
    Rusty Newton Digium, Inc. | Community Support Manager
    445 Jan Davis Drive NW – Huntsville, AL 35806 – US
    direct: +1 256 428 6200

    Check us out at: http://digium.com & http://asterisk.org

  • Glad to help! Wow.. 1.2 ! Most are using 1.8 or 11 these days, so it is good to be aware of that when seeking help and Googeling. The 1.8
    branch is the oldest supported version at the moment. https://wiki.asterisk.org/wiki/display/AST/Asterisk+Versions


    Rusty Newton Digium, Inc. | Community Support Manager
    445 Jan Davis Drive NW – Huntsville, AL 35806 – US
    direct: +1 256 428 6200

    Check us out at: http://digium.com & http://asterisk.org

  • Yes, I know, way behind. We are trying to make the time needed to move on to 11 or 12, but it is quite time consuming. Although we’re not alone, at least Steve Edwards uses 1.2.. 🙂

    I tested SIPFROMDOMAIN, and it worked. Important thing to note is that I needed to have at least one underscore at the beginning of the variable, as your example did, it needs to be inherited at least one level. I don’t really see way this should be needed, shouldn’t Dial be able see it in the channel that executes the application? Maybe this should be noted on the wiki as well, to avoid this kind of confusion?

    Thanks for the help!

    BR, Torbjörn Abrahamsson

  • Glad to hear it worked for you!

    Information on variable inheritance is already on the wiki.

    Here https://wiki.asterisk.org/wiki/display/AST/Variable+Inheritance+Basics

    and here https://wiki.asterisk.org/wiki/display/AST/Variable+Inheritance

    Those two pages and their sub-pages have some overlap and may need to be consolidated.


    Rusty Newton Digium, Inc. | Community Support Manager
    445 Jan Davis Drive NW – Huntsville, AL 35806 – US
    direct: +1 256 428 6200

    Check us out at: http://digium.com & http://asterisk.org

  • I was not referring to the concept of inheritance, rather than that I found it odd that I would need the inheritance in this specific case. My gut feeling told me that the Dial application should see the SIPFROMDOMAIN variable without having to resort to inheritance. This seems the logical way to me, although I have no trouble grasping that there may be magic under the hood that makes this operation need the inheritance. My comment about the wiki was about stating on the SIP CHANNEL VARIABLES page that you need to have the inheritance, otherwise it will not work. If I hadn’t seen your example in the mail, I would not have thought “Oh, I need to make this variable inheritable…”. I would have thought there was some other problem.

    Thanks again for your help!

    BR, Torbjörn Abrahamsson