Route from pstn sip trunk to internal sip trunk

Hello everyone,

I need help with freePBX setup.

I have pstn sip trunk from telco, incoming calls are received and i can see them when using "sip set debug on"
I have another sip trunk that is connected to avaya session manager. when debug is on i can see that freepbx is routing calls to avaya session manager.

What i want is to route all calls from pstn sip trunk to avaya session manager trunk. I have made Inbound route that routes all incoming traffic from pstn sip trunk to session manager trunk.
The problem i have is that when the call is routed to avaya session manager trunk To field is changed and there is no called number id only calling number id.
I need called number id so i can make apropriate rules in avaya session manager.

Verison of software is:
Asterisk 11.2.1
FreePBX 2.11.0.0beta2.6
Avaya session manager 6.3

Here is log from sip set debug on.

<— SIP read from UDP:10.0.0.2:5060 —>
INVITE sip:[email protected]:5060 SIP/2.0
Via: SIP/2.0/UDP 10.0.0.2:5060;branch=z9hG4bKrq673s0068mhulk615k0.1
To: "7155301 7155301"sip:[email protected];cscf
From: sip:[email protected];user=phone;tag=619390923-1375264232667-
Call-ID: [email protected]
CSeq: 437348974 INVITE
Max-Forwards: 27
Content-Length: 236
Contact: sip:[email protected]:5060;transport=udp
Content-Type: application/sdp
Allow: ACK, BYE, CANCEL, INFO, INVITE, OPTIONS, PRACK, REFER, NOTIFY
Accept: multipart/mixed
Accept: application/media_control+xml
Accept: application/sdp
Accept: application/x-hotsip-FileTransfer+xml
Supported: timer
P-Asserted-Identity: sip:112017088;[email protected];user=phone
Privacy: none
P-Charging-Vector: icid-value=b07d234105d76bf90ad408bb06ee57e
Min-SE: 180
Session-Expires: 1800
P-Called-Party-ID: sip:[email protected]

v=0
o=BroadWorks 90037223 1 IN IP4 10.0.0.2
s=-
c=IN IP4 10.0.0.2
t=0 0
a=sendrecv
m=audio 37218 RTP/AVP 8 18 98
a=rtpmap:8 PCMA/8000
a=rtpmap:18 G729/8000
a=fmtp:18 annexb=no
a=rtpmap:98 telephone-event/8000
a=fmtp:98 0-15
<------------->
— (22 headers 12 lines) —
Sending to 10.0.0.2:5060 (no NAT)
Using INVITE request as basis request - [email protected]
Found peer ‘tk1’ for ‘2017088’ from 10.0.0.2:5060
== Using SIP RTP TOS bits 184
== Using SIP RTP CoS mark 5
Found RTP audio format 8
Found RTP audio format 18
Found RTP audio format 98
Found audio description format PCMA for ID 8
Found audio description format G729 for ID 18
Found audio description format telephone-event for ID 98
Capabilities: us - (gsm|ulaw|alaw), peer - audio=(alaw|g729)/video=(nothing)/text=(nothing), combined - (alaw)
Non-codec capabilities (dtmf): us - 0x1 (telephone-event|), peer - 0x1 (telephone-event|), combined - 0x1 (telephone-event|)
Peer audio RTP is at port 10.0.0.2:37218
Looking for s in from-trunk-sip-tk1 (domain 10.2.4.90)
list_route: hop: sip:[email protected]:5060;transport=udp

<— Transmitting (no NAT) to 10.0.0.2:5060 —>
SIP/2.0 100 Trying
Via: SIP/2.0/UDP 10.0.0.2:5060;branch=z9hG4bKrq673s0068mhulk615k0.1;received=10.0.0.2
From: sip:[email protected];user=phone;tag=619390923-1375264232667-
To: "7155301 7155301"sip:[email protected];cscf
Call-ID: [email protected]
CSeq: 437348974 INVITE
Server: FPBX-2.11.0beta3(11.2.1)
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH
Supported: replaces, timer
Session-Expires: 1800;refresher=uas
Contact: sip:[email protected]:5060
Content-Length: 0

<------------>
– Executing [s@from-trunk-sip-tk1:1] Set(“SIP/tk1-000000c7”, “GROUP()=OUT_1”) in new stack
– Executing [s@from-trunk-sip-tk1:2] Goto(“SIP/tk1-000000c7”, “from-trunk,s,1”) in new stack
– Goto (from-trunk,s,1)
– Executing [s@from-trunk:1] ExecIf(“SIP/tk1-000000c7”, “1?Set(__FROM_DID=s)”) in new stack
– Executing [s@from-trunk:2] Gosub(“SIP/tk1-000000c7”, “app-blacklist-check,s,1()”) in new stack
– Executing [s@app-blacklist-check:1] GotoIf(“SIP/tk1-000000c7”, “0?blacklisted”) in new stack
– Executing [s@app-blacklist-check:2] Set(“SIP/tk1-000000c7”, “CALLED_BLACKLIST=1”) in new stack
– Executing [s@app-blacklist-check:3] Return(“SIP/tk1-000000c7”, “”) in new stack
– Executing [s@from-trunk:3] Set(“SIP/tk1-000000c7”, “CDR(did)=s”) in new stack
– Executing [s@from-trunk:4] ExecIf(“SIP/tk1-000000c7”, “1 ?Set(CALLERID(name)=2017088)”) in new stack
– Executing [s@from-trunk:5] Set(“SIP/tk1-000000c7”, “__CALLINGPRES_SV=allowed_not_screened”) in new stack
– Executing [s@from-trunk:6] Set(“SIP/tk1-000000c7”, “CALLERPRES()=allowed_not_screened”) in new stack
– Executing [s@from-trunk:7] Goto(“SIP/tk1-000000c7”, “ext-trunk,2,1”) in new stack
– Goto (ext-trunk,2,1)
– Executing [2@ext-trunk:1] Set(“SIP/tk1-000000c7”, “TDIAL_STRING=SIP/Avaya_SMGR”) in new stack
– Executing [2@ext-trunk:2] Set(“SIP/tk1-000000c7”, “DIAL_TRUNK=2”) in new stack
– Executing [2@ext-trunk:3] Goto(“SIP/tk1-000000c7”, “ext-trunk,tdial,1”) in new stack
– Goto (ext-trunk,tdial,1)
– Executing [tdial@ext-trunk:1] Set(“SIP/tk1-000000c7”, “OUTBOUND_GROUP=OUT_2”) in new stack
– Executing [tdial@ext-trunk:2] GotoIf(“SIP/tk1-000000c7”, “1?nomax”) in new stack
– Goto (ext-trunk,tdial,4)
– Executing [tdial@ext-trunk:4] ExecIf(“SIP/tk1-000000c7”, “1?Set(CALLERPRES()=allowed_not_screened)”) in new stack
– Executing [tdial@ext-trunk:5] Set(“SIP/tk1-000000c7”, “DIAL_NUMBER=s”) in new stack
– Executing [tdial@ext-trunk:6] GosubIf(“SIP/tk1-000000c7”, “0?sub-flp-2,s,1()”) in new stack
– Executing [tdial@ext-trunk:7] Set(“SIP/tk1-000000c7”, “OUTNUM=s”) in new stack
– Executing [tdial@ext-trunk:8] Set(“SIP/tk1-000000c7”, “DIAL_TRUNK_OPTIONS=Tt”) in new stack
– Executing [tdial@ext-trunk:9] Dial(“SIP/tk1-000000c7”, “SIP/Avaya_SMGR/s,300,Tt”) in new stack
== Using SIP RTP TOS bits 184
== Using SIP RTP CoS mark 5
Audio is at 14884
Adding codec 100004 (alaw) to SDP
Adding codec 100003 (ulaw) to SDP
Adding codec 100002 (gsm) to SDP
Adding non-codec 0x1 (telephone-event) to SDP
Reliably Transmitting (no NAT) to 10.2.18.61:5060:
INVITE sip:[email protected]:5060 SIP/2.0
Via: SIP/2.0/TCP 10.2.4.90:5060;branch=z9hG4bK7acd437b
Max-Forwards: 70
From: “2017088” sip:[email protected];tag=as1646631c
To: sip:[email protected]:5060
Contact: sip:[email protected]:5060;transport=TCP
Call-ID: [email protected]
CSeq: 102 INVITE
User-Agent: FPBX-2.11.0beta3(11.2.1)
Date: Wed, 31 Jul 2013 09:50:32 GMT
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH
Supported: replaces, timer
Content-Type: application/sdp
Content-Length: 272

v=0
o=root 34666148 34666148 IN IP4 10.2.4.90
s=Asterisk PBX 11.2.1
c=IN IP4 10.2.4.90
t=0 0
m=audio 14884 RTP/AVP 8 0 3 101
a=rtpmap:8 PCMA/8000
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


-- Called SIP/Avaya_SMGR/s

<— SIP read from TCP:10.2.18.61:5060 —>
SIP/2.0 100 Trying
Call-ID: [email protected]
CSeq: 102 INVITE
From: “2017088” sip:[email protected];tag=as1646631c
To: sip:[email protected]:5060
Via: SIP/2.0/TCP 10.2.4.90:5060;branch=z9hG4bK7acd437b
Content-Length: 0

<------------->
— (7 headers 0 lines) —

<— SIP read from TCP:10.2.18.61:5060 —>
SIP/2.0 404 Not Found (cannot determine routing domain, check SM ports)
Call-ID: [email protected]
CSeq: 102 INVITE
From: “2017088” sip:[email protected];tag=as1646631c
To: sip:[email protected]:5060;tag=24017248102429256_local.1374087054677_539644_539643
Via: SIP/2.0/TCP 10.2.4.90:5060;branch=z9hG4bK7acd437b
Record-Route: sip:[email protected];lr;transport=TCP
Av-Global-Session-ID: a420a5a0-f9c6-11e2-b88e-005056bc3f1a
Server: AVAYA-SM-6.3.2.0.632023
Contact: sip:10.2.18.63:15060;transport=tcp
Content-Length: 0

<------------->
— (11 headers 0 lines) —
Transmitting (no NAT) to 10.2.18.61:5060:
ACK sip:[email protected]:5060 SIP/2.0
Via: SIP/2.0/TCP 10.2.4.90:5060;branch=z9hG4bK7acd437b
Max-Forwards: 70
From: “2017088” sip:[email protected];tag=as1646631c
To: sip:[email protected]:5060;tag=24017248102429256_local.1374087054677_539644_539643
Contact: sip:[email protected]:5060;transport=TCP
Call-ID: [email protected]
CSeq: 102 ACK
User-Agent: FPBX-2.11.0beta3(11.2.1)
Content-Length: 0


Scheduling destruction of SIP dialog ‘[email protected]’ in 6400 ms (Method: INVITE)
== Everyone is busy/congested at this time (1:0/0/1)
– Executing [tdial@ext-trunk:10] Set(“SIP/tk1-000000c7”, “CALLERID(number)=2017088”) in new stack
– Executing [tdial@ext-trunk:11] Set(“SIP/tk1-000000c7”, “CALLERID(name)=2017088”) in new stack
– Executing [tdial@ext-trunk:12] Hangup(“SIP/tk1-000000c7”, “”) in new stack
== Spawn extension (ext-trunk, tdial, 12) exited non-zero on 'SIP/tk1-000000c7’
Scheduling destruction of SIP dialog ‘[email protected]’ in 6400 ms (Method: INVITE)

<— Reliably Transmitting (no NAT) to 10.0.0.2:5060 —>
SIP/2.0 404 Not Found
Via: SIP/2.0/UDP 10.0.0.2:5060;branch=z9hG4bKrq673s0068mhulk615k0.1;received=10.0.0.2
From: sip:[email protected];user=phone;tag=619390923-1375264232667-
To: "7155301 7155301"sip:[email protected];cscf;tag=as5554baa3
Call-ID: [email protected]
CSeq: 437348974 INVITE
Server: FPBX-2.11.0beta3(11.2.1)
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH
Supported: replaces, timer
Content-Length: 0

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

<— SIP read from UDP:10.0.0.2:5060 —>
ACK sip:[email protected]:5060 SIP/2.0
Via: SIP/2.0/UDP 10.0.0.2:5060;branch=z9hG4bKrq673s0068mhulk615k0.1
CSeq: 437348974 ACK
To: "7155301 7155301"sip:[email protected];cscf;tag=as5554baa3
From: sip:[email protected];user=phone;tag=619390923-1375264232667-
Call-ID: [email protected]
Max-Forwards: 27
Content-Length: 0

<------------->
— (8 headers 0 lines) —
Really destroying SIP dialog ‘[email protected]’ Method: INVITE
Really destroying SIP dialog ‘[email protected]’ Method: ACK

Thank you for the help.

Hi, did you solve this I have the same issue…

FreePBX is really in your way. You need to just code the dial plan in Asterisk so you can manipulate the variables the way you want them.

Hi sneme,

I didn’t solve the issue because i didn’t have time to play with settings, I will try again as soon as i have more spare time.

Best regards.