Some amount of time peer gets unreachable?

Why some amount of time peer gets unreachable?(1 or 2 minutes around).

are the peers remote - meaning on the other side of the firewall from the pbx? if yes there is a good chance your firewall is killing the udp session too early.

Yes. One of them wan side of the router. Another peer is same local network with asterisk, lan side of the router.
I don’t use firewall, I use router. Firewall was turned off in routers setting.

Frequently this message is displayed:
NOTICE[8567]: chan_sip.c:29343 sip_poke_noanswer: Peer ‘502’ is now UNREACHABLE! Last qualify: 25

How can I fix that problem?

That is (almost always) a network issue. If you look through the /var/log/asterisk/full log for the same time period, you’ll probably see the phone “unreachable” messages as well.

I had this when my FreePBX VM was on a very slow disk array as well.

my guess is that the router is shutting down the udp session. find the session timer and increase it to be higher than 60 seconds or what ever you have the qual time set to. a quick way to test this is to change the qual time on the extension to be 25 seconds (many older routers used 30 seconds as the udp timeout). if the phones stay registered then find the udp timer in your router and increase it.

Phone is registering easily but unreachable frequently(now registered before 30 minutes but never become a reachable!!).
If there was a network problem so it could not be register so easily.
How can i detect exact reason of my problem?

Now i am watching OPTION packets of Asterisk. My asterisk behind NAT. But when asterisk sends option packets to my IP phone (ip phone is another public ip address and under tha nat) asterisk writes its local ip address to OPTION packets so Ip phone. 192.168.150.90 is the Asterisk’s local ip. Here asterisk’s option packet:
IP phone public ip: 213.22.222.222
Asterisk public ip: 213.11.111.111

No. Time Source Destination Protocol Length Info
1 0.000000 213.11.111.111 192.168.20.166 SIP 605 Request: OPTIONS sip:[email protected]:5082 |

Frame 1: 605 bytes on wire (4840 bits), 605 bytes captured (4840 bits)
Ethernet II, Src: Tp-LinkT_5f:6f:54 (10:fe:ed:5f:6f:54), Dst: 00:a8:59:d1:9e:b2 (00:a8:59:d1:9e:b2)
Internet Protocol Version 4, Src: 213.11.111.111 (213.11.111.111), Dst: 192.168.20.166 (192.168.20.166)
User Datagram Protocol, Src Port: 5061 (5061), Dst Port: 5082 (5082)
Session Initiation Protocol (OPTIONS)
Request-Line: OPTIONS sip:[email protected]:5082 SIP/2.0
Message Header
Via: SIP/2.0/UDP 192.168.150.90:5061;branch=z9hG4bK15c4adca
Max-Forwards: 70
From: “Unknown” sip:[email protected]:5061;tag=as703c69cf
SIP Display info: "Unknown"
SIP from address: sip:[email protected]:5061
SIP from tag: as703c69cf
To: sip:[email protected]:5082
SIP to address: sip:[email protected]:5082
Contact: sip:[email protected]:5061
Contact URI: sip:[email protected]:5061
Call-ID: [email protected]:5061
CSeq: 102 OPTIONS
User-Agent: FPBX-13.0.99(13.8.0)
Date: Thu, 30 Jun 2016 07:50:32 GMT
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces, timer
Content-Length: 0

i am assuming that you have double checked your sip settings in the pbx and have built the proper config for the phone and that you have nat enabled on the extension setting.

this may also be an issue in your router/firewall. assuming you have the port forwards in place, the phone will register correctly but then 30 seconds later the router closes the udp session between the phone and the pbx. neither end knows that the session has been closed. the pbx will “ping” the phone at the 60 second interval and will discover that the phone is no longer reachable. most phones are configured to periodically register - for example the default value on a polycom is one hour. this means that if the router closes the session (as i think it is doing), then the phone will about an hour later will pop back up online for a short time.
as i said an easy way to test this is to reduce the qual time setting for the extension to 25 seconds.

I have not any session timer in my CPE(customer premises equipment).
You mean for double checking that I must change either general sip setting’s nat as yes or nat setting of any extension as yes?
General nat=yes or extension nat=yes. I should not make both of them nat=yes at the same time?

the settings are fine. try reducing the qualification timer in the extension settings from 60 to 25 and see if the extension stays registered. if it does, then you do need to dig into your cpe stuff. out of curiosity, what router are u using?

TP-LINK brand.
TP-W741ND

Today I will change qualify freq. from 60 to 25.

Problem is the same. Nothing is changed.
It can be problem about ip phone implementation bug?

Many phones now support Open VPN and it is built into the distro

With a VPN you will not have any of these issues

Go into your router and turn off the SIP ALG. It’s under Advanced settings or something.

Can you explain me how to use VPN method?
Where will be locate VPN server?
In this case Vpn client will be ip phone.
Can you give me detailed information?
I must install any VPN server on my machine?
My phone must support VPN client?