Understanding custom destinations

Hello,

i want to use custom destination to route calls from trunk to extensions by using only one inbound route.

In my custom destination i have this as destination

`from-did-direct,${FROM_DID:-2},1`

And as far as i understand it means the last two digits will be used to identify the extension. Imagine i have following numbers/extension:

+4912345678 - 8
+4912345678 - 81

In my tests routing to 81 works, but to 8 not. Am i correct if i say “-2” means EXACTLY two digits? And how can i achieve my goal? Our Extensions could be XX and XXX (and perhaps also X). I need to match all possibilities.

Kind Regards

Thomas

from-did-direct,${FROM_DID:11},1
where 11 is the number of characters you want to remove from the beginning of the string.
The remainder of the string, presumably one to three digits, will be used as the extension.

OMG, sure.

Thank you Stewart. Some problems can be solved so easy.

Kind Regards

Thomas

I try to setup an inbound for all extensions, and as DID Number i use

_4912345678X

But if i call the number i’ll get “no service” and the log shows up this:

[2024-02-22 10:16:50] VERBOSE[20484][C-00000123] pbx.c: Executing [s@from-pstn:3] Log("PJSIP/wt_teststellung-000001bf", "WARNING,Friendly Scanner from ") in new stack	
[2024-02-22 10:16:50] WARNING[20484][C-00000123] Ext. s: Friendly Scanner from

Why i have just one X? I test it with a sip trunk for testing which has just extensions from 0-9, one digit. If i will go live with freePBX, the trunk will have extensions from 0-999, 3 digits.

Regards
Thomas

Set Context for the trunk to
from-pstn-toheader

If you still have trouble, post a log of the incoming INVITE (using pjsip logger or sngrep).

Set the Context doesn’t made a change. I used the pjsip logger, and this is the result while i made a call till “no service”. In this log the number i used to make a call is xxxxxx181 and i tried to call xxxxxx7. Maybe @Stewart1 you can see whats going on.

6869	[2024-02-22 11:14:07] VERBOSE[3596] res_pjsip_logger.c: <--- Received SIP request (867 bytes) from UDP:xxx.xxx.xxx.xxx:5060 --->	
6870	INVITE sip:+49##########[email protected]:5060 SIP/2.0	
6871	Call-ID: [email protected]	
6872	Contact: <sip:xxx.xxx.xxx.xxx:5060>	
6873	Content-Type: application/sdp	
6874	CSeq: 2060182761 INVITE	
6875	From: "+49xxxxxxxx181" <sip:[email protected];user=phone>;tag=22649-CQ-7bfda8c6-7bac64cc4	
6876	Max-Forwards: 58	
6877	Record-Route: <sip:xxx.xxx.xxx.xxx:5060;lr>;session=3467	
6878	To: <sip:+49##########[email protected];user=phone>	
6879	Via: SIP/2.0/UDP xxx.xxx.xxx.xxx:5060;branch=z9hG4bK-CJPC-03f1aced-11f25eb6	
6880	Allow: REFER,INVITE,ACK,REGISTER,UPDATE,CANCEL,BYE	
6881	User-Agent: wtnet/ngn (2)	
6882	Content-Length: 249	
6883		
6884	v=0	
6885	o=anonymous 170859684790 170859684790 IN IP4 xxx.xxx.xxx.xxx	
6886	s=SIP Call	
6887	c=IN IP4 xxx.xxx.xxx.xxx	
6888	t=0 0	
6889	m=audio 32728 RTP/AVP 8 101	
6890	b=AS:82	
6891	a=rtpmap:8 PCMA/8000/1	
6892	a=rtpmap:101 telephone-event/8000	
6893	a=fmtp:101 0-15	
6894	a=ptime:20	
6895	a=sendrecv	
6896		
6897	[2024-02-22 11:14:07] VERBOSE[12034] res_pjsip_logger.c: <--- Transmitting SIP response (488 bytes) to UDP:xxx.xxx.xxx.xxx:5060 --->	
6898	SIP/2.0 100 Trying	
6899	Via: SIP/2.0/UDP xxx.xxx.xxx.xxx:5060;rport=5060;received=xxx.xxx.xxx.xxx;branch=z9hG4bK-CJPC-03f1aced-11f25eb6	
6900	Record-Route: <sip:xxx.xxx.xxx.xxx:5060;lr>;session=3467	
6901	Call-ID: [email protected]	
6902	From: "+49xxxxxxxx181" <sip:[email protected];user=phone>;tag=22649-CQ-7bfda8c6-7bac64cc4	
6903	To: <sip:+49##########[email protected];user=phone>	
6904	CSeq: 2060182761 INVITE	
6905	Server: FPBX-16.0.40.7(16.30.0)	
6906	Content-Length: 0	
6907		
6908		
6909	[2024-02-22 11:14:07] VERBOSE[1350][C-00000129] pbx.c: Executing [+49##########7@from-pstn-toheader:1] NoOp("PJSIP/wt_teststellung-000001c7", "Attempting to extract DID from SIP To header") in new stack	
6910	[2024-02-22 11:14:07] VERBOSE[1350][C-00000129] pbx.c: Executing [+49##########7@from-pstn-toheader:2] GotoIf("PJSIP/wt_teststellung-000001c7", "0?SIP") in new stack	
6911	[2024-02-22 11:14:07] VERBOSE[1350][C-00000129] pbx.c: Executing [+49##########7@from-pstn-toheader:3] GotoIf("PJSIP/wt_teststellung-000001c7", "1?PJSIP") in new stack	
6912	[2024-02-22 11:14:07] VERBOSE[1350][C-00000129] pbx_builtins.c: Goto (from-pstn-toheader,+49##########7,7)	
6913	[2024-02-22 11:14:07] VERBOSE[1350][C-00000129] pbx.c: Executing [+49##########7@from-pstn-toheader:7] Goto("PJSIP/wt_teststellung-000001c7", "from-pstn,+49##########7,1") in new stack	
6914	[2024-02-22 11:14:07] VERBOSE[1350][C-00000129] pbx_builtins.c: Goto (from-pstn,+49##########7,1)	
6915	[2024-02-22 11:14:07] VERBOSE[1350][C-00000129] pbx.c: Executing [+49##########7@from-pstn:1] Set("PJSIP/wt_teststellung-000001c7", "__FROM_DID=+49##########7") in new stack	
6916	[2024-02-22 11:14:07] VERBOSE[1350][C-00000129] pbx.c: Executing [+49##########7@from-pstn:2] NoOp("PJSIP/wt_teststellung-000001c7", "Received an unknown call with DID set to +49##########7") in new stack	
6917	[2024-02-22 11:14:07] VERBOSE[1350][C-00000129] pbx.c: Executing [+49##########7@from-pstn:3] Goto("PJSIP/wt_teststellung-000001c7", "s,a2") in new stack	
6918	[2024-02-22 11:14:07] VERBOSE[1350][C-00000129] pbx_builtins.c: Goto (from-pstn,s,2)	
6919	[2024-02-22 11:14:07] VERBOSE[1350][C-00000129] pbx.c: Executing [s@from-pstn:2] Answer("PJSIP/wt_teststellung-000001c7", "") in new stack	
6920	[2024-02-22 11:14:07] VERBOSE[21401] res_pjsip_logger.c: <--- Transmitting SIP response (989 bytes) to UDP:xxx.xxx.xxx.xxx:5060 --->	
6921	SIP/2.0 200 OK	
6922	Via: SIP/2.0/UDP xxx.xxx.xxx.xxx:5060;rport=5060;received=xxx.xxx.xxx.xxx;branch=z9hG4bK-CJPC-03f1aced-11f25eb6	
6923	Record-Route: <sip:xxx.xxx.xxx.xxx:5060;lr>;session=3467	
6924	Call-ID: [email protected]	
6925	From: "+49xxxxxxxx181" <sip:[email protected];user=phone>;tag=22649-CQ-7bfda8c6-7bac64cc4	
6926	To: <sip:+49##########[email protected];user=phone>;tag=f95b3336-86ec-4efb-b034-72d202c412f6	
6927	CSeq: 2060182761 INVITE	
6928	Server: FPBX-16.0.40.7(16.30.0)	
6929	Contact: <sip:xx.xx.xx.xx:5060>	
6930	Allow: OPTIONS, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, REGISTER, SUBSCRIBE, NOTIFY, PUBLISH, MESSAGE, REFER	
6931	Supported: 100rel, timer, replaces, norefersub	
6932	Content-Type: application/sdp	
6933	Content-Length: 237	
6934		
6935	v=0	
6936	o=- 3355960246 3355960248 IN IP4 xx.xx.xx.xx	
6937	s=Asterisk	
6938	c=IN IP4 xx.xx.xx.xx	
6939	t=0 0	
6940	m=audio 16638 RTP/AVP 8 101	
6941	a=rtpmap:8 PCMA/8000	
6942	a=rtpmap:101 telephone-event/8000	
6943	a=fmtp:101 0-16	
6944	a=ptime:20	
6945	a=maxptime:150	
6946	a=sendrecv	
6947		
6948	[2024-02-22 11:14:07] VERBOSE[3596] res_pjsip_logger.c: <--- Received SIP request (495 bytes) from UDP:xxx.xxx.xxx.xxx:5060 --->	
6949	ACK sip:xx.xx.xx.xx:5060 SIP/2.0	
6950	Call-ID: [email protected]	
6951	Contact: <sip:xxx.xxx.xxx.xxx:5060>	
6952	CSeq: 2060182761 ACK	
6953	From: "+49xxxxxxxx181" <sip:[email protected];user=phone>;tag=22649-CQ-7bfda8c6-7bac64cc4	
6954	Max-Forwards: 58	
6955	To: <sip:+49##########[email protected];user=phone>;tag=f95b3336-86ec-4efb-b034-72d202c412f6	
6956	Via: SIP/2.0/UDP xxx.xxx.xxx.xxx:5060;branch=z9hG4bK-TEOV-03f1acee-3bcd0221	
6957	User-Agent: wtnet/ngn (2)	
6958	Content-Length: 0	
6959		
6960		
6961	[2024-02-22 11:14:07] ERROR[1350][C-00000129] pbx_functions.c: Function SIP_HEADER not registered	
6962	[2024-02-22 11:14:07] VERBOSE[1350][C-00000129] pbx.c: Executing [s@from-pstn:3] Log("PJSIP/wt_teststellung-000001c7", "WARNING,Friendly Scanner from ") in new stack	
6963	[2024-02-22 11:14:07] WARNING[1350][C-00000129] Ext. s: Friendly Scanner from	
6964	[2024-02-22 11:14:07] VERBOSE[1350][C-00000129] pbx.c: Executing [s@from-pstn:4] Wait("PJSIP/wt_teststellung-000001c7", "2") in new stack	
6965	[2024-02-22 11:14:08] VERBOSE[3596] res_pjsip_logger.c: <--- Received SIP request (607 bytes) from UDP:192.168.4.30:59788 --->	
6966	OPTIONS sip:[email protected] SIP/2.0	
6967	v:SIP/2.0/UDP 192.168.4.30:59788;rport;branch=z9hG4bKpe5eK4ZSDKr7K	
6968	Max-Forwards:0	
6969	f:<sip:[email protected]>;tag=8KatDc29v8Q3H	
6970	t:<sip:[email protected]>	
6971	i:9YwWvQ05ytgGSS2kQNh2kf	
6972	CSeq:979395377 OPTIONS	
6973	s:KEEPALIVE	
6974	Accept:application/vnd.nokia-register-usage	
6975	Authorization:Digest username="6",realm="asterisk",nonce="1708596743/39bcb7b77fe0a79bf5b1deb72c291206",cnonce="trTud0wNEj2JvQBQVpfssg",opaque="20a4953479340309",algorithm=MD5,uri="sip:[email protected]",response="6614298e436463caf494c89c2e9da14b",qop=auth,nc=00000001	
6976	l:0	
6977		
6978		
6979	[2024-02-22 11:14:08] VERBOSE[18709] res_pjsip_logger.c: <--- Transmitting SIP response (512 bytes) to UDP:192.168.4.30:59788 --->	
6980	SIP/2.0 401 Unauthorized	
6981	Via: SIP/2.0/UDP 192.168.4.30:59788;rport=59788;received=192.168.4.30;branch=z9hG4bKpe5eK4ZSDKr7K	
6982	Call-ID: 9YwWvQ05ytgGSS2kQNh2kf	
6983	From: <sip:[email protected]>;tag=8KatDc29v8Q3H	
6984	To: <sip:[email protected]>;tag=z9hG4bKpe5eK4ZSDKr7K	
6985	CSeq: 979395377 OPTIONS	
6986	WWW-Authenticate: Digest realm="asterisk",nonce="1708596848/d52dd0ac28d3fd03c19b03c20d9a72c9",opaque="7ab150470fb6f604",stale=true,algorithm=MD5,qop="auth"	
6987	Server: FPBX-16.0.40.7(16.30.0)	
6988	Content-Length: 0	
6989		
6990		
6991	[2024-02-22 11:14:09] VERBOSE[12034] res_pjsip_logger.c: <--- Transmitting SIP request (412 bytes) to UDP:192.168.4.30:55003 --->	
6992	OPTIONS sip:[email protected]:55003 SIP/2.0	
6993	Via: SIP/2.0/UDP 192.168.4.30:5060;rport;branch=z9hG4bKPj1a9bfcd7-d031-46c6-a700-5cc1d1e6b047	
6994	From: <sip:[email protected]>;tag=33f15b1f-138b-44d3-84c6-cf48ff051a4a	
6995	To: <sip:[email protected]>	
6996	Contact: <sip:[email protected]:5060>	
6997	Call-ID: 89c894bd-f34e-41c2-b352-ba6782bf3a46	
6998	CSeq: 9229 OPTIONS	
6999	Max-Forwards: 70	
7000	User-Agent: FPBX-16.0.40.7(16.30.0)	
7001	Content-Length: 0	
7002		
7003		
7004	[2024-02-22 11:14:09] VERBOSE[3596] res_pjsip_logger.c: <--- Received SIP response (551 bytes) from UDP:192.168.4.30:55003 --->	
7005	SIP/2.0 200 OK	
7006	Via: SIP/2.0/UDP 192.168.4.30:5060;rport=5060;branch=z9hG4bKPj1a9bfcd7-d031-46c6-a700-5cc1d1e6b047	
7007	From: <sip:[email protected]>;tag=33f15b1f-138b-44d3-84c6-cf48ff051a4a	
7008	To: <sip:[email protected]>;tag=UgF0v5D07158a	
7009	Call-ID: 89c894bd-f34e-41c2-b352-ba6782bf3a46	
7010	CSeq: 9229 OPTIONS	
7011	Contact: 7 Testo Steron <sip:[email protected]:55003;transport=udp>	
7012	User-Agent: Janus WebRTC Server SIP Plugin 0.0.8	
7013	Accept: application/sdp	
7014	Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, REFER, MESSAGE, INFO, NOTIFY	
7015	Supported: replaces	
7016	Content-Length: 0	
7017		
7018		
7019	[2024-02-22 11:14:09] VERBOSE[1350][C-00000129] pbx.c: Executing [s@from-pstn:5] Playback("PJSIP/wt_teststellung-000001c7", "ss-noservice") in new stack	
7020	[2024-02-22 11:14:09] VERBOSE[1350][C-00000129] file.c: <PJSIP/wt_teststellung-000001c7> Playing 'ss-noservice.ulaw' (language 'de_DE')	
7021	[2024-02-22 11:14:13] VERBOSE[3596] res_pjsip_logger.c: <--- Received SIP request (540 bytes) from UDP:xxx.xxx.xxx.xxx:5060 --->

I believe that it should be
_+4912345678.
because the provider is sending the initial +, and you need “.” to match one or more characters; X matches only one.

Thank you @Stewart1. That does the Trick :+1:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.