Grandstream phones store the Outbound Route prepend prefix in Call History (Solved)

After several hours of SIP tracing I found an interesting interaction between FreePBX and Grandstream phones that may save someone else a lot of troubleshooting.

Environment

  • FreePBX 17 with PJSIP
  • Grandstream GXP21XX
  • Outbound Route uses Dial Patterns → Prepend to select a GSM gateway/trunk.

Example:

User dials:

123456789

Outbound Route prepends 333 for routing purposes:

333123456789

The problem

Everything works correctly during the call.

However, the Grandstream stores 333123456789 number in its outgoing call history instead of dialed 123456789

As a result, redialing from the phone history sends the already-prefixed number back to FreePBX, which may cause routing problems.

SIP Analysis

The phone initially sends the correct number without the prefix.

The first time the prefix appears is in the 183 Session Progress sent from FreePBX back to the phone.

The relevant header is:

P-Asserted-Identity: <sip:333123456789@PBX>

Interestingly, the To header still contains the original dialed number:

To: <sip:123456789@PBX>

Grandstream, with its default configuration, prefers the value from P-Asserted-Identity and stores that value in the outgoing call history.

Additional observation

If the prefix is moved from:

Outbound Route
→ Dial Patterns
→ Prepend

to

PJSIP Trunk
→ Dial Number Manipulation Rules
→ Prepend

the problem completely disappears because FreePBX no longer sends the modified number back in the 183 response.

Solution

On the Grandstream phone change:

Accounts
→ Account X
→ SIP Settings
→ Basic Settings
→ Callee ID Display

from to

After changing this setting, the phone ignores the modified identity for display purposes and uses the value from the To header instead.

Outgoing call history now correctly stores 123456789 instead of 333123456789

even when using Outbound Route → Dial Patterns → Prepend.

Hopefully this helps anyone running into the same issue.

What you are describing here is how the feature called connected line update works, in SIP.