Can't get sip trunk to register

I’ve purchased a sip trunk with OVH and it will not register on one of my pbx.
I was able to register the account on another pbx and 2 softphones, one of which is on the same network as the problematic pbx. The softphone that registered is zoiper and when checking the logs i have the following;

Account registering. Account = [email protected] don’t want to register
2016-03-31 14:26:46: Account file : Loading account file "AutoAccount.xml"
2016-03-31 14:26:55: Account waiting for default STUN discovery. Account = [email protected]
2016-03-31 14:27:05: Network discovered for STUN = stun.zoiper.com; Port restricted NAT (result = 5)
2016-03-31 14:27:05: Account registering. Account = [email protected]

Here are my trunk settings in freepbx;

outgoing:
trunk name: ovh
username=003xxxxxxxxx
type=friend
secret=password
qualify=yes
fromdomain=siptrunk.ovh.net
canreinvite=yes
bindport=5060
allow=all

incoming:
register string: 003xxxxxxxxxx:[email protected]

I’ve also changed the Asterisk sip settings to add my external ip in the NAT settings and the local network address

Log in the console;

Retransmitting #3 (NAT) to 91.121.129.23:5060:
REGISTER sip:siptrunk.ovh.net SIP/2.0
Via: SIP/2.0/UDP 192.168.1xx.x:5060;branch=z9hG4bK6971c03e;rport
Max-Forwards: 70
From: sip:[email protected];tag=as372d0f16
To: sip:[email protected]
Call-ID: [email protected][::1]
CSeq: 176 REGISTER
User-Agent: FPBX-13.0.95(11.21.2)
Expires: 120
Contact: sip:[email protected]:5060
Content-Length: 0


<— SIP read from UDP:91.121.129.23:5060 —>
SIP/2.0 401 Unauthorized
Call-ID: [email protected][0:0:0:0:0:0:0:1]
CSeq: 176 REGISTER
From: sip:[email protected];tag=as372d0f16
To: sip:[email protected];tag=00-07656-629103b2-1da1eea30
Via: SIP/2.0/UDP 192.168.1xx.x:5060;received=192.168.1xx.x;rport=5060;branch=z9hG4bK6971c03e
WWW-Authenticate: Digest realm=“siptrunk.ovh.net”,nonce=“6290f76f1852fc5a22e3e0075a297790”,opaque=“62905fb24fc51eb”,stale=false,algorithm=MD5
Server: Cirpack/v4.70 (gw_sip)
Content-Length: 0

@jmarc Is this a Chan_SIP trunk? By default Chan_SIP is binded to 5061 and Chan_PJSIP is on 5060. If you are trying to use a Chan_SIP trunk and you did not swap the bind ports in Asterisk SIP Settings then using 5060 isn’t going to work.

If OVH isn’t being a NAT then you need to set nat=no in the trunk settings.

Try that setting. Also, are you seeing the PBX respond to the 401 Unathorized challenge? Don’t see that in your debug details.

Made the change, still not working.

Here’s the debug;

[2016-03-31 20:54:13] NOTICE[1876]: chan_sip.c:15227 sip_reg_timeout: – Registration for ‘[email protected]’ timed out, trying again (Attempt #2)
Really destroying SIP dialog ‘[email protected][::1]’ Method: REGISTER

<— SIP read from UDP:91.121.129.23:5060 —>
SIP/2.0 100 Trying
Call-ID: [email protected][0:0:0:0:0:0:0:1]
CSeq: 103 REGISTER
From: sip:[email protected];tag=as1118c864
To: sip:[email protected]
Via: SIP/2.0/UDP 192.168.1xx.x:5060;received=192.168.1xx.x;rport=5060;branch=z9hG4bK0159a8ce
Content-Length: 0

<------------->
— (7 headers 0 lines) —

<— SIP read from UDP:91.121.129.23:5060 —>
SIP/2.0 401 Unauthorized
Call-ID: [email protected][0:0:0:0:0:0:0:1]
CSeq: 103 REGISTER
From: sip:[email protected];tag=as1118c864
To: sip:[email protected];tag=00-08144-62d11458-0c1ad0567
Via: SIP/2.0/UDP 192.168.170.8:5060;received=192.168.1xx.x;rport=5060;branch=z9hG4bK0159a8ce
WWW-Authenticate: Digest realm=“siptrunk.ovh.net”,nonce=“62d110603d59c3f2505164586f5b3ecb”,opaque=“62cb956d36c0b22”,stale=false,algorithm=MD5
Server: Cirpack/v4.70 (gw_sip)
Content-Length: 0

<------------->
— (9 headers 0 lines) —
Retransmitting #1 (NAT) to 91.121.129.23:5060:
REGISTER sip:siptrunk.ovh.net SIP/2.0
Via: SIP/2.0/UDP 192.168.1xx.x:5060;branch=z9hG4bK0159a8ce;rport
Max-Forwards: 70
From: sip:[email protected];tag=as1118c864
To: sip:[email protected]
Call-ID: [email protected][::1]
CSeq: 103 REGISTER
User-Agent: FPBX-13.0.95(11.21.2)
Expires: 120
Contact: sip:[email protected]:5060
Content-Length: 0

When you’re replying back to the challenge you are retransmitting via NAT to them. Double check your SIP Settings and also confirm what port Chan_SIP is on. Those updates were based on it being 5060.

First - Version information is really, really important when we try to help you.
Second - If you are using FreePBX with Asterisk 13, we need to identify how you are connecting. There are two choices: PJSIP and Chan-SIP.

It is perfectly reasonable to set up the system so that Chan-SIP is on 5060 and PJSIP is on 5061, or vice versa, or some other configuration, but not having the SIP module is pointed to the right port. You’ve never even told us if you are using Chan-SIP or PJSIP, so us sending you code to blindly use is more than useless, it’s a complete waste of everyone’s time.

SO…

What version information can you share with us?
Are you using PJSIP or Chan-SIP for your trunk connections?
How are your ports configured?
Are you running behind a firewall?
Have you set up the general SIP settings?
Have you set up the Chan-SIP (or PJSIP) specific configuration to handle you NAT (assuming you are using it)?
Is your firewall set up to redirect incoming port traffic on 5060 (or whatever inbound port you are using) to your PBX server?

401 Unauthorized means many things, but the most common are misspelled passwords or usernames.

All valid questions.
FPBX 10.13.66-1
Asterisk 11.21.2

Using Chan_sip trunk, can’t see option to add PJSIP
Yes pbx is behind firewall and nat was configured to route port 5060 UDP to the fpx server’s ip

General SIP settings:
allow anon inbound: yes
Ext address entered
Local network configured

chan_sip settings:
nat: yes
ip config: public ip
bind address: empty
Bind port: empty
Allow sip Guests: yes

Turn off anonymous inbound, especially if you are using port 5060. Allow SIP guests should be turned off as well. These are really dangerous (as in ridiculously expensive) if left on and the a$$wipes on the Internet find them.

On the SIP Settings page, the public address should be in the public address spot and the local address should contain your local (internal net) address, which it sounds like you are doing. With NAT turned on here, you should be fine.

NAT definitively needs to be on, but that is really critical only for outbound connections (this is how the remote machine figures out how to get your traffic back to you).

In your Trunk Configuration:
I’d leave “fromdomain=siptrunk.ovh.net” out unless OVH asks you to include it. “nat=yes” is required for your firewall.

I know lots of people here like the SIP debug output, but I find that the logs tell me what I need to know most of the time. Try posting the log entries for a SIP connection and let’s see what that tells us.

When you are setting up a SIP trunk to connect to the provider, the setting nat=yes/no is related to the endpoint you are connecting too. So when you have nat=yes in your trunk settings, you are telling the system “This trunk I’m registering to is behind NAT so I need to treat their data that way.”

Here’s what the asterisk/full log file says

[2016-04-04 20:01:23] ERROR[9590] phone_message.c: Unable to build dialplan routing - invalid license
[2016-04-04 20:01:23] WARNING[9590] res_digium_phone.c: No Valid DPMA License found. Module is loaded but disabled. Please reload module once valid license is installed.
[2016-04-04 20:01:23] VERBOSE[9590] loader.c: – Reloading module ‘res_fax.so’ (Generic FAX Applications)
[2016-04-04 20:01:23] VERBOSE[9590] config.c: == Parsing ‘/etc/asterisk/res_fax.conf’: Found
[2016-04-04 20:01:23] VERBOSE[9590] config.c: == Parsing ‘/etc/asterisk/res_fax_custom.conf’: Found
[2016-04-04 20:01:23] VERBOSE[9590] loader.c: – Reloading module ‘res_musiconhold.so’ (Music On Hold Resource)
[2016-04-04 20:01:23] VERBOSE[9590] config.c: == Parsing ‘/etc/asterisk/musiconhold.conf’: Found
[2016-04-04 20:01:23] VERBOSE[9590] config.c: == Parsing ‘/etc/asterisk/musiconhold_custom.conf’: Found
[2016-04-04 20:01:23] VERBOSE[9590] config.c: == Parsing ‘/etc/asterisk/musiconhold_additional.conf’: Found
[2016-04-04 20:01:23] VERBOSE[9590] loader.c: – Reloading module ‘res_odbc.so’ (ODBC resource)
[2016-04-04 20:01:23] VERBOSE[9590] config.c: == Parsing ‘/etc/asterisk/res_odbc.conf’: Found
[2016-04-04 20:01:23] VERBOSE[9590] config.c: == Parsing ‘/etc/asterisk/res_odbc_custom.conf’: Found
[2016-04-04 20:01:23] VERBOSE[9590] config.c: == Parsing ‘/etc/asterisk/res_odbc_additional.conf’: Found
[2016-04-04 20:01:23] NOTICE[9590] res_odbc.c: Connecting asteriskcdrdb
[2016-04-04 20:01:23] NOTICE[9590] res_odbc.c: res_odbc: Connected to asteriskcdrdb [MySQL-asteriskcdrdb]
[2016-04-04 20:01:23] NOTICE[9590] res_odbc.c: Registered ODBC class ‘asteriskcdrdb’ dsn->[MySQL-asteriskcdrdb]
[2016-04-04 20:01:23] VERBOSE[9590] loader.c: – Reloading module ‘res_phoneprov.so’ (HTTP Phone Provisioning)
[2016-04-04 20:01:23] VERBOSE[9590] config.c: == Parsing ‘/etc/asterisk/sip.conf’: Found
[2016-04-04 20:01:23] VERBOSE[9590] config.c: == Parsing ‘/etc/asterisk/sip_general_additional.conf’: Found
[2016-04-04 20:01:23] VERBOSE[9590] config.c: == Parsing ‘/etc/asterisk/sip_general_custom.conf’: Found
[2016-04-04 20:01:23] VERBOSE[9590] config.c: == Parsing ‘/etc/asterisk/sip_nat.conf’: Found
[2016-04-04 20:01:23] VERBOSE[9590] config.c: == Parsing ‘/etc/asterisk/sip_registrations_custom.conf’: Found
[2016-04-04 20:01:23] VERBOSE[9590] config.c: == Parsing ‘/etc/asterisk/sip_registrations.conf’: Found
[2016-04-04 20:01:23] VERBOSE[9590] config.c: == Parsing ‘/etc/asterisk/sip_custom.conf’: Found
[2016-04-04 20:01:23] VERBOSE[9590] config.c: == Parsing ‘/etc/asterisk/sip_additional.conf’: Found
[2016-04-04 20:01:23] VERBOSE[9590] config.c: == Parsing ‘/etc/asterisk/sip_custom_post.conf’: Found
[2016-04-04 20:01:23] WARNING[9590] res_phoneprov.c: Unable to load users.conf
[2016-04-04 20:01:23] VERBOSE[9590] loader.c: – Reloading module ‘res_rtp_asterisk.so’ (Asterisk RTP Stack)
[2016-04-04 20:01:23] VERBOSE[9590] config.c: == Parsing ‘/etc/asterisk/rtp.conf’: Found
[2016-04-04 20:01:23] VERBOSE[9590] config.c: == Parsing ‘/etc/asterisk/rtp_additional.conf’: Found
[2016-04-04 20:01:23] VERBOSE[9590] config.c: == Parsing ‘/etc/asterisk/rtp_custom.conf’: Found
[2016-04-04 20:01:23] VERBOSE[9590] res_rtp_asterisk.c: == RTP Allocating from port range 10000 -> 20000
[2016-04-04 20:01:43] NOTICE[1878] chan_sip.c: – Registration for ‘[email protected]’ timed out, trying again (Attempt #2)