SIP Trunking - Device Configuration

Hi Guys

Im new here and im a former freepbx user. So in freepbx i can add custom code in extensions_custom.conf and then have my incoming calls work according to my trunk provider.

They want this code in there for freepbx:

[from-trunk]
;Dialed Number routing according to SIP To: header
exten => s,1,Goto(from-trunk,${CUT(CUT(SIP_HEADER(TO),@,1),:,2):1},1)

Now in kinda lost with Vitalpbx on this step and i would appreciate some help

TIA

Hi @mcsi,

First, I recommend you use PJSIP instead of SIP because SIP is deprecated, and that’s why VitalPBX 3 uses PJSIP as the primary protocol.

About your question, on VitalPBX, you don’t need to create a custom context to obtain the DID from SIP headers. In the trunks module of VitalPBX, you have two fields, “Get DID From” and “Get CID From.”

image

Setting up the field “Get DID From” with the value “To” will make the trunk get the DID number from the SIP header “To,” which is what you are needing.

Now, the field “Get CID From” has two possible values, “From” and “Contact.” This parameter allows you to get the Caller ID information from the previous SIP headers.

In conclusion, you don’t need to alter the VitalPBX dial-plan to obtain the DID and CID information from the SIP headers.

1 Like

Hi Miguel

so my trunk provider is Ringlogix
and this is the documentation for Elastix and Freepbx:

Modify extensions_custom.conf

  1. Log into the PBX and go to the PBX tab
  2. Go to Tools
  3. From the left menu options click on Asterisk File Editor and find extensions_custom.conf
  4. Add the following text to extensions_custom.conf (depending on the Asterisk version)

Asterisk versions 1.6 or older

[from-outside-redir]
;Dialed Number routing according to SIP To: header
exten => s,1,Goto(from-trunk,${CUT(CUT(SIP_HEADER(TO),@,1),:,2):1},1)

Asterisk versions 1.8 or newer

[from-trunk]
;Dialed Number routing according to SIP To: header
exten => s,1,Goto(from-trunk,${CUT(CUT(SIP_HEADER(TO),@,1),:,2):1},1)

Asterisk versions 1.6 or older

type=peer
insecure=invite,port
dtmfmode=auto
host=sbc.ringlogix/com
context=from-outside-redir
username=ACCOUNT-ID
trustrpid=yes
sendrpid=yes
secret=SIP-PASSWORD
allow=all
canreinvite=no

Asterisk versions 1.8 or newer

type=peer
insecure=invite,port
dtmfmode=auto
host=sbc.ringlogix/com
context=from-trunk
username=ACCOUNT-ID
trustrpid=yes
sendrpid=yes
secret=SIP-PASSWORD
allow=all
canreinvite=no

  1. Add the USER Context
  2. Add the USER Details

Asterisk versions 1.6 or older

type=user
insecure=invite,port
dtmfmode=auto
host=sbc.ringlogix/com
context=from-outside-redir
allow=all

Asterisk versions 1.8 or newer

type=user
insecure=invite,port
dtmfmode=auto
host=sbc.ringlogix/com
context=from-trunk
allow=all

  1. Add the Registration String

ACCCOUNT-ID:SIP-PASSWORD@provider:5060


I do have outgoing but im lost with the incoming. I did understand the example but still doesn’t work

You can use the sngrep tool to verify what is sending your provider in the header “To.”

You can post that information here, but hiding any sensitive data.

here you go

output

In this case, the server returns the SIP code “484 Address Incomplete” because the DID doesn’t come in the invite. What you have to do is the following.

  • In the case of SIP, change your registration string from “ACCCOUNT-ID:SIP-PASSWORD@provider:5060” to "ACCCOUNT-ID:SIP-PASSWORD@provider:5060/DID_NUMBER "
  • In the case of PJSIP, you have to add the primary DID in the Contact User field.

In both cases, if you don’t want to use the DID, you can use the ACCCOUNT-ID.

Good morning

with he above advice we are getting closer.

  1. Sip and /DID at the end of the string i get an announcement of my DID number
  2. Sip and /account# i get “no route exists”

Thanks for your help

Did you set up the field “Get DID From ” with the value “To ”?

Could you please share a call trace from Asterisk CLI with the Account ID set up?

Please keep in mind that on their documentation they are asking for this value:

for the “to”

[from-trunk]
;Dialed Number routing according to SIP To: header
exten => s,1,Goto(from-trunk,${CUT(CUT(SIP_HEADER(TO),@,1),:,2):1},1)

attached in the captureCLI.txt (2.2 KB)

The code suggested by your provider comes implemented on VitalPBX already. As I told you, you just need to set up the field “Get DID From ” with the value “To .”

About the CLI file, you are attaching the wrong data. Disable the SIP debug, do the incoming call and copy the output generated in the Asterisk CLI when the call arrives at the PBX.

please remind me the command to get the output.

All the rest are done as discussed and the system announces the DID Numberget

asterisk -rvvvvvvvvvvvvvvvvvvvvvvvvvvv
sip set debug off

Do the call, copy the output generated during the call.

thanks for that

AttachedCLI.txt (10.0 KB)

The call is arriving at “Hard Anodize” tenant. You have to move to that tenant and modify the default Inbound Route to the desired destination.

You can also create a new inbound route with the DID “1320200XXXX” in case you want to handle different destinations per DID.

i have checked that part too
The inbound is there and i still get the " no route exists to the destination " but the route is there
I attach the cli output and the screenshot of the inbound

CLI.txt (5.0 KB)
in

Seems you are using different trunks or you forget to enabled the field to get the DID from the “To” headers.

In your last log, you are receiving “0204255835” as DID.

i did try both /0204255835 and /3202001710 at the end of the registration string

i only have one trunk in there and it is set to "Get DID From: To "

It seems you are mixing something. The call traced that you sent 1 hour ago seems to work as expected.

  -- Executing [0204255835@trk-5-in:1] NoOp("SIP/ringlogix-00000019", "Incoming call through: Ringlogix") in new stack
    -- Executing [0204255835@trk-5-in:2] Set("SIP/ringlogix-00000019", "__TRUNK_ID=5") in new stack
    -- Executing [0204255835@trk-5-in:3] Set("SIP/ringlogix-00000019", "CDR(trunk)=5") in new stack
    -- Executing [0204255835@trk-5-in:4] Set("SIP/ringlogix-00000019", "__DID_NUMBER=0204255835 -> DID Send by the VoIP Provider") in new stack
    -- Executing [0204255835@trk-5-in:5] Set("SIP/ringlogix-00000019", "CDR(did)=0204255835") in new stack
    -- Executing [0204255835@trk-5-in:6] Set("SIP/ringlogix-00000019", "DID=0204255835") in new stack
[2021-10-18 11:54:08] ERROR[2723][C-00000020]: res_pjsip_header_funcs.c:454 func_read_header: This function requires a PJSIP channel.
    -- Executing [0204255835@trk-5-in:7] Set("SIP/ringlogix-00000019", "DID=13202001710 --> DID After reading the Header") in new stack
    -- Executing [0204255835@trk-5-in:8] Goto("SIP/ringlogix-00000019", "default-trunk,13202001710,1") in new stack

I have made the trunk at the tenant level.

The last one an hour ago was at admin level.

If you are going to use the same trunk for all the tenants, it is better to leave it at the primary tenant level.