Routing between trunks

Hi there

I hope someone can help me out on this one.
I have configured 2 trunks on my Asterisk box.

One for my provider, and one for my Lync.

Provider <-> Asterisk <-> Lync <-> Extension

Both are online, and i can make calls out, if i connect an extension directly to the asterisk box.

i can ring in, and i have managed to route calls in on my provider trunk to my lync trunk.

But here is the problem - when i try to call OUT it does not route to my provider.

This is what i have tried to do:

This works.
[from-trunk]
exten => _.,1,Noop(External Call coming in from PROVIDER!)
exten => _.,n,Set(pseudodid=${SIP_HEADER(To)})
exten => _.,n,Set(pseudodid=${CUT(pseudodid,@,1)})
exten => _.,n,Set(pseudodid=${CUT(pseudodid,:,2)})
exten => _.,n,Set(LYNC_Client=+45${pseudodid:1})
exten => _.,n,Set(LYNC_Client=+45${pseudodid})
;exten => _.,n,Answer
exten => _.,n,Dial(SIP/${LYNC_Client}@Connect-with-LYNC,tr)

This does not work.
[from-Lync]
exten => _0.,1,Set(numDialled=${EXTEN})
exten => _0.,n,Set(REALCALLERIDNUM=${CALLERID(number)})
exten => _0.,n(start),NoOp(REALCALLERIDNUM is ${REALCALLERIDNUM})
exten => _0.,n,Set(USEROUTCID=${CALLERID(number)})
exten => _0.,n,Set(CALLERID(number)=0${USEROUTCID:3})
exten => 0.,n,Set(TRUNKOUTCID=${OUTCID${ARG1}})
;exten => _0.,n,Answer
exten => _0.,n,Dial(SIP/${numDialled}@GlobalConnect,tr)

i don’t know if i am on to something in the right direction, but hi really hope so :smile:

/Morten

You need to explain why you are taking the To header to pieces, rather than using ${EXTEN}.

You should note that _. is dangerous, because it also matches h, s, e, i, etc.

You need to provide verbose CLI traces to show what is actually happening to the calls.

I found it in a guide on the net :smile:

thats all.

This is from the debug when i place a call.

pbx*CLI>
<— SIP read from TCP://195.190.31.76:50828 —>
INVITE sip:+4543331155@195.190.31.75;user=phone SIP/2.0
FROM: "Morten Linder"sip:+4578770779@lync01.rpdom.rackpeople.local;user=phone;epid=6D98DAA754;tag=f04c96d55c
TO: sip:+4543331155@195.190.31.75;user=phone
CSEQ: 2030 INVITE
CALL-ID: 7e550aae-31d5-4978-b20e-0706dbdfaf5d
MAX-FORWARDS: 70
VIA: SIP/2.0/TCP 195.190.31.76:50828;branch=z9hG4bK2a6ba5
CONTACT: sip:lync01.rpdom.rackpeople.local:5068;transport=Tcp;maddr=195.190.31.76;ms-opaque=1153c5da3477af33
CONTENT-LENGTH: 342
SUPPORTED: 100rel
USER-AGENT: RTCC/4.0.0.0 MediationServer
CONTENT-TYPE: application/sdp
ALLOW: ACK
Allow: CANCEL,BYE,INVITE,PRACK,UPDATE

v=0
o=- 66 1 IN IP4 195.190.31.76
s=session
c=IN IP4 195.190.31.76
b=CT:1000
t=0 0
m=audio 52312 RTP/AVP 97 101 13 0 8
c=IN IP4 195.190.31.76
a=rtcp:52313
a=label:Audio
a=sendrecv
a=rtpmap:97 RED/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=rtpmap:13 CN/8000
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=ptime:20

<------------->
— (14 headers 18 lines) —
== Using SIP RTP TOS bits 184
== Using SIP RTP CoS mark 5
== Using SIP VRTP TOS bits 136
== Using SIP VRTP CoS mark 6
Sending to 195.190.31.76 : 50828 (no NAT)
Using INVITE request as basis request - 7e550aae-31d5-4978-b20e-0706dbdfaf5d
No user ‘+4578770779’ in SIP users list
Found peer ‘from-LYNC’ for ‘+4578770779’ from 195.190.31.76:50828
Found RTP audio format 97
Found RTP audio format 101
Found RTP audio format 13
Found RTP audio format 0
Found RTP audio format 8
Found unknown media description format RED for ID 97
Found audio description format telephone-event for ID 101
Found audio description format CN for ID 13
Found audio description format PCMU for ID 0
Found audio description format PCMA for ID 8
Capabilities: us - 0x28000c (ulaw|alaw|h263|h264), peer - audio=0xc (ulaw|alaw)/video=0x0 (nothing)/text=0x0 (nothing), combined - 0xc (ulaw|alaw)
Non-codec capabilities (dtmf): us - 0x1 (telephone-event), peer - 0x3 (telephone-event|CN), combined - 0x1 (telephone-event)
Peer audio RTP is at port 195.190.31.76:52312
Peer doesn’t provide video
Looking for +4543331155 in from-Lync (domain 195.190.31.75)
pbx*CLI>
<— Reliably Transmitting (no NAT) to 195.190.31.76:50828 —>
SIP/2.0 404 Not Found
Via: SIP/2.0/TCP 195.190.31.76:50828;branch=z9hG4bK2a6ba5;received=195.190.31.76
From: "Morten Linder"sip:+4578770779@lync01.rpdom.rackpeople.local;user=phone;epid=6D98DAA754;tag=f04c96d55c
To: sip:+4543331155@195.190.31.75;user=phone;tag=as3b2b7f6f
Call-ID: 7e550aae-31d5-4978-b20e-0706dbdfaf5d
CSeq: 2030 INVITE
User-Agent: Asterisk PBX 1.6.0.26-FONCORE-r78
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO
Supported: replaces, timer
Content-Length: 0

0 doesn’t match +

OFC :smile:

it’s working now :smile: