Problem with inbound sip header from trunk registration

I have a stupid problem that I’ve tied myself in knots over to such an extent that I must have missed something simple… hopefully you can spot it. I’m replacing a very old freepbx install build from the nerdvittles script on a rpi with the current freepbx build on debian.

The problem: There are two numbers provided by Voipfone. Separate registrations with different credentials. Registration looks fine. When making an incoming call the CID/DID does not appear in the invite, only the IP address is in the To section of the header. There’s nothing to match against to determine which number has been called. This is a problem.

I’ve confirmed the invite from voipfone does not include the information I expect.

Thing is, this works just fine on the old setup that uses chan_sip.

I’m assuming there’s something missing that I’m not requesting in the registration. But I’m rapidly running out of hair and can’t see what’s wrong. It doesn’t help that I can’t easily get to logs for the existing setup to see what its registration requests look like.

Here’s what I see in the registrations and an invite.

[2026-10-23 23:35:51] VERBOSE[1673] res_pjsip_logger.c: <--- Transmitting SIP request (746 bytes) to UDP:46.31.225.185:5060 --->
REGISTER sip:sip.voipfone.net SIP/2.0
Via: SIP/2.0/UDP <MY_IP_ADDRESS>:5060;rport;branch=z9hG4bKPjf82904e5-e8c3-4ea7-aeb6-355c7f4bafe7
From: <sip:<MY_USERNAME>@sip.voipfone.net>;tag=462335f6-506c-4a4f-9c21-d13d422dc00b
To: <sip:<MY_USERNAME>@sip.voipfone.net>
Call-ID: 859a585c-9634-4a41-a131-06e3623c78dd
CSeq: 59129 REGISTER
Contact: <sip:s@<MY_IP_ADDRESS>:5060;line=cecipoy>
Expires: 3600
Allow: OPTIONS, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, REGISTER, SUBSCRIBE, NOTIFY, PUBLISH, INFO, REFER, MESSAGE
Max-Forwards: 70
User-Agent: FPBX-17.0.33.2(22.11.0)
Authorization: Digest username="<MY_USERNAME>", realm="asterisk", nonce="uxhmgugg", uri="sip:sip.voipfone.net", response="fcb9162ef98e31e930dbef04f02a2fd5"
Content-Length: 0
[2026-10-23 23:35:51] VERBOSE[1680] res_pjsip_logger.c: <--- Received SIP response (479 bytes) from UDP:46.31.225.185:5060 --->
SIP/2.0 200 OK
Via: SIP/2.0/UDP <MY_IP_ADDRESS>:5060;rport;branch=z9hG4bKPjf82904e5-e8c3-4ea7-aeb6-355c7f4bafe7
From: <sip:<MY_USERNAME>@sip.voipfone.net>;tag=462335f6-506c-4a4f-9c21-d13d422dc00b
To: <sip:<MY_USERNAME>@sip.voipfone.net>
Call-ID: 859a585c-9634-4a41-a131-06e3623c78dd
CSeq: 59129 REGISTER
Contact: <sip:s@<MY_IP_ADDRESS>:5060;line=cecipoy>;expires=60
Expires: 60
Date: Fri, 23 Oct 2026 22:35:51 GMT
Min-Expires: 60
User-Agent: Voipfone
Content-Length: 0

[2026-10-23 23:39:30] VERBOSE[1680] res_pjsip_logger.c: <--- Received SIP request (869 bytes) from UDP:46.31.225.185:5060 --->
INVITE sip:s@<MY_IPADDRESS>:5060;line=cecipoy SIP/2.0
Via: SIP/2.0/UDP 46.31.225.185:5060;branch=z9hG4bK39c4a87e;rport
From: "07748193828" <sip:[email protected]>;tag=VF921053383efe6d1352bc090c2f8d
To: <sip:s@<MY_IPADDRESS>:5060;line=cecipoy>
Contact: <sip:[email protected]>
Call-ID: VF4be3fdbfd898394753b1cb3012c8c6@voipfone
CSeq: 102 INVITE
User-Agent: Voipfone Sip Network
Date: Fri, 23 Oct 2026 22:39:30 GMT
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER
Max-Forwards: 70
Content-Type: application/sdp
Content-Length: 310

For each trunk, set Contact User to the respective DID number (in the same format you will use in your Inbound Route).

Stewart!
Thank you. I knew it would be something simple. Problem solved.

Since the INVITE only carries the IP in the To, match on something else. In pjsip, set the trunk’s endpoint identifier and add a Request-URI based match, or use the Contact user from the registration. Registering with a contact_user set to your number usually makes the provider send that in the Request-URI, and the dialplan can read it as the DID. Is there a Request-URI user in the INVITE you captured?

Of course there is. It would be so syntactically invalid, otherwise, that it would fail very rapidly.