DIAL(SIP/exten) sending S@ in TO: header

Hey all,

Have been using * for the last 9 years and I cannot figure this one out. Im trying to (as a favour) send some calls to my friends freepbx box. He has two DIDs which I forward to him using:

exten = 1416xxxxxx0,1,Dial(SIP/1555)
exten = 1416xxxxxx1,1,Dial(SIP/1555)

1555 is what his box registers to me with.

When Dial is executed his header is below. The part I cannot figure out is why the TO header is To: sip:s@99.xx.xx.xxx:5060 rather then DID@IP:PORT.

type is peer for 1555 (I’ve also tried friend and user). Any help is much appreciated! I can typically figure out my issues, this one I’ve been at for hours and hours!

-- Executing [1416XXXXXXX@DID_link2voip-sw2:1] Dial("SIP/ixica-0001ba44", "SIP/1555") in new stack

== Using SIP RTP CoS mark 5
Audio is at 17930
Adding codec 100003 (ulaw) to SDP
Adding codec 100002 (gsm) to SDP
Adding non-codec 0x1 (telephone-event) to SDP
Reliably Transmitting (NAT) to 99.xx.xx.xxx:5060:
INVITE sip:s@99.xx.xx.xxx:5060 SIP/2.0
Via: SIP/2.0/UDP xx.xx.xx.xxx:pppp;branch=z9hG4bK130a8b64;rport
Max-Forwards: 70
From: “ME” sip:4169XXXXXX@.xx.xx.xxx:pppp;tag=as4eacd35e
To: sip:s@99.xx.xx.xxx:5060
Contact: sip:4169XXXXXX@70.xx.xx.xxx:pppp
Call-ID: 51950eda681245692fe401e8332cac4b@70.xx.xx.xxx:pppp
CSeq: 101 INVITE
User-Agent: Asterisk PBX 11.21.2
Date: Sun, 13 Oct 2019 16:48:46 GMT
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, REGISTER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces,timer
Content-Type: application/sdp
Content-Length: 257

v=0
o=root 341229051 341229051 IN IP4 70.xx.xx.xxx
s=Asterisk PBX 11.21.2
c=IN IP4 70.25.53.111
t=0 0
m=audio 17930 RTP/AVP 0 3 101
a=rtpmap:0 PCMU/8000
a=rtpmap:3 GSM/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=ptime:20
a=sendrecv

What was in the Contact header of the incoming REGISTER?

Post the REGISTER request, as @david551 said let see what it is sending the remote BOX on the Contact header, also a workaround it is us the call back extension on the register request

Thanks for your assistance !

— (10 headers 0 lines) —
Really destroying SIP dialog ‘09c192c2305bd47a14e8766a1f667b7f@70.xx.xx.xxxx:pppp’ Method: OPTIONS

<— SIP read from UDP:99.xx.xx.xxx:5060 —>
REGISTER sip:70.xx.xx.xxx:pppp SIP/2.0
Via: SIP/2.0/UDP 99.xx.xx.xxx:5060;branch=z9hG4bK15863afb;rport
Max-Forwards: 70
From: sip:1555@70..xx.xx.xxx;tag=as6b771998
To: sip:1555@70..xx.xx.xxx
Call-ID: 192fdf7f002bca13658273f313cd7eca@[::1]
CSeq: 102 REGISTER
Supported: replaces, timer
User-Agent: FPBX-13.0.192.19(13.12.1)
Expires: 100
Contact: sip:s@99.xx.xx.xxx:5060
Content-Length: 0

<------------->
— (12 headers 0 lines) —
Sending to 99.xx.xx.xxx:5060 (NAT)
Sending to 99.xx.xx.xxx:5060 (NAT)

<— Transmitting (NAT) to 99.xx.xx.xxx:5060 —>
SIP/2.0 401 Unauthorized
Via: SIP/2.0/UDP 99.xx.xx.xxx:5060;branch=z9hG4bK15863afb;received=99.252.231.5;rport=5060
From: sip:1555@70.xx.xx.xxx;tag=as6b771998
To: sip:1555@70.xx.xx.xxx;tag=as3953e310
Call-ID: 192fdf7f002bca13658273f313cd7eca@[::1]
CSeq: 102 REGISTER
Server: Asterisk PBX 11.21.2
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, REGISTER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces,timer
WWW-Authenticate: Digest algorithm=MD5, realm=“asterisk”, nonce=“584c670b”
Content-Length: 0

<------------>
Scheduling destruction of SIP dialog ‘192fdf7f002bca13658273f313cd7eca@[::1]’ in 32000 ms (Method: REGISTER)

<— SIP read from UDP:99.xx.xx.xxx:5060 —>
REGISTER sip:70.xx.xx.xxx SIP/2.0
Via: SIP/2.0/UDP 99.xx.xx.xxx:5060;branch=z9hG4bK6beffcb2;rport
Max-Forwards: 70
From: sip:1555@70.xx.xx.xxx;tag=as6b771998
To: sip:1555@70.xx.xx.xxx
Call-ID: 192fdf7f002bca13658273f313cd7eca@[::1]
CSeq: 103 REGISTER
Supported: replaces, timer
User-Agent: FPBX-13.0.192.19(13.12.1)
Authorization: Digest username=“1555”, realm=“asterisk”, algorithm=MD5, uri=“sip:70.xx.xx.xxxx:pppp”, nonce=“584c670b”, response=“5d8b0d4765357703746a98d0b236445c”
Expires: 100
Contact: sip:s@99.xx.xx.xxx:5060
Content-Length: 0

<------------->
— (13 headers 0 lines) —
Sending to 99.xx.xx.xxx:5060 (NAT)
Reliably Transmitting (NAT) to 99.252.231.5:5060:
OPTIONS sip:s@99.xx.xx.xxx:5060 SIP/2.0
Via: SIP/2.0/UDP 70.xx.xx.xxx:pppp;branch=z9hG4bK61a1f46c;rport
Max-Forwards: 70
From: sip:asterisk@70.xx.xx.xxx:pppp;tag=as4c3bbe97
To: sip:s@99.xx.xx.xxx:5060
Contact: sip:asterisk@70.xx.xx.xxx:pppp
Call-ID: 5868ea5a15c1cac2606f7fd923bc26b0@70.xx.xx.xxx:pppp
CSeq: 101 OPTIONS
User-Agent: Asterisk PBX 11.21.2
Date: Sun, 13 Oct 2019 18:46:36 GMT
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, REGISTER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces,timer
Content-Length: 0


<— Transmitting (NAT) to 99.xx.xx.xxx:5060 —>
SIP/2.0 200 OK
Via: SIP/2.0/UDP 99.xx.xx.xxx:5060;branch=z9hG4bK6beffcb2;received=99.252.231.5;rport=5060
From: sip:1555@70.xx.xx.xxx;tag=as6b771998
To: sip:1555@70.xx.xx.xxx;tag=as3953e310
Call-ID: 192fdf7f002bca13658273f313cd7eca@[::1]
CSeq: 103 REGISTER
Server: Asterisk PBX 11.21.2
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, REGISTER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces,timer
Expires: 100
Contact: sip:s@99.xx.xx.xxx:5060;expires=100
Date: Sun, 13 Oct 2019 18:46:36 GMT
Content-Length: 0

<------------>
Scheduling destruction of SIP dialog ‘765b08087b47e178765097134789c6f0@70.xx.xx.xxx:pppp’ in 6400 ms (Method: NOTIFY)
Reliably Transmitting (NAT) to 99.xx.xx.xxx:5060:
NOTIFY sip:s@99.xx.xx.xxx:5060 SIP/2.0
Via: SIP/2.0/UDP 70.xx.xx.xxx:pppp;branch=z9hG4bK3153392b;rport
Max-Forwards: 70
From: sip:asterisk@70.xx.xx.xxx:pppp;tag=as07014421
To: sip:s@99.xx.xx.xxx:5060
Contact: sip:asterisk@70.xx.xx.xxx:3383
Call-ID: 765b08087b47e178765097134789c6f0@70.xx.xx.xxx:pppp
CSeq: 101 NOTIFY
User-Agent: Asterisk PBX 11.21.2
Event: message-summary
Content-Type: application/simple-message-summary
Content-Length: 93

Messages-Waiting: no
Message-Account: sip:1000@70.xx.xx.xxx:pppp
Voice-Message: 0/0 (0/0)


Scheduling destruction of SIP dialog ‘192fdf7f002bca13658273f313cd7eca@[::1]’ in 32000 ms (Method: REGISTER)

<— SIP read from UDP:99.xx.xx.xxx:5060 —>
SIP/2.0 200 OK
Via: SIP/2.0/UDP 70.xx.xx.xxx:pppp;branch=z9hG4bK61a1f46c;received=70.xx.xx.xxx;rport=pppp
From: sip:asterisk@70.xx.xx.xxx:pppp;tag=as4c3bbe97
To: sip:s@99.xx.xx.xxx:5060;tag=as00fc6b2e
Call-ID: 5868ea5a15c1cac2606f7fd923bc26b0@70.xx.xx.xxx:pppp
CSeq: 101 OPTIONS
Server: FPBX-13.0.192.19(13.12.1)
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces, timer
Contact: sip:99.xx.xx.xxx:5060
Accept: application/sdp
Content-Length: 0

<------------->

remote peer is specifying the s extension as the contact extension

Thanks, I see that as well - he is using Freepbx and I cannot find anything that would cause this behaviour… If you have any pointers it would be great, otherwise I may just wipe out his box and start him from scratch :slight_smile:

Using s is the normal behavour of Asterisk, and therefore FreePBX, if you don’t specify a callback extension.

Generally you would use static addresses, rather registering, for internal trunks.

Its external - Im trying to pass a DID from our wholesaler to a friends freepbx box, but he isn’t getting any TO: numbers specified in the header so he cannot determine the dnid.

I’ve checked his configs adn they are the same I would use to register to all of our wholesalers so Im not sure how they are able to re-write the DNID to me, but I can’t seem to figure out how to pass this onto him!

I’m not sure, but it is possible that the contact address is overridden if you expicitly provide dialed digits

For chan_sip you can selectively override the To header, in the dial string. From the sample configuration file:

; SIP dial strings
; ----------------------------------------------------------
; In the dialplan (extensions.conf) you can use several
; syntaxes for dialing SIP devices.
;        SIP/devicename
;        SIP/username@domain   (SIP uri)
;        SIP/username[:password[:md5secret[:authname[:transport]]]]@host[:port]
;        SIP/devicename/extension
;        SIP/devicename/extension/IPorHost
;        SIP/username@domain//IPorHost
; And to alter the To: or the From: header, you can additionally append
; the following to any of the above strings:
;        [![touser[@todomain]][![fromuser][@fromdomain]]]

I’m not sure how chan_pjsip handles this, and you didn’t say which.

Thanks, I dont have this in my sample file (and I guess my googling never lead me to see this either!). Lastly, if he has a dynamic IP can I simply leave out the @todomain?

Dial(SIP/1555!416XXXXXXX) (without the @todomain)?

That’s what the square brackets mean.

Thank you!

To: headers are now as expected, but the contact header is still S@ (not sure this matters).

On my box when I receive the call it showing calledparty@context, but on his box I still get s@context

I am using chan_sip as well

Thank you! The TO: header certainly got me closer but the calls are still being passed as s@context on the receive side even though the TO header is properly set. Im not sure if it wants this in the contact header and if so is there a way to change that as well?

In the meantime, Im extracting the TO: header info and using that so its working but I’d like to know the ‘proper’ way to send this over without any modification required on the receiving side… I must be missing something simple but cannot see the needle in the stack!

Calls are routed on the basis of the request URI, not the To header. When you register, the request URI is provided, in the Contact header, by the other side.

As suggested earlier you might be able to override this by using SIP/devicename/extension, however that would, I think, be a breach of the SIP protocol, as registration isn’t supposed to be used for “trunks”. As such, I can’t guarantee that it will work.

Thanks, was trying to avoid that as there are multiple DIDs and doing so that way will require one registration per DID.

For now it’s working but I’ll keep searching!

That is a horrible idea. The Asterisk box (FreePBX 13) is setup wrong. It’s not sending a Contact User in its registration string so the other Asterisk box (v11) is using the default ‘s’ user for the contact user when sending calls to the other Asterisk box.

The FreePBX 13 box should have its context set to from-pstn-to-header so it will take the DID from the To Header field instead of the INVITE header. That will allow you to send all the calls over the peer like you have from the example earlier SIP/peer/number

Yupp from-pstn-toheader with sending the dial string as sip/exten!did did the trick to allow for this. What I can’t find is how to properly configure the *13 box correctly.

I’ve seen a lot of discussion about it but no one seems to know why. When I have a min I’m gonna go redo the 13 box completely as I’m thinking it may be a bug somewhere - it’s the first time I’ve run into this issue!

Thanks all!

As a point of detail, the one sending the Contact header is the one that is specifying the use of “s”. The OP’s system isn’t defaulting; it is doing what it is being told to do.