IP registration

Hi all, i have the problem with registration with the switch my friend to my asterisk
This is my configuration
OS Debian12 and ASTERISK 18.26.1


sip show peers
Name/username             Host                                    Dyn Forcerport Comedia    ACL Port     Status      Description
IP01                      X.X.X.X                               No         No             5060     OK (256 ms)
1 sip peers [Monitored: 1 online, 0 offline Unmonitored: 0 online, 0 offline]

sip show registry
Host                                    dnsmgr Username       Refresh State                Reg.Time
X.X.X.X:5060                      N      IP01               120 Rejected
1 SIP registrations.
ASTERISK01*CLI>
ASTERISK01*CLI> sip reload
 Reloading SIP
Reliably Transmitting (no NAT) to X.X.X.X:5060:
OPTIONS sip:X.X.X.X SIP/2.0
Via: SIP/2.0/UDP Z.Z.Z.Z:5060;branch=z9hG4bK3d699efd
Max-Forwards: 70
From: "asterisk" <sip:asterisk@Z.Z.Z.Z>;tag=as202c3abd
To: <sip:X.X.X.X>
Contact: <sip:asterisk@Z.Z.Z.Z:5060>
Call-ID: 265545667e6e7843475db7f77f58704a@Z.Z.Z.Z:5060
CSeq: 102 OPTIONS
User-Agent: gsm-gw-3.4.1
Date: Tue, 28 Jan 2025 12:10:35 GMT
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces, timer
Content-Length: 0


---
[2025-01-28 12:10:35] NOTICE[576]: chan_sip.c:15889 sip_reregister:    -- Re-registration for  IP01@X.X.X.X
REGISTER 11 headers, 0 lines
Reliably Transmitting (no NAT) to X.X.X.X:5060:
REGISTER sip:X.X.X.X SIP/2.0
Via: SIP/2.0/UDP Z.Z.Z.Z:5060;branch=z9hG4bK0d7ac6cf
Max-Forwards: 70
From: <sip:IP01@X.X.X.X>;tag=as2eeea158
To: <sip:IP01@X.X.X.X>
Call-ID: 6223d7ab1ec60f3519d1218b4c58575b@[fe80::f816:3eff:fe7d:5ec1]
CSeq: 103 REGISTER
Supported: replaces, timer
User-Agent: gsm-gw-3.4.1
Expires: 120
Contact: <sip:s@Z.Z.Z.Z:5060>
Content-Length: 0


---

<--- SIP read from UDP:X.X.X.X:5060 --->
SIP/2.0 404 Not Found
From: asterisk <sip:asterisk@Z.Z.Z.Z>;tag=as202c3abd
To: <sip:X.X.X.X>;tag=19a9b987-2afb8704-a44eb-7f5331293460-100007f-13c4-764
Call-ID: 265545667e6e7843475db7f77f58704a@Z.Z.Z.Z:5060
CSeq: 102 OPTIONS
Via: SIP/2.0/UDP Z.Z.Z.Z:5060;branch=z9hG4bK3d699efd
Content-Length: 0

<------------->
--- (7 headers 0 lines) ---
Really destroying SIP dialog '265545667e6e7843475db7f77f58704a@Z.Z.Z.Z:5060' Method: OPTIONS

<--- SIP read from UDP:X.X.X.X:5060 --->
SIP/2.0 404 Not Found
From: <sip:IP01@X.X.X.X>;tag=as2eeea158
To: <sip:IP01@X.X.X.X>;tag=5b295035-26cbb31a-a44eb-7f5331ab20f0-100007f-13c4-764
Call-ID: 6223d7ab1ec60f3519d1218b4c58575b@[fe80::f816:3eff:fe7d:5ec1]
CSeq: 103 REGISTER
Via: SIP/2.0/UDP Z.Z.Z.Z:5060;branch=z9hG4bK0d7ac6cf
Content-Length: 0

<------------->
--- (7 headers 0 lines) ---
[2025-01-28 12:10:36] WARNING[576]: chan_sip.c:24845 handle_response_register: Got 404 Not found on SIP register to service IP01@X.X.X.X, giving up
Really destroying SIP dialog '6223d7ab1ec60f3519d1218b4c58575b@[fe80::f816:3eff:fe7d:5ec1]' Method: REGISTER
ASTERISK01*CLI>

X.X.X.X is IP destination
Z.Z.Z.Z is my IP

This is my sip.conf

register => IP01:123456@X.X.X.X

;IP01
[IP01]
type = peer
host = X.X.X.X
context = tohost01
;secret=123456
trustrpid = yes
quality = yes
disallow = all
allow = alaw,g729
insecure = invite
nat = auto
dtmfmode = rfc2833

Where am I going wrong or this is the problem my friend?

The registrar doesn’t like your request. Most likely it is the To header. See bullet point 5, on the second page of RFC 3261 Section 10.3

As chan_sip is no longer supported, you should convert to chan_pjsip, consult with the operator of the remote system as to the correct format for that header’s URI, and set it as the client URI, in the type=registration section.

1 Like

I change to pjsip, but i have the problem with only IP authentication (without username and password)
Where i find the example?

Delete the type=registration and type=auth sections, and all references to them, from the second example, in res_pjsip Configuration Examples - Asterisk Documentation (although it is much better to actually understand the configuration and build it from first principles).

However, if you are using “IP authentication”, it doesn’t make sense to have a register line in your sip.conf, and it would explain why you are getting an error.

Also, in your sip.conf, note that insecure=invite does nothing, if you don’t have a secret. It says don’t challenge the peer for its knowledge of the secret, but that can’t happen if there is no secret.

(There should only be references to the type=auth section.)

I change but dont work.
This is the minimal file pjsip

[IP01]
type = endpoint
context = tohost01
allow = !all,alaw
aors = IP01

[IP01]
type = aor
contact = sip:X.X.X.X

[IP01]
type = identify
match = X.X.X.X

And this is the error in console

pjsip reload
Module 'res_pjsip.so' reloaded successfully.
Module 'res_pjsip_authenticator_digest.so' reloaded successfully.
Module 'res_pjsip_endpoint_identifier_ip.so' reloaded successfully.
Module 'res_pjsip_mwi.so' reloaded successfully.
Module 'res_pjsip_notify.so' reloaded successfully.
Module 'res_pjsip_outbound_publish.so' reloaded successfully.
Module 'res_pjsip_publish_asterisk.so' reloaded successfully.
Module 'res_pjsip_outbound_registration.so' reloaded successfully.
    -- Reloading module 'res_pjsip.so' (Basic SIP resource)
[2025-01-29 07:42:13] ERROR[4961]: res_pjsip_endpoint_identifier_ip.c:518 ip_identify_apply: Identify 'IP01' missing required endpoint name.
[2025-01-29 07:42:13] ERROR[4961]: res_sorcery_config.c:422 sorcery_config_internal_load: Could not create an object of type 'identify' with id 'IP01' from configuration file 'pjsip.conf'
[2025-01-29 07:42:13] NOTICE[4961]: sorcery.c:1348 sorcery_object_load: Type 'system' is not reloadable, maintaining previous values
    -- Reloading module 'res_pjsip_authenticator_digest.so' (PJSIP authentication resource)
    -- Reloading module 'res_pjsip_endpoint_identifier_ip.so' (PJSIP IP endpoint identifier)
[2025-01-29 07:42:13] ERROR[648]: res_pjsip_endpoint_identifier_ip.c:518 ip_identify_apply: Identify 'IP01' missing required endpoint name.
[2025-01-29 07:42:13] ERROR[648]: res_sorcery_config.c:422 sorcery_config_internal_load: Could not create an object of type 'identify' with id 'IP01' from configuration file 'pjsip.conf'
    -- Reloading module 'res_pjsip_mwi.so' (PJSIP MWI resource)
    -- Reloading module 'res_pjsip_notify.so' (CLI/AMI PJSIP NOTIFY Support)
    -- Reloading module 'res_pjsip_outbound_publish.so' (PJSIP Outbound Publish Support)
    -- Reloading module 'res_pjsip_publish_asterisk.so' (PJSIP Asterisk Event PUBLISH Support)
    -- Reloading module 'res_pjsip_outbound_registration.so' (PJSIP Outbound Registration Support)

Fairly self explanatory, I would say. Especially if you look at the example I referenced.

I dont know what is the problem

I change sip to pjsip and this is the configuration

[IP01]
type = registration
retry_interval = 30
max_retries = 0
expiration = 120
transport = transport-udp
outbound_auth = IP01
client_uri = sip:IP01@X.X.X.X
server_uri = sip:X.X.X.X

[IP01]
type = auth
;password = 123456
;username = IP01

[IP01]
type = aor
contact = sip:X.X.X.X
maximum_expiration = 3600
default_expiration = 120

[IP01]
type = identify
endpoint = IP01
match = X.X.X.X

[IP01]
type = endpoint
context = tohost01
dtmf_mode = rfc4733
disallow = all
allow = ulaw
allow = alaw
allow = g729
allow = gsm
force_rport = yes
rewrite_contact = yes
direct_media = no
trust_id_inbound = yes
language = en
aors = IP01

I need only IP, but i have this answer in console

 res_pjsip_outbound_registration.c:1383 handle_registration_response: Fatal response '404' received from 'sip:X.X.X.X' on registration attempt to 'sip:IP01@X.X.X.X', stopping outbound registration

and

 IP01/sip:X.X.X.X                                 IP01                        Rejected          (exp. 2s ago)

Can i check ?

Please read what I wrote. If you have “IP authentication” you will not be expected to register,so don’t try.

I delete sections registration and auth.
But when create the call to X.X.X.X i have this answer

Call failed to go through, reason (0) Call Failure (not BUSY, and not NO_ANSWER, maybe Circuit busy or down?)

This is the answer to
pjsip show endpoints

Endpoint:  IP01                                                 Not in use    0 of inf
        Aor:  IP01                                               0
      Contact:  IP01/sip:X.X.X.X                     48318e025e NonQual         nan
   Identify:  IP01/IP01
        Match: X.X.X.X/32

and this is for
pjsip show aors

 Aor:  IP01                                                 0
    Contact:  IP01/sip:X.X.X.X                       48318e025e NonQual         nan

without registration and authentication the pjsip show dont have answer

Please provide the logs.

What log?
full or message?

Full, with “pjsip set logger on” in effect, and verbosity at least 3.

This is only this

ASTERISK01*CLI>
<--- Received SIP request (367 bytes) from UDP:194.164.107.6:56643 --->
OPTIONS sip:SZuBzXLS@15.235.192.70 SIP/2.0
Via: SIP/2.0/UDP 194.164.107.6:56643;branch=PIGdoW.5349240411;rport;alias
From: sip:fioputPM@194.164.107.6:56643;tag=95251984
To: sip:oEyfJmyS@15.235.192.70
Call-ID: 3593060882@194.164.107.6
CSeq: 1 OPTIONS
Contact: sip:VHFcKFQp@194.164.107.6:56643
Content-Length: 0
Max-Forwards: 20
User-Agent: JpyxPeRX
Accept: text/plain

[2025-01-31 12:44:37] NOTICE[6753]: res_pjsip/pjsip_distributor.c:673 log_failed_request: Request 'OPTIONS' from '<sip:fioputPM@194.164.107.6>' failed for '194.164.107.6:56643' (callid: 3593060882@194.164.107.6) - No matching endpoint found
<--- Transmitting SIP response (477 bytes) to UDP:194.164.107.6:56643 --->
SIP/2.0 401 Unauthorized
Via: SIP/2.0/UDP 194.164.107.6:56643;rport=56643;received=194.164.107.6;branch=PIGdoW.5349240411;alias
Call-ID: 3593060882@194.164.107.6
From: <sip:fioputPM@194.164.107.6>;tag=95251984
To: <sip:oEyfJmyS@15.235.192.70>;tag=PIGdoW.5349240411
CSeq: 1 OPTIONS
WWW-Authenticate: Digest realm="asterisk",nonce="1738327477/fc1b410b8e6acb25575810b506e3b003",opaque="3ba4048f43440eed",algorithm=MD5,qop="auth"
Server: gsm-gw-3.4.1
Content-Length:  0


ASTERISK01*CLI>

But not is my IP the destination

Where does this come from? I was expecting to see it, in the logs, with the surrounding context

My switch need connection to X.X.X.X

This is the log when send the call
Z.Z.Z.Z. is my IP
X.X.X.X is IP where i want send the call

ASTERISK01*CLI>
    -- Attempting call on PJSIP/IP01 for 675884515@tohost01:1 (Retry 1)
    -- Called IP01
<--- Transmitting SIP request (987 bytes) to UDP:X.X.X.X:5060 --->
INVITE sip:X.X.X.X SIP/2.0
Via: SIP/2.0/UDP Z.Z.Z.Z:5060;rport;branch=z9hG4bKPj8ec24094-3593-4218-bb16-f4a5d2574aa0
From: <sip:675884515@Z.Z.Z.Z>;tag=000d6d55-ebba-418e-ac57-e9e897785593
To: <sip:X.X.X.X>
Contact: <sip:asterisk@Z.Z.Z.Z:5060>
Call-ID: d2b87206-dc96-49e8-a9c4-088dcc121dc5
CSeq: 22854 INVITE
Allow: OPTIONS, REGISTER, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, MESSAGE, INFO, REFER
Supported: 100rel, timer, replaces, norefersub, histinfo
Session-Expires: 1800
Min-SE: 90
Max-Forwards: 70
User-Agent: gsm-gw-3.4.1
Content-Type: application/sdp
Content-Length:   333

v=0
o=- 1656788661 1656788661 IN IP4 Z.Z.Z.Z
s=Asterisk
c=IN IP4 Z.Z.Z.Z
t=0 0
m=audio 25300 RTP/AVP 0 8 18 3 101
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:18 G729/8000
a=fmtp:18 annexb=no
a=rtpmap:3 GSM/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=ptime:20
a=maxptime:140
a=sendrecv

<--- Received SIP response (373 bytes) from UDP:X.X.X.X:5060 --->
SIP/2.0 404 Not Found
From: <sip:675884515@Z.Z.Z.Z>;tag=000d6d55-ebba-418e-ac57-e9e897785593
To: <sip:X.X.X.X>;tag=27abbfc8-7622d77a-e971c-7f5331928510-100007f-13c4-764
Call-ID: d2b87206-dc96-49e8-a9c4-088dcc121dc5
CSeq: 22854 INVITE
Via: SIP/2.0/UDP Z.Z.Z.Z:5060;rport=5060;branch=z9hG4bKPj8ec24094-3593-4218-bb16-f4a5d2574aa0
Content-Length: 0


<--- Transmitting SIP request (418 bytes) to UDP:X.X.X.X:5060 --->
ACK sip:X.X.X.X SIP/2.0
Via: SIP/2.0/UDP Z.Z.Z.Z:5060;rport;branch=z9hG4bKPj8ec24094-3593-4218-bb16-f4a5d2574aa0
From: <sip:675884515@Z.Z.Z.Z>;tag=000d6d55-ebba-418e-ac57-e9e897785593
To: <sip:X.X.X.X>;tag=27abbfc8-7622d77a-e971c-7f5331928510-100007f-13c4-764
Call-ID: d2b87206-dc96-49e8-a9c4-088dcc121dc5
CSeq: 22854 ACK
Max-Forwards: 70
User-Agent: gsm-gw-3.4.1
Content-Length:  0


[2025-01-31 18:50:20] NOTICE[10024]: pbx_spool.c:450 attempt_thread: Call failed to go through, reason (0) Call Failure (not BUSY, and not NO_ANSWER, maybe Circuit busy or down?)
ASTERISK01*CLI>

You haven’t sent any digits, but you are saying you are talking to a switch not a phone, so you will need to supply digits for the onward routing. 404 is number unobtainable (i.e. not known), and you are probably getting it because the number is empty.

You haven’t the contents of the call file, or whatever writes it.

Generally you seem to be providing too little information, too late.

How check if my trunk is connected?

Sorry, but I don’t understand the question in the context of the rest of this thread. By trunk, do you mean Internet Telephony Service Provider (ITSP), as trunk is not a term used by SIP or Asterisk? By connected, do you mean two way communication is possible, or do you mean a session has been established?

You have two way communication with X.X.X.X8:5060. You are not managing to establish a session with it, as it is saying that the number you are calling does not exist (which, as I said above, is because you haven’t actually provided a number).

Reposting out of sequence, because I’ve been asked to redact part of this.