TRY THIS SIP URI Calling

Discussion in 'Open Discussion' started by kdthomas, Feb 7, 2019.

  1. kdthomas

    kdthomas Member

    Joined:
    May 13, 2016
    Messages:
    55
    Likes Received:
    10
    So I'm running latest Incredible PBX and I could have sworn I was able to do this in the past in previous versions of PBXIAF/Incredible. I'm trying to call SIP addresses like
    [email protected] or [email protected]. I use X-Lite as my softphone, but I'm getting failures on any SIP address I try calling. I've tried adding "sip:" but the same result. I don't care about recieving SIP URI calls, just to be able to call them. Is this possible?
     
  2. wardmundy

    wardmundy Nerd Uno

    Joined:
    Oct 12, 2007
    Messages:
    14,507
    Likes Received:
    2,471
    @kdthomas: It's possible, but it's a two-step process. With FreePBX, you have to have a matching outbound route, or it has to be an internal call. So you have to set up custom extensions either in the GUI or you can add lines to extensions_custom.conf in the [from-internal-custom] context like this:
    Code:
    exten => 1415,1,Dial(SIP/[email protected])
    Then you dial the internal extension number (1415) from your softphone.
     
    #2 wardmundy, Feb 8, 2019
    Last edited: Feb 8, 2019
  3. wardmundy

    wardmundy Nerd Uno

    Joined:
    Oct 12, 2007
    Messages:
    14,507
    Likes Received:
    2,471
    @kdthomas: Here's a workaround that we developed based upon these tips. Just add this code to the end of extensions_custom.conf and reload Asterisk dialplan.

    NOTE: Don't use the SIP: prefix with any SIP URI call. For SIP URIs starting with a letter of the alphabet, you can dial them as is without the SIP: prefix. For SIP URIs starting with a number, prefix them with an asterisk (*) and don't use the SIP: prefix. All regular calls (all numbers) will be processed using usual dialplan rules and outbound routes.

    UPDATE: This design has been superseded by the approach documented in the new Nerd Vittles article.

    For example, if you dial [email protected], only the numeric portion of the SIP URI will be used, and it will be processed using your standard outbound routes. If you dial *[email protected], the * will be stripped off and the remaining dial string will be processed as a SIP URI outbound call. [email protected] will be processed as a SIP URI call, and 18005551212 will be processed using your existing outbound routing rules.

    Code:
    [ext-local-custom]
    exten => _[a-z].,1,Macro(uridial,${EXTEN}@${SIPDOMAIN})
    exten => _[A-Z].,1,Macro(uridial,${EXTEN}@${SIPDOMAIN})
    exten => _*X.,1,Macro(uridial,${EXTEN:1}@${SIPDOMAIN})
    
    [macro-uridial];; Cut out the “;user=phone….” bits at the end of SIP URI that some clients add
    ;; requires SRVLOOKUP=yes setting in your SIP configuration which is Incredible PBX default
    exten => s,1,Set(dialuri=${CUT(ARG1,\;,1)})
    ;; corrrect outgoing caller ID from DB name:
    exten => s,n,ExecIf($["${DB(${CALLERID(number)}/user_sipname)}" != ""],Set,CALLERID(number)=${DB(${CALLERID(number)}/user_sipname)})
    exten => s,n,NoOp(Calling SIP URI ${dialuri})
    exten => s,n,NoOp(— From: ${CALLERID(all)} —)
    exten => s,n,Dial(SIP/${dialuri},120,tr)
    exten => s,n,Congestion()
    exten => s,n,Return
    You can set the outbound CallerID for your SIP URI calls from an extension (701 in example) like this using the Asterisk CLI:
    Code:
    database put 701 user_sipname "Nerd Uno"
     
    #3 wardmundy, Feb 8, 2019
    Last edited: Feb 11, 2019
    chris_c_ likes this.
  4. wardmundy

    wardmundy Nerd Uno

    Joined:
    Oct 12, 2007
    Messages:
    14,507
    Likes Received:
    2,471
    New version coming Monday to Nerd Vittles. No dial prefix required for SIP URI calling any longer.
     
    chris_c_ likes this.
  5. chris_c_

    chris_c_ Active Member

    Joined:
    Aug 19, 2010
    Messages:
    509
    Likes Received:
    67
    Pretty soon, everyone will have a thing that looks like an email address ("SIP address"?) as their SIP direct "number".
    SIP address could even be exactly the same as your email address.
    [email protected] to call him on his cisco voip desk phone or smartphone sip app.
    [email protected] to ring him on his google duo app or google hangouts app - google would need to build this bridge from sip into their services, maybe they will maybe they won't.
     
  6. wardmundy

    wardmundy Nerd Uno

    Joined:
    Oct 12, 2007
    Messages:
    14,507
    Likes Received:
    2,471
    If Google doesn't, somebody else will. :santa:
     
    chris_c_ likes this.
  7. wardmundy

    wardmundy Nerd Uno

    Joined:
    Oct 12, 2007
    Messages:
    14,507
    Likes Received:
    2,471
  8. wardmundy

    wardmundy Nerd Uno

    Joined:
    Oct 12, 2007
    Messages:
    14,507
    Likes Received:
    2,471
    SECURITY ALERT: Never use the SIP URI MOD on a server with a publicly-exposed SIP port as it is possible for some nefarious individual to spoof your FQDN in the headers of a SIP packet and easily gain outbound calling access using your server’s trunk credentials.
     
  9. billsimon

    billsimon Experienced in Asterisk, FreePBX, and SIP

    Joined:
    Jan 2, 2011
    Messages:
    902
    Likes Received:
    273
    Yeah, don't put that dialplan in the ext-local-custom context. Put it in a context that is only exposed to authenticated users (from-internal or one of its includes).
     
    wardmundy likes this.