SIP Trunk UNREACHABLE (but registered)

Hello,
I’m using Asterisk 11 with my SIP provider since years without problem, but now, I want to add another SIP provider (Movistar Spain).
This provider is my ISP, that offers telephone via VoIP, and I think it’s interesting use it in my Asterisk.
This provider uses a outboundproxy, and it’s the only difference between this new SIP provider.
I’ve connected my Asterisk directly to the router, because it uses VLAN’s for VoIP, ipTV, and Internet.
This is my trunk configuration in sip.con:

[movistar]
type=peer
username=96XXXXXXX
fromuser=96XXXXXXX
secret=96XXXXXXX
fromdomain=telefonica.net
host=10.31.255.134
outboundproxy=10.31.255.134
outboundproxyport=5070
port=5070
nat=force_rport,comedia
insecure=port,invite
dtmfmode=auto
disallow=all
allow=ulaw
allow=alaw
context=casa
qualify=yes
trustpid=yes

And I register it with:

register => 96XXXXXXX@telefonica.net:96XXXXXXX@10.31.255.134:5070/96XXXXXXX

The problem is that I’m registered, but UNREACHABLE:

sip show registry
Host                                    dnsmgr Username       Refresh State                Reg.Time                
10.31.255.134:5070                      N      96XXXXXXX@te        55 Registered           Tue, 01 Aug 2017 11:42:07

If i try to do a UPD connection, it works:

nc -u 10.31.255.134 5070
REGISTER sip:telefonica.net SIP/2.0
SIP/2.0 400 Missing CSeq Header
CSeq: 0 REGISTER

And with wireshark I can see the REGISTER call:

35   5.503121   172.28.12.120   10.31.255.134   SIP   431   Request: REGISTER sip:telefonica.net  (1 binding) | 93   16.794847   10.31.255.134   172.28.12.120   SIP   679   Status: 200 OK  (2 bindings) | 

But all the requests OPTIONS are ko:

2   0.203298   172.28.12.120   213.4.130.95   SIP   581   Request: OPTIONS sip:telefonica.net | 122   21.085087   172.28.12.120   213.4.130.95   SIP   581   Request: OPTIONS sip:telefonica.net | 

In fact, there are only outbounding calls to my provider (telefonica.net (213.4.130.95)), but not incoming calls (replies). I only can see timeouts in Asterisk:

    <--- SIP read from UDP:10.31.255.134:5070 --->SIP/2.0 408 Request Timeout 020351913
    Via: SIP/2.0/UDP 172.28.12.120:5060;received=10.26.129.182;branch=z9hG4bK251cff65;rport=5060
    From: "asterisk" <sip:96XXXXXXX@172.28.12.120>;tag=as1d6418e4
    To: <sip:10.31.255.134>;tag=0ccde71601b7bb0790caa95ddd7af3cf
    Call-ID: 45230ebd151c840c37a16bc36ff9a16b@172.28.12.120:5060
    CSeq: 102 OPTIONS
    Content-Length: 0

Anyone can help me?
Regards

Attach router voip configuration screenshot:


If I try to configure it since my Android, it works (CSipSipmple). :sob:

If OPTIONS don’t get through, you will need to disable qualify.

Yes, but with qualify disabled, the error persist.

-- Called SIP/6XXXXXXXX@movistar
[Aug  1 21:58:19] WARNING[2392]: chan_sip.c:4175 retrans_pkt: Retransmission timeout reached on transmission 5cbf239e10fa211d1d2a9e1f5da1d692@telefonica.net for seqno 102 (Critical Request) -- See https://wiki.asterisk.org/wiki/display/AST/SIP+Retransmissions
Packet timed out after 32000ms with no response
[Aug  1 21:58:19] WARNING[2392]: chan_sip.c:4204 retrans_pkt: Hanging up call 5cbf239e10fa211d1d2a9e1f5da1d692@telefonica.net - no reply to our critical packet (see https://wiki.asterisk.org/wiki/display/AST/SIP+Retransmissions).

Which packet is being timed out?

Are the correct contact headers being sent and received?

I think it’s my call, because it found a CHANUNAVAIL:

�INVITE sip:6XXXXXXXX@10.31.255.134:5070 SIP/2.0
�Via: SIP/2.0/UDP 172.28.12.120:5060;branch=z9hG4bK1b102cc8;rport
�Max-Forwards: 70
�From: "Clemente Casa" <sip:96XXXXXXX@telefonica.net>;tag=as716e862f
�To: <sip:6XXXXXXXX@10.31.255.134:5070>
�Contact: <sip:96XXXXXXX@172.28.12.120:5060>
�Call-ID: 54a7515d6f544fdb7d0fa4060188eced@telefonica.net
�CSeq: 102 INVITE
�User-Agent: Asterisk PBX
�Date: Thu, 03 Aug 2017 10:46:19 GMT
�Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
�Supported: replaces, timer
�Content-Type: application/sdp
�Content-Length: 277
[Aug  3 12:46:50] DEBUG[2392] chan_sip.c: Trying to put 'INVITE sip:' onto UDP socket destined for 10.31.255.134:5060
[Aug  3 12:46:51] WARNING[2392] chan_sip.c: Retransmission timeout reached on transmission 54a7515d6f544fdb7d0fa4060188eced@telefonica.net $
Packet timed out after 32000ms with no response
[Aug  3 12:46:51] WARNING[2392] chan_sip.c: Hanging up call 54a7515d6f544fdb7d0fa4060188eced@telefonica.net - no reply to our critical pack$
[Aug  3 12:46:51] DEBUG[2392] chan_sip.c: Setting SIP_ALREADYGONE on dialog 54a7515d6f544fdb7d0fa4060188eced@telefonica.net
[Aug  3 12:46:51] DEBUG[9862][C-0000002e] channel.c: Hanging up channel 'SIP/movistar-00000051'
[Aug  3 12:46:51] DEBUG[9862][C-0000002e] chan_sip.c: Hangup call SIP/movistar-00000051, SIP callid 54a7515d6f544fdb7d0fa4060188eced@telefo$
[Aug  3 12:46:51] DEBUG[9862][C-0000002e] chan_sip.c: Hanging up channel in state Down (not UP)
[Aug  3 12:46:51] DEBUG[9862][C-0000002e] res_rtp_asterisk.c: Setting RTCP address on RTP instance '0x23d93b4'
[Aug  3 12:46:51] DEBUG[9862][C-0000002e] app_dial.c: Exiting with DIALSTATUS=CHANUNAVAIL.
[Aug  3 12:46:51] DEBUG[9862][C-0000002e] pbx.c: Result of 'DIALSTATUS' is 'CHANUNAVAIL'
[Aug  3 12:46:51] DEBUG[9862][C-0000002e] pbx.c: Expression result is '0'
[Aug  3 12:46:51] DEBUG[9862][C-0000002e] pbx.c: Result of 'DIALSTATUS' is 'CHANUNAVAIL'
[Aug  3 12:46:51] DEBUG[9862][C-0000002e] pbx.c: Expression result is '0'
[Aug  3 12:46:51] DEBUG[9862][C-0000002e] pbx.c: Expression result is '0'
[Aug  3 12:46:51] DEBUG[9862][C-0000002e] pbx.c: Launching 'GotoIf'
[Aug  3 12:46:51] DEBUG[9862][C-0000002e] pbx.c: Not taking any branch
[Aug  3 12:46:51] DEBUG[9862][C-0000002e] pbx.c: Launching 'Hangup'
[Aug  3 12:46:51] DEBUG[9862][C-0000002e] channel.c: Soft-Hanging up channel 'SIP/601-00000050'
[Aug  3 12:46:51] DEBUG[9862][C-0000002e] pbx.c: Spawn extension (casa,6XXXXXXXX,4) exited non-zero on 'SIP/601-00000050'
[Aug  3 12:46:51] DEBUG[9862][C-0000002e] channel.c: Soft-Hanging up channel 'SIP/601-00000050'
[Aug  3 12:46:51] DEBUG[9862][C-0000002e] channel.c: Hanging up channel 'SIP/601-00000050'
[Aug  3 12:46:51] DEBUG[9862][C-0000002e] chan_sip.c: Hangup call SIP/601-00000050, SIP callid 142965194@172.28.12.121
[Aug  3 12:46:51] DEBUG[9862][C-0000002e] chan_sip.c: Hanging up channel in state Ring (not UP)
[Aug  3 12:46:51] DEBUG[9862][C-0000002e] res_rtp_asterisk.c: Setting RTCP address on RTP instance '0xb434355c'
[Aug  3 12:46:51] VERBOSE[9862][C-0000002e] chan_sip.c: Scheduling destruction of SIP dialog '142965194@172.28.12.121' in 8320 ms (Method: $
[Aug  3 12:46:51] VERBOSE[9862][C-0000002e] chan_sip.c:
�<--- Reliably Transmitting (NAT) to 172.28.12.121:5063 --->
�SIP/2.0 408 Request Timeout
�Via: SIP/2.0/UDP 172.28.12.121:5063;branch=z9hG4bK2319037921;received=172.28.12.121;rport=5063
�From: "Casa Cle" <sip:601@172.28.12.120>;tag=907508186
�To: <sip:6XXXXXXXX@172.28.12.120>;tag=as49ba119a
�Call-ID: 142965194@172.28.12.121
�CSeq: 2 INVITE
�Server: Asterisk PBX
�Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
�Supported: replaces, timer
�Content-Length: 0
�
�
�<------------>
[Aug  3 12:46:51] DEBUG[9862][C-0000002e] chan_sip.c: *** SIP TIMER: Initializing retransmit timer on packet: Id  #347041
[Aug  3 12:46:51] DEBUG[9862][C-0000002e] chan_sip.c: Trying to put 'SIP/2.0 408' onto UDP socket destined for 172.28.12.121:5063
[Aug  3 12:46:51] DEBUG[2392] chan_sip.c: Destroying SIP dialog 54a7515d6f544fdb7d0fa4060188eced@telefonica.net
[Aug  3 12:46:51] VERBOSE[2392] chan_sip.c: Really destroying SIP dialog '54a7515d6f544fdb7d0fa4060188eced@telefonica.net' Method: INVITE
[Aug  3 12:46:51] DEBUG[2392] rtp_engine.c: Destroyed RTP instance '0x23d93b4'
[Aug  3 12:46:51] DEBUG[2186] devicestate.c: No provider found, checking channel drivers for SIP - movistar
[Aug  3 12:46:51] DEBUG[2186] chan_sip.c: Checking device state for peer movistar
[Aug  3 12:46:51] DEBUG[2186] devicestate.c: Changing state for SIP/movistar - state 1 (Not in use)
[Aug  3 12:46:51] DEBUG[2186] devicestate.c: device 'SIP/movistar' state '1'
[Aug  3 12:46:51] DEBUG[2405] app_queue.c: Device 'SIP/movistar' changed to state '1' (Not in use) but we don't care because they're not a $

172.28.12.120 is the Asterisk server, and 172.28.12.121 is the extension from i’m triying to call to the PSTN (6XXXXXXXX).

It is not just OPTIONS that is not getting through. INVITE, or the response isn’t, either.

You need to trace through your network and find where the request or response is getting lost.

CHANUNAVAIL was a secondary symptom of the underlying network problem.

First of all, thanks @david551 for your help.
Opening the dump with wireshark, I can see this:

  1. The extension (.121) request a INVITE to the Asterisk server (.120), to origin the call.
  2. Asterisk return a Unauthorized (I don’t know why)
  3. Asterisk request a INVITE to the SIP proxy (and the EXTENSION proxy)
  4. No responses from SIP trunk

Finally, Asterisk return timeout to the extension:

That unauthorised is completely normal for any peer that needs to be authenticated.

The rest doesn’t provide any more information other than the debugging, assuming that the packet capture was run on the machine running Asterisk. You need to find at which hop in the network the INVITE gets lost, or at which point the 401 from the ITSP gets lost. You know that is happening outside of the Asterisk machine.

Can you confirm that you do have suitable port forwarding on your NAT device? Also that you all your firewalls are set to pass SIP/UDP.

Hi,
it’s not problem with the NAT or the firewall, because I can use without problem my other SIP trunk, and, if I open CSIPSimple in my Android device, and connected to the router, I can register and make (and receive calls) from it.
The problem is the Asterisk configuration, because the LAN is the same, for that reason, I cannot found the solution.
Obviously, the dump was run on the Asterisk server.
I’m a bit crazy, I don’t know what happen, if it was a problem with the LAN, the softphones would not work…
Regards