How to set UDP timeout / UDP Persist-Connection in FreePBX?

Many other VOIP PBX systems have option to change UDP timeout. How to do it in FreePBX?

Explanation why this is needed here:
What do I do when my phones keep changing to Unreachable over time? (digium.com)

It’s not a PBX setting. As the article states, you can make a change on your router or firewall to allow longer UDP sessions. Or you could set your phones to issue keepalive messages (usually an empty packet or SIP OPTIONS) that are sent regularly enough from the phone to the PBX to keep the path open.

My remote phones have NAT keep alive interval set to 15 (when it was set to 25 there were more instances of reachable/unreachable) so it seems to be a good improvement; should it be lowered to 10 secs to further eliminate the issue?

You can try that. It seems like your NAT is very aggressively closing sessions. You might want to look into that setting on your router/firewall.

I don’t think you should be using dynamic NAT at all for the SIP signalling port, and possibly even not for the media port range.

I have 1-1 static NAT with ports forwarded at the PBX location
can you clarify that is what you mean?

Which means that your NAT timing out can’t be the problem, although there could also be dynamic firewall rules that should be made static.

What is the difference between:

[2022-08-25 03:42:41] VERBOSE[14037] res_pjsip/pjsip_options.c: Contact 123/sip:[email protected]:1025;x-ast-orig-host=10.0.20.36:42859 has been deleted
[2022-08-25 03:43:44] VERBOSE[6067] res_pjsip_registrar.c: Added contact 'sip:[email protected]:1025;x-ast-orig-host=10.0.20.36:42859' to AOR '123' with expiration of 30 seconds
[2022-08-25 03:43:44] VERBOSE[26855] res_pjsip/pjsip_options.c: Contact 123/sip:[email protected]:1025;x-ast-orig-host=10.0.20.36:42859 is now Reachable.  RTT: 40.940 msec

AND:

[2022-08-25 14:38:56] VERBOSE[26855] res_pjsip_registrar.c: Added contact 'sip:[email protected]:3313;rinstance=BAE2A60E;x-ast-orig-host=10.0.20.81:3313' to AOR '223' with expiration of 60 seconds
[2022-08-25 14:38:56] VERBOSE[16829] res_pjsip/pjsip_options.c: Contact 223/sip:[email protected]:3313;rinstance=BAE2A60E;x-ast-orig-host=10.0.20.81:3313 is now Reachable.  RTT: 179.194 msec
[2022-08-25 14:38:58] VERBOSE[25590] res_pjsip_registrar.c: Removed contact 'sip:[email protected]:3313;rinstance=BAE2A60E;x-ast-orig-host=10.0.20.81:3313' from AOR '223' due to request
[2022-08-25 14:38:58] VERBOSE[26855] res_pjsip/pjsip_options.c: Contact 223/sip:[email protected]:3313;rinstance=BAE2A60E;x-ast-orig-host=10.0.20.81:3313 has been deleted
[2022-08-25 14:38:59] VERBOSE[25590] res_pjsip/pjsip_options.c: Contact 223/sip:[email protected]:42859;x-ast-orig-host=10.0.20.147:42859 is now Unreachable.  RTT: 0.000 msec
[2022-08-25 14:54:15] VERBOSE[13863] res_pjsip_registrar.c: Added contact 'sip:[email protected]:42859;x-ast-orig-host=10.0.20.36:42859' to AOR '123' with expiration of 60 seconds
[2022-08-25 14:54:15] VERBOSE[16829] res_pjsip/pjsip_options.c: Contact 123/sip:[email protected]:42859;x-ast-orig-host=10.0.20.36:42859 is now Reachable.  RTT: 46.587 msec
[2022-08-25 14:54:18] VERBOSE[25590] res_pjsip/pjsip_options.c: Contact 123/sip:[email protected]:1025;x-ast-orig-host=10.0.20.36:42859 is now Unreachable.  RTT: 0.000 msec
[2022-08-25 14:54:30] VERBOSE[22261] res_pjsip_registrar.c: Added contact 'sip:[email protected]:1025;x-ast-orig-host=10.0.20.147:42859' to AOR '223' with expiration of 60 seconds
[2022-08-25 14:54:30] VERBOSE[16829] res_pjsip/pjsip_options.c: Contact 223/sip:[email protected]:42859;x-ast-orig-host=10.0.20.147:42859 is now Reachable.  RTT: 36.872 msec
[2022-08-25 14:54:30] VERBOSE[6041] res_pjsip/pjsip_options.c: Contact 223/sip:[email protected]:1025;x-ast-orig-host=10.0.20.147:42859 is now Reachable.  RTT: 44.479 msec
[2022-08-25 14:54:52] VERBOSE[31182] res_pjsip/pjsip_options.c: Contact 123/sip:[email protected]:1025;x-ast-orig-host=10.0.20.36:42859 has been deleted
[2022-08-25 14:55:04] VERBOSE[26855] res_pjsip/pjsip_options.c: Contact 223/sip:[email protected]:42859;x-ast-orig-host=10.0.20.147:42859 has been deleted

That’s a rather open question, but guessing at what you might be interested, I think it is whether or not there was anything registered at the time it tried to do a qualify test.

The reason I ask is because sometimes (first log paragraph), it doesn’t show unreachable and the phone flashes as unregistered, thene log shows contact deleted, added AOR, and then reachable again.
And then in the 2nd paragraph of logs above, it also displays Unreachable. So why is that showing unreachable as well and what is the most common cause for this sort of issue.

If the phone itself is displaying unregistered, it is most likely that the network lost all the attempts of the phone to re-register, and the registration expired.