Multiple trunks & routes help needed

Hi

I’m using Freepbx 2.8.0.4 from an AsteriskNOW 1.7.1 installation, fully upgraded as of 30.11.10.

What I’m trying to achieve is the following:

There are 2 trunks with 2 DID’s - 12345 678901 and 12345 678902 (examples).
There are 8 extensions - 200-206 must ONLY use the first trunk and 207-208 must ONLY use the second trunk.

When a call comes in to trunk 1 I need extensions 200-206 to ring, and when a call comes in to trunk 2, I need extensions 207-208 to ring. I also need each set of extensions to use the correct outbound route to send the correct CLI.

I’ve set up the 2 SIP trunks and they are registered.
I’ve added the extensions and created the ring groups and time conditions required.

What I’m struggling with is the inbound & outbound routes.

I created 2 inbound routes with the DID set, first with the 12345 678901 & 12345 678902 numbers, which didn’t work. This is the CLI output:

-- Executing [s@from-trunk-sip-balm:1] Set("SIP/balm-00000159", "GROUP()=OUT_1") in new stack
-- Executing [s@from-trunk-sip-balm:2] Goto("SIP/balm-00000159", "from-trunk,s,1") in new stack
-- Goto (from-trunk,s,1)
-- Executing [s@from-trunk:1] NoOp("SIP/balm-00000159", "No DID or CID Match") in new stack
-- Executing [s@from-trunk:2] Answer("SIP/balm-00000159", "") in new stack
-- Executing [s@from-trunk:3] Wait("SIP/balm-00000159", "2") in new stack
-- Executing [s@from-trunk:4] Playback("SIP/balm-00000159", "ss-noservice") in new stack
-- <SIP/balm-00000159> Playing 'ss-noservice.slin' (language 'en_GB')

== Spawn extension (from-trunk, s, 4) exited non-zero on ‘SIP/balm-00000159’
– Executing [h@from-trunk:1] Macro(“SIP/balm-00000159”, “hangupcall,”) in new stack
– Executing [s@macro-hangupcall:1] GotoIf(“SIP/balm-00000159”, “1?skiprg”) in new stack
– Goto (macro-hangupcall,s,4)
– Executing [s@macro-hangupcall:4] GotoIf(“SIP/balm-00000159”, “1?skipblkvm”) in new stack
– Goto (macro-hangupcall,s,7)
– Executing [s@macro-hangupcall:7] GotoIf(“SIP/balm-00000159”, “1?theend”) in new stack
– Goto (macro-hangupcall,s,9)
– Executing [s@macro-hangupcall:9] Hangup(“SIP/balm-00000159”, “”) in new stack
== Spawn extension (macro-hangupcall, s, 9) exited non-zero on ‘SIP/balm-00000159’ in macro ‘hangupcall’
== Spawn extension (from-trunk, h, 1) exited non-zero on ‘SIP/balm-00000159’

I then tried setting the DID on each inbound route to the corresponding SIP account number instead of the telephone number - I read that this should work but again, same error.

In order to get incoming calls I had to create another inbound route with Any CID/Any DID.

For the outbound routes I’m stuck as to how to tell the extensions which trunk to use. I need extensions 200-206 to use trunk 1 and extensions 207-208 to use trunk 2. At the moment all extensions are using the first outbound route created (I created 2).

Is there enough information here for someone to assist me? If more information is required please let me know.

Any help would be most appreciated.

TIA

BR

Finally, a resolution!

I resolved the issue I was having by including the ‘fromuser=XXXXXXXX’ string in the Trunk peer details.

Thanks again for all your help, I hope you’ve had a great Xmas, Happy New Year to you!

:slight_smile:

BR

Take another look at your debugs.

SIP read from UDP:87.XXX.XXX.XXX:5060
SIP/2.0 403 Forbidden

You’re not sending the right credentials to the proxy. Check username/password.

Take another look at your debugs.

SIP read from UDP:87.XXX.XXX.XXX:5060
SIP/2.0 403 Forbidden

You’re not sending the right credentials to the proxy. Check username/password.

Outbound routing seems ok to me. From your output it looks like something is wrong with the trunk Test02. Try turning on sip debug ‘sip set debug on’ and analyze the sip packets to see what fails.

Hi Bill

Thanks for the speedy reply!

So just to clarify, you don’t think the fact I have 2 Outbound Routes with the same dial plans is the problem?

Here is the SIP debug output from a failed call:

<— SIP read from UDP:192.XXX.XXX.XXX:2049 —>

INVITE sip:[email protected];user=phone SIP/2.0

Via: SIP/2.0/UDP 192.XXX.XXX.XXX:2049;branch=z9hG4bK-9l04mp7qhehd;rport

From: “Test06” sip:[email protected];tag=fl0crpvpbr

To: sip:[email protected];user=phone

Call-ID: 3c791bf20e4c-23j7lfluuo6m

CSeq: 1 INVITE

Max-Forwards: 70

Contact: sip:[email protected]:2049;line=wrc75tvx;reg-id=1

X-Serialnumber: 0004132C4DA7

P-Key-Flags: keys=“3”

User-Agent: snom320/8.2.35

Accept: application/sdp

Allow: INVITE, ACK, CANCEL, BYE, REFER, OPTIONS, NOTIFY, SUBSCRIBE, PRACK, MESSAGE, INFO, UPDATE

Allow-Events: talk, hold, refer, call-info

Supported: timer, 100rel, replaces, from-change

Session-Expires: 3600;refresher=uas

Min-SE: 90

Content-Type: application/sdp

Content-Length: 479

v=0

o=root 1320890612 1320890612 IN IP4 192.XXX.XXX.XXX

s=call

c=IN IP4 192.XXX.XXX.XXX

t=0 0

m=audio 49654 RTP/AVP 0 8 9 103 3 18 4 101

a=crypto:1 AES_CM_128_HMAC_SHA1_32 inline:td61tolPLuYIH5qFCxTlj9ggg2cjlhIZ2sBLmODB

a=rtpmap:0 pcmu/8000

a=rtpmap:8 pcma/8000

a=rtpmap:9 g722/8000

a=rtpmap:103 g726-32/8000

a=rtpmap:3 gsm/8000

a=rtpmap:18 g729/8000

a=fmtp:18 annexb=no

a=rtpmap:4 g723/8000

a=rtpmap:101 telephone-event/8000

a=fmtp:101 0-16

a=ptime:20

a=sendrecv

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

— (19 headers 19 lines) —

== Using SIP RTP TOS bits 184

== Using SIP RTP CoS mark 5

Sending to 192.XXX.XXX.XXX : 2049 (NAT)

Using INVITE request as basis request - 3c791bf20e4c-23j7lfluuo6m

Found peer ‘207’ for ‘207’ from 192.XXX.XXX.XXX:2049

<— Reliably Transmitting (NAT) to 192.XXX.XXX.XXX:2049 —>

SIP/2.0 401 Unauthorized

Via: SIP/2.0/UDP 192.XXX.XXX.XXX:2049;branch=z9hG4bK-9l04mp7qhehd;received=192.XXX.XXX.XXX;rport=2049

From: “Test06” sip:[email protected];tag=fl0crpvpbr

To: sip:[email protected];user=phone;tag=as6ab4a756

Call-ID: 3c791bf20e4c-23j7lfluuo6m

CSeq: 1 INVITE

Server: Asterisk PBX 1.6.2.15

Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO

Supported: replaces, timer

WWW-Authenticate: Digest algorithm=MD5, realm=“asterisk”, nonce=“39c3dd22”

Content-Length: 0

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

Scheduling destruction of SIP dialog ‘3c791bf20e4c-23j7lfluuo6m’ in 6400 ms (Method: INVITE)

<— SIP read from UDP:192.XXX.XXX.XXX:2049 —>

ACK sip:[email protected];user=phone SIP/2.0

Via: SIP/2.0/UDP 192.XXX.XXX.XXX:2049;branch=z9hG4bK-9l04mp7qhehd;rport

From: “Test06” sip:[email protected];tag=fl0crpvpbr

To: sip:[email protected];user=phone;tag=as6ab4a756

Call-ID: 3c791bf20e4c-23j7lfluuo6m

CSeq: 1 ACK

Max-Forwards: 70

Contact: sip:[email protected]:2049;line=wrc75tvx;reg-id=1

Content-Length: 0

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

— (9 headers 0 lines) —

<— SIP read from UDP:192.XXX.XXX.XXX:2049 —>

INVITE sip:[email protected];user=phone SIP/2.0

Via: SIP/2.0/UDP 192.XXX.XXX.XXX:2049;branch=z9hG4bK-gefktzcfq6jy;rport

From: “Test06” sip:[email protected];tag=fl0crpvpbr

To: sip:[email protected];user=phone

Call-ID: 3c791bf20e4c-23j7lfluuo6m

CSeq: 2 INVITE

Max-Forwards: 70

Contact: sip:[email protected]:2049;line=wrc75tvx;reg-id=1

X-Serialnumber: 0004132C4DA7

P-Key-Flags: keys=“3”

User-Agent: snom320/8.2.35

Accept: application/sdp

Allow: INVITE, ACK, CANCEL, BYE, REFER, OPTIONS, NOTIFY, SUBSCRIBE, PRACK, MESSAGE, INFO, UPDATE

Allow-Events: talk, hold, refer, call-info

Supported: timer, 100rel, replaces, from-change

Session-Expires: 3600;refresher=uas

Min-SE: 90

Authorization: Digest username=“207”,realm=“asterisk”,nonce=“39c3dd22”,uri="sip:[email protected];user=phone",response=“59e40971ef8afc9c1d2f1c031af143be”,algorithm=MD5

Content-Type: application/sdp

Content-Length: 479

v=0

o=root 1320890612 1320890612 IN IP4 192.XXX.XXX.XXX

s=call

c=IN IP4 192.XXX.XXX.XXX

t=0 0

m=audio 49654 RTP/AVP 0 8 9 103 3 18 4 101

a=crypto:1 AES_CM_128_HMAC_SHA1_32 inline:td61tolPLuYIH5qFCxTlj9ggg2cjlhIZ2sBLmODB

a=rtpmap:0 pcmu/8000

a=rtpmap:8 pcma/8000

a=rtpmap:9 g722/8000

a=rtpmap:103 g726-32/8000

a=rtpmap:3 gsm/8000

a=rtpmap:18 g729/8000

a=fmtp:18 annexb=no

a=rtpmap:4 g723/8000

a=rtpmap:101 telephone-event/8000

a=fmtp:101 0-16

a=ptime:20

a=sendrecv

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

— (20 headers 19 lines) —

Sending to 192.XXX.XXX.XXX : 2049 (NAT)

Using INVITE request as basis request - 3c791bf20e4c-23j7lfluuo6m

Found peer ‘207’ for ‘207’ from 192.XXX.XXX.XXX:2049

Found RTP audio format 0

Found RTP audio format 8

Found RTP audio format 9

Found RTP audio format 103

Found RTP audio format 3

Found RTP audio format 18

Found RTP audio format 4

Found RTP audio format 101

Found audio description format pcmu for ID 0

Found audio description format pcma for ID 8

Found audio description format g722 for ID 9

Found audio description format g726-32 for ID 103

Found audio description format gsm for ID 3

Found audio description format g729 for ID 18

Found audio description format g723 for ID 4

Found audio description format telephone-event for ID 101

Capabilities: us - 0xe (gsm|ulaw|alaw), peer - audio=0x190f (g723|gsm|ulaw|alaw|g726|g729|g722)/video=0x0 (nothing)/text=0x0 (nothing), combined - 0xe (gsm|ulaw|alaw)

Non-codec capabilities (dtmf): us - 0x1 (telephone-event), peer - 0x1 (telephone-event), combined - 0x1 (telephone-event)

Peer audio RTP is at port 192.XXX.XXX.XXX:49654

Looking for 07XXXXXXXXX in from-internal (domain 192.XXX.XXX.XXX)

list_route: hop: sip:[email protected]:2049;line=wrc75tvx

<— Transmitting (NAT) to 192.XXX.XXX.XXX:2049 —>

SIP/2.0 100 Trying

Via: SIP/2.0/UDP 192.XXX.XXX.XXX:2049;branch=z9hG4bK-gefktzcfq6jy;received=192.XXX.XXX.XXX;rport=2049

From: “Test06” sip:[email protected];tag=fl0crpvpbr

To: sip:[email protected];user=phone

Call-ID: 3c791bf20e4c-23j7lfluuo6m

CSeq: 2 INVITE

Server: Asterisk PBX 1.6.2.15

Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO

Supported: replaces, timer

Session-Expires: 1800;refresher=uas

Contact: sip:[email protected]

Content-Length: 0

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

-- Executing [07XXXXXXXXX@from-internal:1] Macro("SIP/207-00000000", "user-callerid,SKIPTTL,") in new stack

-- Executing [s@macro-user-callerid:1] Set("SIP/207-00000000", "AMPUSER=207") in new stack

-- Executing [s@macro-user-callerid:2] GotoIf("SIP/207-00000000", "0?report") in new stack

-- Executing [s@macro-user-callerid:3] ExecIf("SIP/207-00000000", "1?Set(REALCALLERIDNUM=207)") in new stack

-- Executing [s@macro-user-callerid:4] Set("SIP/207-00000000", "AMPUSER=207") in new stack

-- Executing [s@macro-user-callerid:5] Set("SIP/207-00000000", "AMPUSERCIDNAME=Test07") in new stack

-- Executing [s@macro-user-callerid:6] GotoIf("SIP/207-00000000", "0?report") in new stack

-- Executing [s@macro-user-callerid:7] Set("SIP/207-00000000", "AMPUSERCID=207") in new stack

-- Executing [s@macro-user-callerid:8] Set("SIP/207-00000000", "CALLERID(all)="Test07" <207>") in new stack

-- Executing [s@macro-user-callerid:9] GotoIf("SIP/207-00000000", "1?continue") in new stack

-- Goto (macro-user-callerid,s,18)

-- Executing [s@macro-user-callerid:18] NoOp("SIP/207-00000000", "Using CallerID "Test07" <207>") in new stack

-- Executing [07XXXXXXXXX@from-internal:2] NoOp("SIP/207-00000000", "Calling Out Route: Route02") in new stack

-- Executing [07XXXXXXXXX@from-internal:3] Set("SIP/207-00000000", "MOHCLASS=default") in new stack

-- Executing [07XXXXXXXXX@from-internal:4] Set("SIP/207-00000000", "_NODEST=") in new stack

-- Executing [07XXXXXXXXX@from-internal:5] Macro("SIP/207-00000000", "record-enable,207,OUT,") in new stack

-- Executing [s@macro-record-enable:1] GotoIf("SIP/207-00000000", "1?check") in new stack

-- Goto (macro-record-enable,s,4)

-- Executing [s@macro-record-enable:4] ExecIf("SIP/207-00000000", "0?MacroExit()") in new stack

-- Executing [s@macro-record-enable:5] GotoIf("SIP/207-00000000", "0?Group:OUT") in new stack

-- Goto (macro-record-enable,s,15)

-- Executing [s@macro-record-enable:15] GotoIf("SIP/207-00000000", "0?IN") in new stack

-- Executing [s@macro-record-enable:16] ExecIf("SIP/207-00000000", "1?MacroExit()") in new stack

-- Executing [07XXXXXXXXX@from-internal:6] Macro("SIP/207-00000000", "dialout-trunk,2,07XXXXXXXXX,") in new stack

-- Executing [s@macro-dialout-trunk:1] Set("SIP/207-00000000", "DIAL_TRUNK=2") in new stack

-- Executing [s@macro-dialout-trunk:2] GosubIf("SIP/207-00000000", "0?sub-pincheck,s,1") in new stack

-- Executing [s@macro-dialout-trunk:3] GotoIf("SIP/207-00000000", "0?disabletrunk,1") in new stack

-- Executing [s@macro-dialout-trunk:4] Set("SIP/207-00000000", "DIAL_NUMBER=07XXXXXXXXX") in new stack

-- Executing [s@macro-dialout-trunk:5] Set("SIP/207-00000000", "DIAL_TRUNK_OPTIONS=tr") in new stack

-- Executing [s@macro-dialout-trunk:6] Set("SIP/207-00000000", "OUTBOUND_GROUP=OUT_2") in new stack

-- Executing [s@macro-dialout-trunk:7] GotoIf("SIP/207-00000000", "1?nomax") in new stack

-- Goto (macro-dialout-trunk,s,9)

-- Executing [s@macro-dialout-trunk:9] GotoIf("SIP/207-00000000", "0?skipoutcid") in new stack

-- Executing [s@macro-dialout-trunk:10] Set("SIP/207-00000000", "DIAL_TRUNK_OPTIONS=") in new stack

-- Executing [s@macro-dialout-trunk:11] Macro("SIP/207-00000000", "outbound-callerid,2") in new stack

-- Executing [s@macro-outbound-callerid:1] ExecIf("SIP/207-00000000", "0?Set(CALLERPRES()=)") in new stack

-- Executing [s@macro-outbound-callerid:2] ExecIf("SIP/207-00000000", "0?Set(REALCALLERIDNUM=207)") in new stack

-- Executing [s@macro-outbound-callerid:3] GotoIf("SIP/207-00000000", "1?normcid") in new stack

-- Goto (macro-outbound-callerid,s,6)

-- Executing [s@macro-outbound-callerid:6] Set("SIP/207-00000000", "USEROUTCID=") in new stack

-- Executing [s@macro-outbound-callerid:7] Set("SIP/207-00000000", "EMERGENCYCID=") in new stack

-- Executing [s@macro-outbound-callerid:8] Set("SIP/207-00000000", "TRUNKOUTCID=02XXXXXXXXX") in new stack

-- Executing [s@macro-outbound-callerid:9] GotoIf("SIP/207-00000000", "1?trunkcid") in new stack

-- Goto (macro-outbound-callerid,s,12)

-- Executing [s@macro-outbound-callerid:12] ExecIf("SIP/207-00000000", "1?Set(CALLERID(all)=02XXXXXXXXX)") in new stack

-- Executing [s@macro-outbound-callerid:13] ExecIf("SIP/207-00000000", "0?Set(CALLERID(all)=)") in new stack

-- Executing [s@macro-outbound-callerid:14] ExecIf("SIP/207-00000000", "1?Set(CALLERID(all)=02XXXXXXXXX)") in new stack

-- Executing [s@macro-outbound-callerid:15] ExecIf("SIP/207-00000000", "0?Set(CALLERPRES()=prohib_passed_screen)") in new stack

-- Executing [s@macro-dialout-trunk:12] GosubIf("SIP/207-00000000", "0?sub-flp-2,s,1") in new stack

-- Executing [s@macro-dialout-trunk:13] Set("SIP/207-00000000", "OUTNUM=07XXXXXXXXX") in new stack

-- Executing [s@macro-dialout-trunk:14] Set("SIP/207-00000000", "custom=SIP/Test02") in new stack

-- Executing [s@macro-dialout-trunk:15] ExecIf("SIP/207-00000000", "0?Set(DIAL_TRUNK_OPTIONS=M(setmusic^default))") in new stack

-- Executing [s@macro-dialout-trunk:16] Macro("SIP/207-00000000", "dialout-trunk-predial-hook,") in new stack

-- Executing [s@macro-dialout-trunk-predial-hook:1] MacroExit("SIP/207-00000000", "") in new stack

-- Executing [s@macro-dialout-trunk:17] GotoIf("SIP/207-00000000", "0?bypass,1") in new stack

-- Executing [s@macro-dialout-trunk:18] GotoIf("SIP/207-00000000", "0?customtrunk") in new stack

-- Executing [s@macro-dialout-trunk:19] Dial("SIP/207-00000000", "SIP/Test02/07XXXXXXXXX,300,") in new stack

== Using SIP RTP TOS bits 184

== Using SIP RTP CoS mark 5

Audio is at 195.XXX.XXX.XXX port 11740

Adding codec 0x4 (ulaw) to SDP

Adding codec 0x8 (alaw) to SDP

Adding codec 0x2 (gsm) to SDP

Adding non-codec 0x1 (telephone-event) to SDP

Reliably Transmitting (NAT) to 87.XXX.XXX.XXX:5060:

INVITE sip:[email protected] SIP/2.0

Via: SIP/2.0/UDP 195.XXX.XXX.XXX:5060;branch=z9hG4bK7791038f;rport

Max-Forwards: 70

From: “02XXXXXXXXX” sip:[email protected];tag=as400b86fa

To: sip:[email protected]

Contact: sip:[email protected]

Call-ID: [email protected]

CSeq: 102 INVITE

User-Agent: Asterisk PBX 1.6.2.15

Remote-Party-ID: “02XXXXXXXXX” sip:[email protected];privacy=off;screen=no

Date: Mon, 20 Dec 2010 03:21:44 GMT

Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO

Supported: replaces, timer

Content-Type: application/sdp

Content-Length: 284

v=0

o=root 1276180298 1276180298 IN IP4 195.XXX.XXX.XXX

s=Asterisk PBX 1.6.2.15

c=IN IP4 195.XXX.XXX.XXX

t=0 0

m=audio 11740 RTP/AVP 0 8 3 101

a=rtpmap:0 PCMU/8000

a=rtpmap:8 PCMA/8000

a=rtpmap:3 GSM/8000

a=rtpmap:101 telephone-event/8000

a=fmtp:101 0-16

a=ptime:20

a=sendrecv


<— SIP read from UDP:87.XXX.XXX.XXX:5060 —>

SIP/2.0 407 Proxy Authentication Required

Via: SIP/2.0/UDP 195.XXX.XXX.XXX:5060;branch=z9hG4bK7791038f;received=195.XXX.XXX.XXX;rport=5060

From: “02XXXXXXXXX” sip:[email protected];tag=as400b86fa

To: sip:[email protected];tag=as6b9b5976

Call-ID: [email protected]

CSeq: 102 INVITE

User-Agent: Asterisk PBX

Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY

Supported: replaces

Proxy-Authenticate: Digest algorithm=MD5, realm=“asterisk”, nonce=“274e2af0”

Content-Length: 0

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

— (11 headers 0 lines) —

Transmitting (NAT) to 87.XXX.XXX.XXX:5060:

ACK sip:[email protected] SIP/2.0

Via: SIP/2.0/UDP 195.XXX.XXX.XXX:5060;branch=z9hG4bK7791038f;rport

Max-Forwards: 70

From: “02XXXXXXXXX” sip:[email protected];tag=as400b86fa

To: sip:[email protected];tag=as6b9b5976

Contact: sip:[email protected]

Call-ID: [email protected]

CSeq: 102 ACK

User-Agent: Asterisk PBX 1.6.2.15

Remote-Party-ID: “02XXXXXXXXX” sip:[email protected];privacy=off;screen=no

Content-Length: 0


Audio is at 195.XXX.XXX.XXX port 11740

Adding codec 0x4 (ulaw) to SDP

Adding codec 0x8 (alaw) to SDP

Adding codec 0x2 (gsm) to SDP

Adding non-codec 0x1 (telephone-event) to SDP

Reliably Transmitting (NAT) to 87.XXX.XXX.XXX:5060:

INVITE sip:[email protected] SIP/2.0

Via: SIP/2.0/UDP 195.XXX.XXX.XXX:5060;branch=z9hG4bK2b086846;rport

Max-Forwards: 70

From: “02XXXXXXXXX” sip:[email protected];tag=as400b86fa

To: sip:[email protected]

Contact: sip:[email protected]

Call-ID: [email protected]

CSeq: 103 INVITE

User-Agent: Asterisk PBX 1.6.2.15

Remote-Party-ID: “02XXXXXXXXX” sip:[email protected];privacy=off;screen=no

Proxy-Authorization: Digest username=“XXXXXXXXXX”, realm=“asterisk”, algorithm=MD5, uri="sip:[email protected]", nonce=“274e2af0”, response=“74ea7f942ed24d01c4f5de9eddfa22f5”

Date: Mon, 20 Dec 2010 03:21:44 GMT

Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO

Supported: replaces, timer

Content-Type: application/sdp

Content-Length: 284

v=0

o=root 1276180298 1276180299 IN IP4 195.XXX.XXX.XXX

s=Asterisk PBX 1.6.2.15

c=IN IP4 195.XXX.XXX.XXX

t=0 0

m=audio 11740 RTP/AVP 0 8 3 101

a=rtpmap:0 PCMU/8000

a=rtpmap:8 PCMA/8000

a=rtpmap:3 GSM/8000

a=rtpmap:101 telephone-event/8000

a=fmtp:101 0-16

a=ptime:20

a=sendrecv


<— SIP read from UDP:87.XXX.XXX.XXX:5060 —>

SIP/2.0 403 Forbidden

Via: SIP/2.0/UDP 195.XXX.XXX.XXX:5060;branch=z9hG4bK2b086846;received=195.XXX.XXX.XXX;rport=5060

From: “02XXXXXXXXX” sip:[email protected];tag=as400b86fa

To: sip:[email protected];tag=as6b9b5976

Call-ID: [email protected]

CSeq: 103 INVITE

User-Agent: Asterisk PBX

Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY

Supported: replaces

Content-Length: 0

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

— (10 headers 0 lines) —

Transmitting (NAT) to 87.XXX.XXX.XXX:5060:

ACK sip:[email protected] SIP/2.0

Via: SIP/2.0/UDP 195.XXX.XXX.XXX:5060;branch=z9hG4bK2b086846;rport

Max-Forwards: 70

From: “02XXXXXXXXX” sip:[email protected];tag=as400b86fa

To: sip:[email protected];tag=as6b9b5976

Contact: sip:[email protected]

Call-ID: [email protected]

CSeq: 103 ACK

User-Agent: Asterisk PBX 1.6.2.15

Remote-Party-ID: “02XXXXXXXXX” sip:[email protected];privacy=off;screen=no

Content-Length: 0


-- Called Test02/07XXXXXXXXX

-- SIP/Test02-00000001 is circuit-busy

== Everyone is busy/congested at this time (1:0/1/0)

-- Executing [s@macro-dialout-trunk:20] NoOp("SIP/207-00000000", "Dial failed for some reason with DIALSTATUS = CONGESTION and HANGUPCAUSE = 21") in new stack

-- Executing [s@macro-dialout-trunk:21] Goto("SIP/207-00000000", "s-CONGESTION,1") in new stack

-- Goto (macro-dialout-trunk,s-CONGESTION,1)

-- Executing [s-CONGESTION@macro-dialout-trunk:1] Set("SIP/207-00000000", "RC=21") in new stack

-- Executing [s-CONGESTION@macro-dialout-trunk:2] Goto("SIP/207-00000000", "21,1") in new stack

-- Goto (macro-dialout-trunk,21,1)

-- Executing [21@macro-dialout-trunk:1] Goto("SIP/207-00000000", "continue,1") in new stack

-- Goto (macro-dialout-trunk,continue,1)

-- Executing [continue@macro-dialout-trunk:1] GotoIf("SIP/207-00000000", "1?noreport") in new stack

-- Goto (macro-dialout-trunk,continue,3)

-- Executing [continue@macro-dialout-trunk:3] NoOp("SIP/207-00000000", "TRUNK Dial failed due to CONGESTION HANGUPCAUSE: 21 - failing through to other trunks") in new stack

-- Executing [continue@macro-dialout-trunk:4] Set("SIP/207-00000000", "CALLERID(number)=207") in new stack

-- Executing [07XXXXXXXXX@from-internal:7] Macro("SIP/207-00000000", "outisbusy,") in new stack

-- Executing [s@macro-outisbusy:1] Progress("SIP/207-00000000", "") in new stack

Audio is at 192.XXX.XXX.XXX port 10594

Adding codec 0x4 (ulaw) to SDP

Adding codec 0x8 (alaw) to SDP

Adding codec 0x2 (gsm) to SDP

Adding non-codec 0x1 (telephone-event) to SDP

<— Transmitting (NAT) to 192.XXX.XXX.XXX:2049 —>

SIP/2.0 183 Session Progress

Via: SIP/2.0/UDP 192.XXX.XXX.XXX:2049;branch=z9hG4bK-gefktzcfq6jy;received=192.XXX.XXX.XXX;rport=2049

From: “Test06” sip:[email protected];tag=fl0crpvpbr

To: sip:[email protected];user=phone;tag=as5db19a33

Call-ID: 3c791bf20e4c-23j7lfluuo6m

CSeq: 2 INVITE

Server: Asterisk PBX 1.6.2.15

Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO

Supported: replaces, timer

Session-Expires: 1800;refresher=uas

Contact: sip:[email protected]

Content-Type: application/sdp

Content-Length: 284

v=0

o=root 456832074 456832074 IN IP4 192.XXX.XXX.XXX

s=Asterisk PBX 1.6.2.15

c=IN IP4 192.XXX.XXX.XXX

t=0 0

m=audio 10594 RTP/AVP 0 8 3 101

a=rtpmap:0 PCMU/8000

a=rtpmap:8 PCMA/8000

a=rtpmap:3 GSM/8000

a=rtpmap:101 telephone-event/8000

a=fmtp:101 0-16

a=ptime:20

a=sendrecv

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

-- Executing [s@macro-outisbusy:2] Playback("SIP/207-00000000", "all-circuits-busy-now,noanswer") in new stack

-- <SIP/207-00000000> Playing 'all-circuits-busy-now.gsm' (language 'en_GB')

Really destroying SIP dialog ‘[email protected]’ Method: INVITE

-- Executing [s@macro-outisbusy:3] Playback("SIP/207-00000000", "pls-try-call-later,noanswer") in new stack

-- <SIP/207-00000000> Playing 'pls-try-call-later.gsm' (language 'en_GB')

-- Executing [s@macro-outisbusy:4] Macro("SIP/207-00000000", "hangupcall") in new stack

-- Executing [s@macro-hangupcall:1] GotoIf("SIP/207-00000000", "1?skiprg") in new stack

-- Goto (macro-hangupcall,s,4)

-- Executing [s@macro-hangupcall:4] GotoIf("SIP/207-00000000", "1?skipblkvm") in new stack

-- Goto (macro-hangupcall,s,7)

-- Executing [s@macro-hangupcall:7] GotoIf("SIP/207-00000000", "1?theend") in new stack

-- Goto (macro-hangupcall,s,9)

-- Executing [s@macro-hangupcall:9] Hangup("SIP/207-00000000", "") in new stack

== Spawn extension (macro-hangupcall, s, 9) exited non-zero on ‘SIP/207-00000000’ in macro ‘hangupcall’

== Spawn extension (macro-outisbusy, s, 4) exited non-zero on ‘SIP/207-00000000’ in macro ‘outisbusy’

== Spawn extension (from-internal, 07XXXXXXXXX, 7) exited non-zero on ‘SIP/207-00000000’

-- Executing [h@from-internal:1] Macro("SIP/207-00000000", "hangupcall") in new stack

-- Executing [s@macro-hangupcall:1] GotoIf("SIP/207-00000000", "1?skiprg") in new stack

-- Goto (macro-hangupcall,s,4)

-- Executing [s@macro-hangupcall:4] GotoIf("SIP/207-00000000", "1?skipblkvm") in new stack

-- Goto (macro-hangupcall,s,7)

-- Executing [s@macro-hangupcall:7] GotoIf("SIP/207-00000000", "1?theend") in new stack

-- Goto (macro-hangupcall,s,9)

-- Executing [s@macro-hangupcall:9] Hangup("SIP/207-00000000", "") in new stack

== Spawn extension (macro-hangupcall, s, 9) exited non-zero on ‘SIP/207-00000000’ in macro ‘hangupcall’

== Spawn extension (from-internal, h, 1) exited non-zero on ‘SIP/207-00000000’

Scheduling destruction of SIP dialog ‘3c791bf20e4c-23j7lfluuo6m’ in 6400 ms (Method: INVITE)

<— Reliably Transmitting (NAT) to 192.XXX.XXX.XXX:2049 —>

SIP/2.0 403 Forbidden

Via: SIP/2.0/UDP 192.XXX.XXX.XXX:2049;branch=z9hG4bK-gefktzcfq6jy;received=192.XXX.XXX.XXX;rport=2049

From: “Test06” sip:[email protected];tag=fl0crpvpbr

To: sip:[email protected];user=phone;tag=as5db19a33

Call-ID: 3c791bf20e4c-23j7lfluuo6m

CSeq: 2 INVITE

Server: Asterisk PBX 1.6.2.15

Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO

Supported: replaces, timer

Content-Length: 0

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

<— SIP read from UDP:192.XXX.XXX.XXX:2049 —>

ACK sip:[email protected];user=phone SIP/2.0

Via: SIP/2.0/UDP 192.XXX.XXX.XXX:2049;branch=z9hG4bK-gefktzcfq6jy;rport

From: “Test06” sip:[email protected];tag=fl0crpvpbr

To: sip:[email protected];user=phone;tag=as5db19a33

Call-ID: 3c791bf20e4c-23j7lfluuo6m

CSeq: 2 ACK

Max-Forwards: 70

Contact: sip:[email protected]:2049;line=wrc75tvx;reg-id=1

Content-Length: 0

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

— (9 headers 0 lines) —

Can you see anything that may suggest what the problem is?

Thanks again for your help :slight_smile:

BR

Hi Guys

Thanks for the replies, my apologies for not replying sooner but I’ve been trying to resolve this and am still having no luck.

I’ve tried both methods and I’m close both times. The problem is this:

I’ve set up 2 companies on the box that both share an office. Both companies have the same dial prefix, for example 01708, and both need to be able to dial any number.

The inbound routes work fine. If you dial one number extensions 201-206 ring, and if you dial the other number extensions 207-208 ring.

I’ve created 2 outbound routes that only contain ‘X.’ (without single quotes) in the ‘match pattern’ field, so that any calls placed will go out to the trunk. Route 1 goes to Trunk 1 and route 2 goes to trunk 2.

If I place a call from extensions 201-206 the calls go through, using route 1/trunk 1. If I place a call using extensions 207-208 I get the ‘all circuits are busy now’ message.

From what I can glean from trawling the net the problem lies with the fact I have 2 routes with the same dial plan - ‘X.’ in this case, even though they are named route 1 and route 2 and point towards trunk 1 and trunk 2.

Is there a way to achieve what I’m attempting? Please let me know if I need to elaborate.

I’ve included the cli output from the failed call below (numbers changed).

Executing [07XXXXXXXXX@from-internal:1] Macro(“SIP/207-0000002a”, “user-callerid,SKIPTTL,”) in new stack

-- Executing [s@macro-user-callerid:1] Set("SIP/207-0000002a", "AMPUSER=207") in new stack

-- Executing [s@macro-user-callerid:2] GotoIf("SIP/207-0000002a", "0?report") in new stack

-- Executing [s@macro-user-callerid:3] ExecIf("SIP/207-0000002a", "1?Set(REALCALLERIDNUM=207)") in new stack

-- Executing [s@macro-user-callerid:4] Set("SIP/207-0000002a", "AMPUSER=207") in new stack

-- Executing [s@macro-user-callerid:5] Set("SIP/207-0000002a", "AMPUSERCIDNAME=Test07") in new stack

-- Executing [s@macro-user-callerid:6] GotoIf("SIP/207-0000002a", "0?report") in new stack

-- Executing [s@macro-user-callerid:7] Set("SIP/207-0000002a", "AMPUSERCID=207") in new stack

-- Executing [s@macro-user-callerid:8] Set("SIP/207-0000002a", "CALLERID(all)="Test07" <207>") in new stack

-- Executing [s@macro-user-callerid:9] GotoIf("SIP/207-0000002a", "1?continue") in new stack

-- Goto (macro-user-callerid,s,18)

-- Executing [s@macro-user-callerid:18] NoOp("SIP/207-0000002a", "Using CallerID "Test07" <207>") in new stack

-- Executing [07XXXXXXXXX@from-internal:2] NoOp("SIP/207-0000002a", "Calling Out Route: Route02") in new stack

-- Executing [07XXXXXXXXX@from-internal:3] Set("SIP/207-0000002a", "MOHCLASS=default") in new stack

-- Executing [07XXXXXXXXX@from-internal:4] Set("SIP/207-0000002a", "_NODEST=") in new stack

-- Executing [07XXXXXXXXX@from-internal:5] Macro("SIP/207-0000002a", "record-enable,207,OUT,") in new stack

-- Executing [s@macro-record-enable:1] GotoIf("SIP/207-0000002a", "1?check") in new stack

-- Goto (macro-record-enable,s,4)

-- Executing [s@macro-record-enable:4] ExecIf("SIP/207-0000002a", "0?MacroExit()") in new stack

-- Executing [s@macro-record-enable:5] GotoIf("SIP/207-0000002a", "0?Group:OUT") in new stack

-- Goto (macro-record-enable,s,15)

-- Executing [s@macro-record-enable:15] GotoIf("SIP/207-0000002a", "0?IN") in new stack

-- Executing [s@macro-record-enable:16] ExecIf("SIP/207-0000002a", "1?MacroExit()") in new stack

-- Executing [07XXXXXXXXX@from-internal:6] Macro("SIP/207-0000002a", "dialout-trunk,2,07XXXXXXXXX,") in new stack

-- Executing [s@macro-dialout-trunk:1] Set("SIP/207-0000002a", "DIAL_TRUNK=2") in new stack

-- Executing [s@macro-dialout-trunk:2] GosubIf("SIP/207-0000002a", "0?sub-pincheck,s,1") in new stack

-- Executing [s@macro-dialout-trunk:3] GotoIf("SIP/207-0000002a", "0?disabletrunk,1") in new stack

-- Executing [s@macro-dialout-trunk:4] Set("SIP/207-0000002a", "DIAL_NUMBER=07XXXXXXXXX") in new stack

-- Executing [s@macro-dialout-trunk:5] Set("SIP/207-0000002a", "DIAL_TRUNK_OPTIONS=tr") in new stack

-- Executing [s@macro-dialout-trunk:6] Set("SIP/207-0000002a", "OUTBOUND_GROUP=OUT_2") in new stack

-- Executing [s@macro-dialout-trunk:7] GotoIf("SIP/207-0000002a", "1?nomax") in new stack

-- Goto (macro-dialout-trunk,s,9)

-- Executing [s@macro-dialout-trunk:9] GotoIf("SIP/207-0000002a", "0?skipoutcid") in new stack

-- Executing [s@macro-dialout-trunk:10] Set("SIP/207-0000002a", "DIAL_TRUNK_OPTIONS=") in new stack

-- Executing [s@macro-dialout-trunk:11] Macro("SIP/207-0000002a", "outbound-callerid,2") in new stack

-- Executing [s@macro-outbound-callerid:1] ExecIf("SIP/207-0000002a", "0?Set(CALLERPRES()=)") in new stack

-- Executing [s@macro-outbound-callerid:2] ExecIf("SIP/207-0000002a", "0?Set(REALCALLERIDNUM=207)") in new stack

-- Executing [s@macro-outbound-callerid:3] GotoIf("SIP/207-0000002a", "1?normcid") in new stack

-- Goto (macro-outbound-callerid,s,6)

-- Executing [s@macro-outbound-callerid:6] Set("SIP/207-0000002a", "USEROUTCID=") in new stack

-- Executing [s@macro-outbound-callerid:7] Set("SIP/207-0000002a", "EMERGENCYCID=") in new stack

-- Executing [s@macro-outbound-callerid:8] Set("SIP/207-0000002a", "TRUNKOUTCID=02XXXXXXXXX") in new stack

-- Executing [s@macro-outbound-callerid:9] GotoIf("SIP/207-0000002a", "1?trunkcid") in new stack

-- Goto (macro-outbound-callerid,s,12)

-- Executing [s@macro-outbound-callerid:12] ExecIf("SIP/207-0000002a", "1?Set(CALLERID(all)=02XXXXXXXXX)") in new stack

-- Executing [s@macro-outbound-callerid:13] ExecIf("SIP/207-0000002a", "0?Set(CALLERID(all)=)") in new stack

-- Executing [s@macro-outbound-callerid:14] ExecIf("SIP/207-0000002a", "1?Set(CALLERID(all)=02XXXXXXXXX)") in new stack

-- Executing [s@macro-outbound-callerid:15] ExecIf("SIP/207-0000002a", "0?Set(CALLERPRES()=prohib_passed_screen)") in new stack

-- Executing [s@macro-dialout-trunk:12] GosubIf("SIP/207-0000002a", "0?sub-flp-2,s,1") in new stack

-- Executing [s@macro-dialout-trunk:13] Set("SIP/207-0000002a", "OUTNUM=07XXXXXXXXX") in new stack

-- Executing [s@macro-dialout-trunk:14] Set("SIP/207-0000002a", "custom=SIP/Test02") in new stack

-- Executing [s@macro-dialout-trunk:15] ExecIf("SIP/207-0000002a", "0?Set(DIAL_TRUNK_OPTIONS=M(setmusic^default))") in new stack

-- Executing [s@macro-dialout-trunk:16] Macro("SIP/207-0000002a", "dialout-trunk-predial-hook,") in new stack

-- Executing [s@macro-dialout-trunk-predial-hook:1] MacroExit("SIP/207-0000002a", "") in new stack

-- Executing [s@macro-dialout-trunk:17] GotoIf("SIP/207-0000002a", "0?bypass,1") in new stack

-- Executing [s@macro-dialout-trunk:18] GotoIf("SIP/207-0000002a", "0?customtrunk") in new stack

-- Executing [s@macro-dialout-trunk:19] Dial("SIP/207-0000002a", "SIP/Test02/07XXXXXXXXX,300,") in new stack

== Using SIP RTP TOS bits 184

== Using SIP RTP CoS mark 5

testpbx*CLI> Use of uninitialized value in hash element at /var/www/html/panel/op_server.pl line 3367.

Use of uninitialized value in concatenation (.) or string at /var/www/html/panel/op_server.pl line 3372.

Use of uninitialized value in pattern match (m//) at /var/www/html/panel/op_server.pl line 3374.

-- Called Test02/07XXXXXXXXX

-- SIP/Test02-0000002b is circuit-busy

== Everyone is busy/congested at this time (1:0/1/0)

-- Executing [s@macro-dialout-trunk:20] NoOp("SIP/207-0000002a", "Dial failed for some reason with DIALSTATUS = CONGESTION and HANGUPCAUSE = 21") in new stack

-- Executing [s@macro-dialout-trunk:21] Goto("SIP/207-0000002a", "s-CONGESTION,1") in new stack

-- Goto (macro-dialout-trunk,s-CONGESTION,1)

-- Executing [s-CONGESTION@macro-dialout-trunk:1] Set("SIP/207-0000002a", "RC=21") in new stack

-- Executing [s-CONGESTION@macro-dialout-trunk:2] Goto("SIP/207-0000002a", "21,1") in new stack

-- Goto (macro-dialout-trunk,21,1)

-- Executing [21@macro-dialout-trunk:1] Goto("SIP/207-0000002a", "continue,1") in new stack

-- Goto (macro-dialout-trunk,continue,1)

-- Executing [continue@macro-dialout-trunk:1] GotoIf("SIP/207-0000002a", "1?noreport") in new stack

-- Goto (macro-dialout-trunk,continue,3)

-- Executing [continue@macro-dialout-trunk:3] NoOp("SIP/207-0000002a", "TRUNK Dial failed due to CONGESTION HANGUPCAUSE: 21 - failing through to other trunks") in new stack

-- Executing [continue@macro-dialout-trunk:4] Set("SIP/207-0000002a", "CALLERID(number)=207") in new stack

-- Executing [07XXXXXXXXX@from-internal:7] Macro("SIP/207-0000002a", "outisbusy,") in new stack

-- Executing [s@macro-outisbusy:1] Progress("SIP/207-0000002a", "") in new stack

-- Executing [s@macro-outisbusy:2] Playback("SIP/207-0000002a", "all-circuits-busy-now,noanswer") in new stack

-- <SIP/207-0000002a> Playing 'all-circuits-busy-now.gsm' (language 'en_GB')

testpbx*CLI> Use of uninitialized value in concatenation (.) or string at /var/www/html/panel/op_server.pl line 3360.

Use of uninitialized value in hash element at /var/www/html/panel/op_server.pl line 3367.

Use of uninitialized value in concatenation (.) or string at /var/www/html/panel/op_server.pl line 3372.

Use of uninitialized value in pattern match (m//) at /var/www/html/panel/op_server.pl line 3374.

== Manager ‘admin’ logged on from 127.0.0.1

== Spawn extension (macro-outisbusy, s, 2) exited non-zero on ‘SIP/207-0000002a’ in macro ‘outisbusy’

== Spawn extension (from-internal, 07XXXXXXXXX, 7) exited non-zero on ‘SIP/207-0000002a’

-- Executing [h@from-internal:1] Macro("SIP/207-0000002a", "hangupcall") in new stack

-- Executing [s@macro-hangupcall:1] GotoIf("SIP/207-0000002a", "1?skiprg") in new stack

-- Goto (macro-hangupcall,s,4)

-- Executing [s@macro-hangupcall:4] GotoIf("SIP/207-0000002a", "1?skipblkvm") in new stack

-- Goto (macro-hangupcall,s,7)

-- Executing [s@macro-hangupcall:7] GotoIf("SIP/207-0000002a", "1?theend") in new stack

-- Goto (macro-hangupcall,s,9)

-- Executing [s@macro-hangupcall:9] Hangup("SIP/207-0000002a", "") in new stack

== Spawn extension (macro-hangupcall, s, 9) exited non-zero on ‘SIP/207-0000002a’ in macro ‘hangupcall’

TIA

BR

Setup two outbound routes, one for each trunk, then you need to use the custom context module and setup two different contexts each with one of the outbound routes allowed, then set whichever context you want with each extension and calls from the extension will be pushed out on that contexts outbound route. The custom context module is in the extended repository if I remember correctly.

Stonet, that seems like overkill for what he was asking. Two trunks, two outbound routes pointing to the two trunks with each outbound route assigned only to certain CallerID (extensions) will do the trick with the native modules.

Since you’re using FreePBX 2.8, notice the end part of the Dial Pattern field. That CallerId section means that callers from CallerId (20[0-6] for your first one, 20[78] for your second) will match that outbound route.

Hi Bill

Thanks for the reply. I tried your suggestion and the Inbound Routes are now working. Adding the account number to the end of the reg string did the trick.

I also had to talk to the SIP provider to get them to send the CLI on outbound calls, however, I still haven’t got the Outbound Routes set up correctly.

What I need to achieve is for extensions 200-206 to use Outbound Route A (set to use Trunk A) and for extensions 207-208 to use Outbound Route B (set to use Trunk B).

How should this be done?

Again, any help would be much appreciated.

TIA

BR

You noted that you are registering to your provider.

Have you added the DID at the end of your registration string, e.g.

username:[email protected]/DIDNUM

?

If you do, they might send the DID to you. This line shows that they are not, currently:

– Executing [s@from-trunk-sip-balm:1]

Otherwise the DID would show up in place of the ‘s’ extension.

if it helps anyone, the ‘fromuser=XXXXXXXX’ sorted sorted by problem. It seems like the pbx was using one of the other trunk numbers I have to present to the sip provider. The fromuser forces the correct number to present to the carrier, and then works. If I remove it, I get “all lines are busy” message again.

Thanks for the post!