Trunk registration fail

Hi,
I have a problem with the trunk registration on my asterisk.
I have Asterisk 11.4.0 version and I use freepbx 2.11.0

This trunk worked but I maybe changed some configuration because the sip show registry show me that he is not registered. This is my configuration on freepbx, I have the same configuration on an other server and that works, and If I try to register the sip account directly on a softphone it also works.

host=freephonie.net
username=mynumber
secret=mysecret
type=peer
qualify=yes
fromdomain=freephonie.net
dtmfmode=auto
context=from-trunk
disallow=all
allow=ulaw&alaw
canreinvite=no

Register String
mynumber:mysecret@freephonie.net

I only add on the sip configuration settings defaultexpiry = 1800, that is required for my provider.

this is the output of the sip debug when I try to start a call

SIP/2.0 403 not registered
Call-ID: 3345d1520a2ca63a7faba86812510848@freephonie.net
CSeq: 102 INVITE
From: sip:mynumber@freephonie.net;tag=as5a97f546
To: sip:destinationnumber@freephonie.net;tag=00-32608-01763f49-7baaee754
Via: SIP/2.0/UDP myexternalip:5060;received=myexternalip;rport=5060;branch=z9hG4bK7a3a0bcc
Content-Length: 0

[2013-08-15 11:13:36] WARNING[30598][C-0000001a]: chan_sip.c:22834 handle_response_invite: Received response: “Forbidden” from ‘sip:mynumber@freephonie.net;tag=as63f7fcd2’
Scheduling destruction of SIP dialog '073476fe344b09d901d65f365189be2b@freephonie.net’ in 6400 ms (Method: INVITE)
Audio is at 10032
Adding codec 100003 (ulaw) to SDP
Adding codec 100004 (alaw) to SDP
Adding codec 100002 (gsm) to SDP
Adding non-codec 0x1 (telephone-event) to SDP

and when try to register:

Really destroying SIP dialog ‘217154ee047e7c9c03859f6b7aa19b2f@192.168.1.31:5060’ Method: OPTIONS
Reliably Transmitting (NAT) to 212.27.52.5:5060:
OPTIONS sip:freephonie.net SIP/2.0
Via: SIP/2.0/UDP myexternalip:5060;branch=z9hG4bK0cba0227;rport
Max-Forwards: 70
From: “Unknown” sip:Unknown@myexternalip;tag=as1c0dcbc2
To: sip:freephonie.net
Contact: sip:Unknown@myexternalip:5060
Call-ID: 6b6ba7a74450d017398b5fd50400a6c4@myexternalip:5060
CSeq: 102 OPTIONS
User-Agent: FPBX-2.11.0(11.4.0)
Date: Thu, 15 Aug 2013 09:26:00 GMT
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH
Supported: replaces, timer
Content-Length: 0


<— SIP read from UDP:212.27.52.5:5060 —>
SIP/2.0 501 Not Implemented Yet
Call-ID: 6b6ba7a74450d017398b5fd50400a6c4@myexternalip:5060
CSeq: 102 OPTIONS
From: “Unknown” sip:Unknown@myexternalip;tag=as1c0dcbc2
To: sip:freephonie.net;tag=00-31667-01772c3e-5c12be2c1
Via: SIP/2.0/UDP myexternalip:5060;received=myexternalip;rport=5060;branch=z9hG4bK0cba0227
Content-Length: 0

Thank you

secret should be remotesecret. allowguest (in general) should be no.

canreinvite is deprecated in that version; use directmedia.

I believe username is deprecated in that version. Most people don’t need it.

Thank you
I change my configuration

type=peer
remotesecret=mysecret
qualify=yes
host=freephonie.net
fromdomain=freephonie.net
dtmfmode=auto
disallow=all
context=from-trunk
directmedia=no
allow=ulaw&alaw
allowguest=no

But I have always the same problem

allowguest must go in general. Note that the likely effect of fixing that is that incoming calls will fail completely, as the information in the incoming INVITE isn’t matching the sip.conf entry and you are falling back to public access.

Ok, I disable “allow sip guest” in the sip general settings in freepbx, it was set to yes and I changed it, but always the same problem

Your logs do not include a registration attempt.

Is your register string in the correct place? (In the general section, with each line beginning “register =>”.)

My registration string is in the freepbx trunk configuration mynumber:mysecret@freephonie.net. I try to insert it in the sip_general_custom.conf:
register => mynumber:mysecret@freephonie.net, that is the file included by the untouchable sip.conf already used by freepbx, but this don’t solve my problem.
My configuration worked on this server and now I don’t know what is happened. I have the port 5060 rerouted on external 55060 because I think the provider of my internet service block the external 5060, I don’t know if this can be a problem, but in the same net with a softphone I can connect with my sip account correctly.
Thank you for your help

For FreePBX aspects, please use freepbx.org/forums/

It sounds like you have a complex NAT case (translated port numbers). What is translating the port number? You don’t appear to have externhost, etc.

What do you mean for translating port numbers? (I’m Italian)
I rerouted 5060 to 55060 external one, and that’s warking because I can communicate with my server also from external using extensions. I configured my external ip in the configuration settings, also rtcp for the audio, that’s wark, my only problem it’s the registration of the trunk that worked and now it doesn’t work. I posted in freepbx forum too

The parts of the Asterisk configuration you have provided indicate that everything is on the default port number. SIP messages contain addresses. If these don’t correspond with what the other side will use, or will see in IP and UDP level headers, you will need to consider special options.

If your router is rewriting the port number, that is a NAT situation. If it is not rewriting the port number, you need to explain what you mean by “rerouted 5060 to 55060 external one”.

Solved!!!
My problem was that I have a dynamic external ip, I configure my sip_nat.conf for this case and now it’s work.
Thank you!!!