Asterisk not registering to SIP trunk, and phones not taking calls 2.6 rc2

I am using 2.6 RC2/asterisk1.4.21/zap, and am trying to migrate from an old Asterisk 1.2 system (non freepbx), which worked completely on the same network with the same phones and same trunks. My build template is also used on several other systems without a fault.

I built my trunks and everything in Freepbx, but it appears that asterisk is not reading the includes properly because my sip registration was not showing up under ‘sip show registry’ - its empty.

Besides that I added some NAT settings to sip_general_custom.conf under [general], and when running sip debug on my trunk peer it showed 192.168 addresses, I added these settings directly to sip.conf and then it showed the correct NAT IPs in sip debug.

I then added the sip registration directly to sip.conf and ‘sip show registry’ showed trunks registered, however at this point my extensions would only ring once (at the extension), then go to voicemail.

At this point, I went in and hit submit on some extensions, no change, so I started from fresh asterisk/zap/freepbx source and compiled it again, now nothing works, no registrations show up, no phones work.

Original Ast 1.2 SIP.CONF:

[code]
[general]
bindport=5060
bindaddr=0.0.0.0
context=invalid-context
musicclass=default
externip=173.160.133.52
localnet=192.168.102.0/255.255.255.0
nat=yes
allowguest=no
useragent=PBXware
maxexpirey=7200
defaultexpirey=3600
realm=PBXware
progressinband=never
disallow=all
allow=ulaw
allow=alaw

register => 1166:[email protected]:5060

[2800_in]
type=friend
dtmfmode=rfc2833
context=2800_in
canreinvite=no
qualify=8000
host=66.5.5.5
username=1166
secret=LCHezOuK
disallow=all
allow=ulaw
allow=alaw
insecure=very
deny=0.0.0.0/0.0.0.0
permit=175.166.184.171[/code]

Trunks as entered in FreePBX:

[code]Trunk Name: 2800_in

Peer Details:
type=friend
dtmfmode=rfc2833
context=from-trunk
canreinvite=no
qualify=yes
host=66.5.5.5
username=1166
secret=LCHezOuK
disallow=all
allow=ulaw&alaw
insecure=very

registration: 1166:[email protected]:5060[/code]

Some debug:

Reliably Transmitting (NAT) to 66.5.5.5:5060:
OPTIONS sip:66.5.5.5 SIP/2.0
Via: SIP/2.0/UDP 174.16.133.53:5060;branch=z9hG4bK33595b2b;rport
From: "asterisk" <sip:[email protected]>;tag=as298629cd
To: <sip:66.5.5.5>
Contact: <sip:[email protected]>
Call-ID: [email protected]
CSeq: 102 OPTIONS
User-Agent: PBXware
Max-Forwards: 70
Date: Thu, 15 Oct 2009 19:42:18 GMT
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY
Supported: replaces
Content-Length: 0

<--- SIP read from 66.5.5.5:5060 --->
SIP/2.0 404 Not Found
Via: SIP/2.0/UDP 174.16.133.53:5060;branch=z9hG4bK33595b2b;rport;received=174.16.133.53
From: "asterisk" <sip:[email protected]>;tag=as298629cd
To: <sip:66.5.5.5>;tag=as5c1e1069
Call-ID: [email protected]
CSeq: 102 OPTIONS
User-Agent: Telcoware
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY
Accept: application/sdp
Content-Length: 0

[2009-10-14 23:28:06] DEBUG[8631] chan_sip.c: Adding subscription for extension 2801 context from-internal for peer 2801
[2009-10-14 23:28:06] VERBOSE[8631] logger.c:     -- Incoming call: Got SIP response 400 "Bad Request" back from 192.168.102.250