Can't register/connect to an iQsim CR250 Gateway device

Good day everyone,
I am having a bit of a problem executing outbound calls from my FreePBX/Asterisk server to a mobile phone (for test purpouses I am using my own phone number, at this time) using an iQsim CR250 device. The device contains two working SIM cards whose Network connectivity was tested sending an SMS through an http request.
In order to communicate with the devide, I created a SIP trunk from my FreePBX server and I am using a softphone conntected to my PBX server to make the calls. The call starts, but my mobile phone never rings and, after a while, it stops giving out a warning “app_dial.c: Unable to create channel of type ‘SIP’ (cause 20 - Subscriber absent)”. I checked to see if I had any sip registered and it doesn’t look like it, although the peers I have are the following:

Name/username             Host                                    Dyn Forcerport Comedia    ACL Port     Status      Description
101/101                   xxx.xxx.xxx.xxx                           D  Yes        Yes         A  32569    OK (3 ms)
sip-trunk/administrator   yyy.yyy.yyy.yyy                              Yes        Yes            5160     UNREACHABLE
2 sip peers [Monitored: 1 online, 1 offline Unmonitored: 0 online, 0 offline]

where the first is my softphone (xxx.xxx.xxx.xxx is the IP of my FreeBPX server) and the second one is the trunk I created to connect to the devide (yyy.yyy.yyy.yyy is the IP address).
My sip.conf file is as follows:

[101] //softphone
deny=0.0.0.0/0.0.0.0
secret=seletech
dtmfmode=rfc2833
canreinvite=no
context=outbound
host=dynamic
defaultuser=
trustrpid=yes
user_eq_phone=no
sendrpid=pai
type=peer
session-timers=accept
nat=force_rport,comedia
port=5160
qualify=yes
qualifyfreq=60
transport=udp
avpf=no
force_avp=no
icesupport=no
rtcp_mux=no
encryption=no
namedcallgroup=
namedpickupgroup=
dial=SIP/101
accountcode=
permit=0.0.0.0/0.0.0.0
callerid=A6 <101>
recordonfeature=apprecord
recordofffeature=apprecord
callcounter=yes
faxdetect=no



[sip-trunk] //trunk
disallow=all
type=peer
host=yyy.yyy.yyy.yyy
username=usr
secret=psw
fromuser=usr
port=5160
qualify=yes
dtmfmode=rfc2833
canreinvite=no
allow=ulaw
allow=alaw
allow=gsm
insecure=port,invite
fromdomain=yyy.yyy.yyy.yyy
register=> usr:psw@yyy.yyy.yyy.yyy:5160
context=from-trunk-sip-sip-trunk

The dialplan I am using is the, instead:

[outbound]
exten => _X.,1,Dial(SIP/sip-trunk/${ESTEN})

Does anyone know how to connect to a device like this one? Which username and passwrd should I use? At hte moment I am using the ones needed to acces the configuration, but I also tried with the login and password of one of the users I created on the device configuration. I also turned on the sip debugging and I will leave the result below.

VERBOSE[2536] chan_sip.c: Reliably Transmitting (NAT) to yyy.yyy.yyy.yyy:5160:	
21403	OPTIONS sip:yyy.yyy.yyy.yyy SIP/2.0	
21404	Via: SIP/2.0/UDP xxx.xxx.xxx.xxx:5160;branch=z9hG4bK36931901;rport	
21405	Max-Forwards: 70	
21406	From: "Unknown" <sip:administrator@xxx.xxx.xxx.xxx:5160>;tag=as274bd0bc	
21407	To: <sip:yyy.yyy.yyy.yyy>	
21408	Contact: <sip:administrator@xxx.xxx.xxx.xxx:5160>	
21409	Call-ID: 656fc9067ef0e38009d24a57025d4bb9@xxx.xxx.xxx.xxx:5160	
21410	CSeq: 102 OPTIONS	
21411	User-Agent: FPBX-15.0.17.55(16.17.0)	
21412	Date: Wed, 10 Nov 2021 10:15:28 GMT	
21413	Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE	
21414	Supported: replaces, timer	
21415	Content-Length: 0	
21416		
21417		
21418	---	
21419	[2021-11-10 10:15:29] VERBOSE[2536] chan_sip.c: Retransmitting #1 (NAT) to yyy.yyy.yyy.yyy:5160:	
21420	OPTIONS sip:yyy.yyy.yyy.yyy SIP/2.0	
21421	Via: SIP/2.0/UDP xxx.xxx.xxx.xxx:5160;branch=z9hG4bK36931901;rport	
21422	Max-Forwards: 70	
21423	From: "Unknown" <sip:administrator@xxx.xxx.xxx.xxx:5160>;tag=as274bd0bc	
21424	To: <sipyyy.yyy.yyy.yyy>	
21425	Contact: <sip:administrator@xxx.xxx.xxx.xxx:5160>	
21426	Call-ID: 656fc9067ef0e38009d24a57025d4bb9@xxx.xxx.xxx.xxx:5160	
21427	CSeq: 102 OPTIONS	
21428	User-Agent: FPBX-15.0.17.55(16.17.0)	
21429	Date: Wed, 10 Nov 2021 10:15:28 GMT	
21430	Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE	
21431	Supported: replaces, timer	
21432	Content-Length: 0	
21433		
21434		
21435	---	
21436	[2021-11-10 10:15:30] VERBOSE[2536] chan_sip.c: Retransmitting #2 (NAT) to yyy.yyy.yyy.yyy:5160:	
21437	OPTIONS sip:yyy.yyy.yyy.yyy SIP/2.0	
21438	Via: SIP/2.0/UDP xxx.xxx.xxx.xxx:5160;branch=z9hG4bK36931901;rport	
21439	Max-Forwards: 70	
21440	From: "Unknown" <sip:administrator@xxx.xxx.xxx.xxx:5160>;tag=as274bd0bc	
21441	To: <sip:yyy.yyy.yyy.yyy>	
21442	Contact: <sip:administrator@xxx.xxx.xxx.xxx:5160>	
21443	Call-ID: 656fc9067ef0e38009d24a57025d4bb9@xxx.xxx.xxx.xxx:5160	
21444	CSeq: 102 OPTIONS	
21445	User-Agent: FPBX-15.0.17.55(16.17.0)	
21446	Date: Wed, 10 Nov 2021 10:15:28 GMT	
21447	Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE	
21448	Supported: replaces, timer	
21449	Content-Length: 0	
21450		
21451		
21452	---	
21453	[2021-11-10 10:15:31] VERBOSE[2536] chan_sip.c: Retransmitting #3 (NAT) to yyy.yyy.yyy.yyy:5160:	
21454	OPTIONS sip:yyy.yyy.yyy.yyy SIP/2.0	
21455	Via: SIP/2.0/UDP xxx.xxx.xxx.xxx:5160;branch=z9hG4bK36931901;rport	
21456	Max-Forwards: 70	
21457	From: "Unknown" <sip:administrator@xxx.xxx.xxx.xxx:5160>;tag=as274bd0bc	
21458	To: <sip:yyy.yyy.yyy.yyy>	
21459	Contact: <sip:administrator@xxx.xxx.xxx.xxx:5160>	
21460	Call-ID: 656fc9067ef0e38009d24a57025d4bb9@xxx.xxx.xxx.xxx:5160	
21461	CSeq: 102 OPTIONS	
21462	User-Agent: FPBX-15.0.17.55(16.17.0)	
21463	Date: Wed, 10 Nov 2021 10:15:28 GMT	
21464	Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE	
21465	Supported: replaces, timer	
21466	Content-Length: 0	
21467		
21468		
21469	---	
21470	[2021-11-10 10:15:32] VERBOSE[2536] chan_sip.c: Retransmitting #4 (NAT) to yyy.yyy.yyy.yyy:5160:	
21471	OPTIONS sip:yyy.yyy.yyy.yyy SIP/2.0	
21472	Via: SIP/2.0/UDP xxx.xxx.xxx.xxx:5160;branch=z9hG4bK36931901;rport	
21473	Max-Forwards: 70	
21474	From: "Unknown" <sip:administrator@xxx.xxx.xxx.xxx:5160>;tag=as274bd0bc	
21475	To: <sip:yyy.yyy.yyy.yyy>	
21476	Contact: <sip:administrator@xxx.xxx.xxx.xxx:5160>	
21477	Call-ID: 656fc9067ef0e38009d24a57025d4bb9@xxx.xxx.xxx.xxx:5160	
21478	CSeq: 102 OPTIONS	
21479	User-Agent: FPBX-15.0.17.55(16.17.0)	
21480	Date: Wed, 10 Nov 2021 10:15:28 GMT	
21481	Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE	
21482	Supported: replaces, timer	
21483	Content-Length: 0	
21484		
21485		
21486	---	
21487	[2021-11-10 10:15:32] VERBOSE[2536] chan_sip.c: Really destroying SIP dialog '656fc9067ef0e38009d24a57025d4bb9@10.181.233.205:5160' Method: OPTIONS	
21488	[2021-11-10 10:15:42] VERBOSE[2536] chan_sip.c: Reliably Transmitting (NAT) to 10.182.233.232:5160:	
21489	OPTIONS sip:yyy.yyy.yyy.yyy SIP/2.0	
21490	Via: SIP/2.0/UDP xxx.xxx.xxx.xxx:5160;branch=z9hG4bK10aa98d0;rport	
21491	Max-Forwards: 70	
21492	From: "Unknown" <sip:administrator@xxx.xxx.xxx.xxx:5160>;tag=as59ccdad0	
21493	To: <sip:yyy.yyy.yyy.yyy>	
21494	Contact: <sip:administrator@xxx.xxx.xxx.xxx:5160>	
21495	Call-ID: 667fb92608ad96e22da0225e2887f144@xxx.xxx.xxx.xxx:5160	
21496	CSeq: 102 OPTIONS	
21497	User-Agent: FPBX-15.0.17.55(16.17.0)	
21498	Date: Wed, 10 Nov 2021 10:15:42 GMT	
21499	Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE	
21500	Supported: replaces, timer	
21501	Content-Length: 0

Where xxx.xxx.xxx.xxx = PBX IP and yyy.yyy.yyy.yyy = GATEWAY IP

This is not the FreePBX support forum. That is https://community.freepbx.org/.

By SIP trunk it appears to mean a peer to which you register, which I believe is how FreePBX uses the term, although SIP has no concept of a trunk. (Outbound calls can, by definition only be from a SIP client, although calling the PABX a sever is a common error.)

The peer corresponding to sip-trunk is not replying to OPTIONS. Either its implementation of OPTIONS is broken (it should reply even if it doesn’t understand them, or there is not a complete round trip path (either the request or response is getting lost in transit). If its implementation of OPTIONS is broken, you should turn off qualify.

You haven’t provided sip show registry output, so I can’t tell if the register has worked. However, I’d note that register lines normally go in the general section and I’m not sure they would be recognized in a peer section.

You have a lot of indications of copy and paste coding, such as the use of obsolete parameter names and settings that are probably unnecessary and reduce security. I have to assume that both xxx.xxx.xxx.xxx and yyy.yyy.yyy.yyy are public addresses or both are on the same private network, as there is nothing to support outward NAT traversal.

It looks like you have re-keyed (incorrectly) the dialplan excerpt.

Please note that chan_sip is deprecated and scheduled for removal. Judging by your source port number, you seem to have both chan_sip and chan_pjsip installed and enabled, which often causes confusion.

Thanks for your answer! I will post this on the freepbx community for the questions regarding the trunk, but what do you mean the dialplan is incorrect? What I would like for it to happen, at a later stage of developement, is that I can create a channel from a softphone to the Gateway changing the mobile number dynamically. The line in the Asterisk CLI that I was planning on using is

Channel originate SIP/sip-trunk/number extension 101@from-internal

where the “number” will be changed every time I create a new channel. Do you think a command like this one would work, or am I missing something?

The return of the sip show registry is the following

Host                                    dnsmgr Username       Refresh State                Reg.Time
0 SIP registrations.

I was planning on using the chan_pjsip, but, from what I know, the gateway I have only receives a SIP trunk and I am not sure how it would work with a PJSIP trunk. That being said, it might bt worth a try.

It has a wildcard pattern, but doesn’t reference ${EXTEN} on the right hand side. That is rather unlikely. Moreover, it references ${ESTEN} which looks like it is a mistranscription of ${EXTEN}.

I also checked the source code, and “register” is definitely only recognized in the general section, not the peer specific section. I don’t know if FreePBX allows direct editing of the general section. However, even if not registered, you ought to get at least a forbidden response for the OPTIONS.

It has a wildcard pattern, but doesn’t reference ${EXTEN} on the right hand side. That is rather unlikely. Moreover, it references ${ESTEN} which looks like it is a mistranscription of ${EXTEN}.

Ah, yes, I apologize; I actually have my phone number there, at the moment, but ${EXTEN} is what I was planning on using when I finally make it work with my number, so that it should grab the extension I dial, correct?

I also checked the source code, and “register” is definitely only recognized in the general section, not the peer specific section. I don’t know if FreePBX allows direct editing of the general section. However, even if not registered, you ought to get at least a forbidden response for the OPTIONS.

I don’t seem to be able to modify the general section directly (all the ‘empty’ variables you see in the definition of the extensions are those that were not set from the interface), but I can put a registration string in the trunk definition

register=> usr:psw@yyy.yyy.yyy.yyy:5160

You are going to have to get help on this from the FreePBX people… The only code that recognizes “register” in chan_sip.c only looks in the general section. You might be able to use callbackextension, but you should research the details.

CORRECTED. regexten was wrong.