Call forwarding on SIP trunk | Original CallerID not being transmitted

Hi FreePBX users and admins!

Running FreePBX with Asterisk 13.19.1.

Enabling call forwarding on my extension 123 by *72<CF_destination_number># is being accepted by the PBX, but both internal and external calls to the extension 123 are not being forwarded.

The Asterisk CLI tells me the following:

#######################################################
[2018-04-11 15:42:27] NOTICE[20580][C-0000017b]: app_dial.c:1000 do_forward: Not accepting call completion offers from call-forward recipient Local/<CF_destination_number>@from-internal-0000036b;1
#######################################################

Google doesn’t help searching with these info.

Anyone an idea?

Thanks in advance!

Best Regards,
Sepp

The NOTICE is not an error and is most likely unrelated to your issue; see http://forums.asterisk.org/viewtopic.php?p=211609 .

When forwarding an incoming call to an external destination, displaying the original caller’s number (the default) requests your outbound trunking provider to send a caller ID that is not yours. Because such “spoofing” capability is often abused, many providers don’t allow it.

If you have a trunk that does permit sending an arbitrary caller ID, check that your settings match the provider’s specifications. Some will accept the caller ID in the From header, while others want a main or account number in From and the desired caller ID in Remote-Party-ID or P-Asserted-Identity. Also, some are fussy about the format, e.g. (in US) 212-555-1212 may need to be sent as 12125551212 or as +12125551212.

To test a simpler case, temporarily set the Outbound CID for your extension to a valid number that is not on your system, then make a call to an ANI test number such as 1 800 437 7950 (or to your mobile).

If you still have trouble, post what country you are in and which outbound trunking provider(s) you have.

Hi Stewart,

thanks a lot for your explanation.

Our provider is Vodafone and they explained that they do support the arbitrary caller ID.

They also explained, that they use the “From user” option for the CID transmission and the P-Asserted-Identity.

You have to configure your SIP header so that the fields “Contact”, “From” and “To”, respectively, meet the format [email protected], where +49 is your country code (Germany), 4321 is your area code and 998877 is the number of your SIP trunk. Or the format [email protected], where 04321 is your area code.

So, in the SIP trunk configuration of FreePBX webinterface, I filled the field “From user” and the field “Contact user” at pjsip Settings > Advanced with [email protected].

I cannot identify the “To” field mentioned by Vodafone in the FreePBX webinterface. Do you know where to find it?

On the “Advanced” tab of pjsip Settings, I also selected at “Send RPID/PAI” the option “Send P-Asserted-Identity header”. Vodafone told me that you have to assemble the PAI of the area code, the SIP trunk number and the DID. Unfortunately, in FreePBX webinterface you can only enable or disable the PAI option, but you cannot define the PAI number. BTW the notation Vodafone requires doesn’t make sense to me, because if you define also the DID, there will be sent always this hard-coded number and not the DID of the appropriate caller, or not?

Further Caller ID settings are at trunk configuration > General at Outbound CallerID. This is set to <04321998877>
The “CID Option” below is set to “Allow Any CID”.

At “Outbound Routes” > Route settings the field “Route CID” is left blank, the option “Override Extension” is set to “No”.

Finally the configuration of the extensions include at “General” Outbound CID the format 04321998877123, where 123 is my extension.
The extension’s tab “Advanced” offers the option “Send RPID” which is set to “Send P-Asserted-Identity header”.

I changed the Caller ID setting in the extension’s configuration - as you proposed to do - to a different number, which doesn’t match my correct number (04321998877123). I guess it is meant to test, if the provider transmits any CID and not only CIDs from within your SIP trunk number range.
The result is a voice saying that “all circuits are busy now”.

Your setup seems correct to me (though I may have missed something important). Don’t worry about the To header – it contains the called number and if your calls are being completed correctly (when not spoofing the caller ID), then it is set correctly.

The ‘all circuits are busy now’ message indicates that Vodafone rejected your call attempt and there were no remaining trunks specified in the Outbound Route. Possibly this is because the number was invalid. For example, 04321998877123 would not be valid because it has 13 digits (not counting the initial zero); the maximum length in Germany is 11 digits. It’s possible that they do stricter checks such as knowing the allowable number ranges based on area code or based on area code and exchange.

I suggest that you check that nothing is broken by first setting the Caller ID for the extension to its normal value and making a successful call. For example, try calling 0 69 257385876 (an iNum gateway). You should hear a “welcome to iNum” prompt, then dial 000 000 093 # and you should hear your caller ID read back to you. Next, change the Caller ID setting to e.g. your mobile number (or other working number). Try the caller ID test number again. If you hear your mobile number, set your extension Caller ID back to normal and with luck Follow Me should be working. If not, at the Asterisk command prompt type pjsip set logger on and try another (failing) test. The SIP requests and responses should appear in the Asterisk log. If you have trouble interpreting it, post the SIP trace for the failing call (masking any phone numbers, account numbers, public IP addresses or any other data that you consider personal).

Here’s the relevant data from ‘full’ log having switched pjsip logging on and conducted the test call with wrong CID set (to mobile number 01701213434).

Two points suspicious to me:

  1. Occurence of leading ‘0’ at dialed number ‘00692575632’. We do not use leading ‘0’ for external calls.

  2. Section at lines 288-297. Authentication error on INVITE. At FreePBX Webinterface > Connectivity > Trunks > edit my trunk > pjsip Settings > General > Authentication we selected option Outbound. Perhaps the cause of the problem? But why?full.tgz (4,4 KB)

According to the log, the Grandstream phone really did send the 00692575632. Did you dial it manually on the keypad? If not (it was dialed from history, contacts, speed dial, etc.) then the entry may have been corrupted by a previous problem. Please repeat the test, dialing manually and watching the display to be sure the 0 key doesn’t bounce. If it still sends the extra 0, the phone’s dial plan is probably mangling the number. Log into the device and check Call Settings for the account in question. Dial Plan Prefix should be blank and Dial Plan should not do any unwanted modifications. See http://www.grandstream.com/sites/default/files/Resources/gxp16xx_administration_guide.pdf page 36.

I suspect that the Forbidden was because Vodafone expects the From header to contain the main trunk number (essentially used as an account number). In the trunk config, try setting From User to 04321998877 (use just the digits of your actual number). If that’s what you already have, I’m quite puzzled.

If you still have trouble, first confirm that nothing has been broken (if you set the caller ID for the extension back to normal, you can call out ok). Then, go back to the failing case and post another log (same as your last post) and screenshots of your trunk settings (with personal data blanked out).

Here are the logs:

Outbound Caller ID on extension’s settings is set to a mobile number.
One log with “From User” blank, the second with “From User” set to my SIP trunk number (what Vodafone told me to insert there).

Second attachments with my SIP trunk settings.Logs.tgz (4,7 KB)
TrunkSettings.tgz (440,0 KB)

Unfortunately, the SIP trace is missing from both logs. Please try again, doing
pjsip set logger on
before making the test calls.

When From User is filled in but Oubound Caller ID for the extension is normal (not spoofing), do calls complete ok? If so, please post two logs, one for a successful call without spoofing and one for a failed call when attempting to spoof (both with From User filled in).

If filling From User causes calls to fail, even when not spoofing, then also post the log for a successful call with From User blank.

No, the call never is being established, no matter if FROM USER is filled in or blank.

Here’s the log including the SIP trace this time.

full.tgz (4,9 KB)

Finally got news from Vodafone having sent a TCPDUMP SIP trace to them:

“Configure DIVERSION HEADER or PAI HEADER or CONTACT HEADER to include your full telephone number!”

So, the DIVERSION HEADER setting (‘Generate Diversion Headers’) in FreePBX can be set to YES or NO (at Settings > Advanced Settings > Dialplan and Operational). But it cannot be defined (how ithas to bee assembled).
From the description text we learn:

KEYWORD:DIVERSIONHEADER
If this value is set to true, then calls going out your outbound routes that originate from outside your PBX and were subsequently forwarded through a call forward, ring group, follow-me or other means, will have a SIP diversion header added to the call with the original incoming DID assuming there is a DID available. This is useful with some carriers that may require this under certain circumstances.

So we should assume that FreePBX sets the diversion header only to the DID (123), not the full telephone number (04321987123). Having set the Diversion Header option to YES and made a test call, our assumption seems to be correct:

Diversion: sip:[email protected];reason=unconditional

So, how to configure FreePBX to assemble the diversion header to use the full telephone number?

The alternative, according to Vodafone: Setting the CONTACT HEADER to the full telephone number.

The TCPDUMP tells us, that currently the value of this header is:

Contact: sip:[email protected]:5060

But it should be: Contact: sip:[email protected]:5060

So, where to configure it?

The second alternative, the PAI HEADER can’t be configured either in FreePBX. You can only enable or disable it at Connectivity > Trunks > edit my trunk > pjsip Settings > Advanced > Send RPID/PAI .
Can also be enabled at Applications > Extensions > edit my extension > Advanced > Edit Extension > Send RPID .

But how to tell FreePBX how to assemble the PAI?

Aked my provider if Contact Header would be sufficient (i.e. disabling Diversion and PAI headers in the PBX) for the routing of the call.
They told me that it is sufficient.

So, the hopefully simple question is, how to configure the Contact Header individually in FreePBX?

I’m having trouble understanding your last two posts, because they only refer to one number.

There are three phone numbers involved: The number you are calling, the caller ID you wish to display and the company number.

It is clear that the number you are calling goes into the SIP URI and the To: header – there are no questions about that.

However, the Vodafone documentation doesn’t seem to show what combinations of headers are permitted for the other two numbers and what formats are allowed. For example, if the company number is in Contact: and the caller ID number is in From:, will that work? Perhaps they have examples of a valid INVITE request.

Or, can you post a link to (or a copy of) the relevant Vodafone documentation? (I can read German fairly well, if it’s not available in English.)

There is no Vodafone documentation I’m aware of.

I’m talking to their support by eMail.

They told me, that

  1. during calls being forwarded to external numbers the PBX starts a new INVITE request
  2. The DIVERSION or PAI or CONTACT header must reflect the “Anschlussbezogene Rufnummer + Nebenstelle”.
  3. The sequence of evaluation (regarding Call Forwardings) is DIVERSION, then PAI, then CONTACT (i.e. if there’s a DIVERSION header the other two headers are not being evaluated).

To make things simpler, I asked them, if it would be sufficient to have the CONTACT header reflecting the “Anschlussbezogene Rufnummer” (i.e. disabling the generation of the DIVERSION and PAI headers in the PBX).
The answer was YES.

First I disabled the DIVERSION and PAI headers. While the PAI header is not being created having disabled it in the FreePBX WebGUI, the DIVERSION header still occurs. So, how to get rid of it?

Then we have to find a way to configure the CONTACT header to be the “Anschlussbezogene Rufnummer” (+494321987123 in my case) and call forwardings should work (according to Vodafone support).

If we cannot get rid of the DIVERSION header, we have to manipulate it to reflect the “Anschlussbezogene Rufnummer”. Doesn’t seem to be possible by WebGUI. Any idea?

Regarding the attached SIP TRACE, you can see the current state of the CONTACT and DIVERSION headers:

Lines 60 & 74 | Contact: sip:192.168.128.110:5060
[IP is the FreePBX LAN IP]

Line 75 | Diversion: sip:[email protected];user=phone;reason=unconditional
[123 is the callee’s DID]

Line 84 | Contact: sip:[email protected]:5060

Line 91 | Diversion: sip:[email protected];reason=unconditional

Line 156 | Diversion: sip:[email protected];user=phone;reason=unconditional

Obviously the reason for the failing call forwarding is: 404 Forbidden / “Authentication Failed on INVITE”:

Lines 123 - 132 | 09:14:07.940916 IP Vodafone-SIP-IP.5060 > 192.168.128.110.5060: SIP: SIP/2.0 403 Forbidden
E…z.X.XO…E…1LSIP/2.0 403 Forbidden
Via: SIP/2.0/UDP 192.168.128.110:5060;received=188.111.57.198;branch=z9hG4bKPjaf30506b-7364-4329-8471-e8b68b887ab4;rport=5060
From: sip:[email protected];tag=a6412043-e40c-49a7-b15b-a78c80c195d4
To: sip:01701213434@*Vodafone-SIP-IP*;tag=SDjnaa299-13b7d323-001d-053f-0000-0000
Call-ID: fbaa7b38-3624-4f36-b632-8e30b4155e0e
CSeq: 579 INVITE
Server: SSW/0.0.0
Warning: 399 arcor.de " Authentication Failed on INVITE"
Content-Length: 0

tcpdump_SIP_Trace.tgz (1,8 KB)

I did a simple test and got different results:
Test system has a DID 1775851XXXX; Inbound Route points directly at a pjsip extension.
That extension is set Call Forwarding Unconditional to 18004377950 (an ANI test number).
Outbound Route goes to a pjsip trunk configured for Flowroute (uses IP auth similar to Vodafone).
Route Type has Emergency and Intra-Company both off.
In Advanced Settings, Generate Diversion Headers set to Yes.
In settings for trunk, Send RPID/PAI is set to No.
I call from 1775420XXXX to the 1775851XXXX DID.
Resulting INVITE:

INVITE sip:XXXXXXXX*[email protected]:5060 SIP/2.0
Via: SIP/2.0/UDP 35.187.XXX.XXX:XXXX;rport;branch=z9hG4bKPj78afcb0c-d6c8-4bc7-b050-131d3920afa4
From: <sip:[email protected]>;tag=6a4b122f-668d-4f3e-9415-253a606b5997
To: <sip:XXXXXXXX*[email protected]>
Contact: <sip:[email protected]:XXXX>
Call-ID: c9ca2bb0-27dc-43f9-9a83-27090ab73823
CSeq: 19767 INVITE
Allow: OPTIONS, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, REGISTER, MESSAGE, REFER
Supported: 100rel, timer, replaces, norefersub
Session-Expires: 1800
Min-SE: 90
Diversion: <tel:1775851XXXX>;reason=unconditional;screen=no;privacy=off
Max-Forwards: 70
User-Agent: FPBX-14.0.1.36(14.7.5)
Content-Type: application/sdp
Content-Length:   284

I don’t know whether the tel: protocol indicator would be accepted by Vodafone, but otherwise this looks like what you want. Can you please try these settings and post the INVITE that results? (I also don’t know whether Asterisk 14.7.5 on the test system makes an important difference here.)

Checked all settings:

  • Inbound route points directly at pjsip extension: OK
  • Extension set to C.F.U. to external number (tried twice, first with German mobile number, second with your ANI number, same INVITE results)
  • Outbound Route goes to a pjsip trunk: OK
  • Route type has Emergenca and Intr-Company both off: OK
  • Generate Diversion Headers is on: OK
  • RPID/PAI in trunk settings is disabled: OK

Call from 01509879879 to 04321987123
CFU number is 01701213434

Resulting INVITE:

INVITE sip:01701213434@Vodafone-SIP-IP:5060 SIP/2.0
E`.N…@.@…EXO…:…INVITE sip:01701213434@Vodafone-SIP-IP:5060 SIP/2.0
Via: SIP/2.0/UDP 192.168.128.110:5060;rport;branch=z9hG4bKPj4d6214d5-86cf-4016-8eac-6b0dad98de61
From: sip:[email protected];tag=b8659df8-64ba-40d6-89f9-8a7a931ed224
To: sip:01701213434@*Vodafone-SIP-IP*
Contact: sip:[email protected]:5060
Call-ID: 69b59ff4-cc4d-41ea-a949-c37b2cec9d43
CSeq: 18588 INVITE
Allow: OPTIONS, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, REGISTER, MESSAGE, REFER
Supported: 100rel, timer, replaces, norefersub
Session-Expires: 1800
Min-SE: 90
Diversion: sip:[email protected];reason=unconditional
Max-Forwards: 70
User-Agent: FPBX-14.0.2.14(13.19.1)
Content-Type: application/sdp
Content-Length: 337

Observations:

  • LINE 1: Flowroute trace: Leading XXXXXXXX* in value of sip prior to CFU number
  • LINE 2: LINE 2 of Vodafone trace doesn’t exist in Flowroute trace
  • LINE 2F/3V: VIA header with public IP of PBX in Flowroute trace and private LAN IP in Vodafone trace
  • LINE 3F/4V: FROM header in Flowroute displays only DID, in Vodafone trace full phone number with leading country code.
  • LINE 4F/5V: TO header in Flowroute trace with leading numbers XXXXXXXXX* prior to CFU number
  • LINE 5F/6V: Strange CONTACT header in both traces: asterisk@PBX-IP-address
  • LINE 12F/13V: DIVERSION header with <tel: > tag in Flowroute trace, but <sip: > tag in Vodafone trace. Flowroute trace shows only DID, Vodafone trace shows DID with suffix ‘@mycompany.arcor.de’. Flowroute trace has additional properties: screen and privacy.

II believe that I now understand what is going wrong. In the incoming call, Vodafone is transmitting just the extension number in their INVITE, not the complete number. I don’t know if there is any way to adjust the diversion header in the GUI. Here is an attempt at a manual fix:

In the file /etc/asterisk/extensions_override_freepbx.conf, put a modifed copy of the sub-diversion-header context. (The original is in /etc/asterisk/extensions_additional.conf; don’t modify that.) For example:

[sub-diversion-header]
exten => s,1,Set(DIVERSION_REASON=${IF($[${LEN(${DIVERSION_REASON})}=0]?no-answer:${DIVERSION_REASON})})
exten => s,n,Gosub(func-set-sipheader,s,1(Diversion,<tel:+494321987${FROM_DID}>\;reason=${DIVERSION_REASON}\;screen=$
exten => s,n,Return()

Reload Asterisk after writing or changing this file.

If this doesn’t help, confirm that the Diversion: header in the SIP trace has changed as expected.
If so but Vodafone still doesn’t accept it, try with the third line as

exten => s,n,Gosub(func-set-sipheader,s,1(Diversion,<sip:+494321987${FROM_DID}>\;reason=${DIVERSION_REASON}\;screen=$

or as

exten => s,n,Gosub(func-set-sipheader,s,1(Diversion,<sip:04321987${FROM_DID}>\;reason=${DIVERSION_REASON}\;screen=$

Edit: From your Obbservations, it seems that the sub-diversion-header context may be different or not being executed on your system. If this is the case, can you see from the Asterisk log where/how the Diversion: header is being set?

1 Like
  • Edited /etc/asterisk/extensions_override_freepbx.conf accordingly

  • Reloaded Asterisk: [root@mySIPserver asterisk]# amportal a r

  • Result of test call: no change - trace shows exactly the same as before

  • Tried also with the second and third proposal for LINE 3: same results

  • Tried also substituting the <tel: > tag with <sip: > tag in LINE 3: same results

It seems that FreePBX doesn’t care about the extensions_override_freepbx.conf file or the sub_diversion_header.

Here’s the latest Asterisk full log having conducted new test call with call forwarding being activated.

Observations:

  1. “diversion” occurs in lines 358, 387, 452-458, 515, 518, 537.
  2. sub-diversion-header seems to be responsible for addition of DIVERSION header (see lines 452-458)
  3. The REALCALLERIDNUM variable always reflects the correct number (i.e. the number of the original caller). So, apparently the system knows from the beginning to the end what number to use. See lines 123, 403, 479.

The second attachment are the lines of file extensions_additional.conf with ocurrences of ‘sub-diversion-header’.

full.tgz (7,6 KB)

extensions_additional_conf.tgz (648 Bytes)

UPDATE to the last post:

  • There were to )) lacking in the code proposals of extensions_additional.conf.
  • I guess that I used the wrong reload command. Used mySIPserver*CLI> core reload now.

The DIVERSION header consisted then of twice the full telephone number (i.e. +494321987123+494321987123).

So I deleted the leading hard coded number. the full line was then:
exten => s,n,Gosub(func-set-sipheader,s,1(Diversion,<tel:${FROM_DID}>\;reason=${DIVERSION_REASON}\;screen=$))

Result: The DIVERSION header in the test reflected the full telephone number (i.e. +494321987123).

Unfortunately, the call has been aborted like before. Same reason is being displayed:

Warning: 399 arcor.de " Authentication Failed on INVITE"

Have to try it with the two more code proposals´. Will report then (tomorrow).

UPDATE

I noticed, that removing the hard coded +494321987 from the code proposal, the line is the same as the original handler in the extensions_additional.conf file.

I removed the override code completely and made a new test.

In the Asterisk log, the correct number is being displayed (i.e. full number).
But the SIP trace continues showing only the DID (i.e. extension).

I’m sorry to hear that this problem is still unsolved. It seems that on this test you did exactly what Vodafone asked, yet they still rejected the call. You could show them this SIP trace and ask why they did not accept the call. Or, ask them to provide an example of an INVITE that will be accepted and we can try to emulate that behavior.

Another approach is to use a different trunking provider for forwarded or follow-me calls. I recommend AnveoDirect and/or Voxbeam. Neither require any special headers – put any caller ID in From and you’re good to go. Both provide a small credit at signup so you can test without making a payment or providing any financial information. Rates to DE T-Mobile are less than 0.015 €/min. If you don’t have any DIDs with them, there are no monthly charges. However, they do require your server to emulate being on a public IP. I believe that this is a simple matter of setting External Address and Local Networks in Asterisk SIP Settings and restarting Asterisk.

I have both providers on my system and could make test calls to your mobile if you would like.