SIP trunks, outbound but no inbound

This is driving me insane. I’m not sure its not my SIP provider to blame here (directvoip) but I have the following scenarios.

All three units, dialing out works just great, theres some finessing to do but nothing major, I’m happy with it.

Inbound is just so damn flakey its untrue, assuming it even works. If I reboot the freepbx box, it all comes up and works for some random period of time. On one machine, it’ll work again if you make an outbound call. On the other two its gone till you reboot. Only in one of these applications do I need ot working but it worries me something isnt right. IAX trunks arent affected by any of this silliness (predictably)

Whats throwing me is I get a lot of

[2012-09-22 16:35:35] WARNING[3118]: chan_sip.c:20789 handle_response_register: Forbidden - wrong password on authentication for REGISTER for ‘9838164759’ to ‘ha-sip02.directvoip.co.uk
[2012-09-22 16:21:03] NOTICE[3118]: chan_sip.c:13227 sip_reg_timeout: – Registration for ‘[email protected]’ timed out, trying again (Attempt #7)

Both of the systems here on test have their own external IP and are forwarded through the firewall directly (5060/udp and 10000-20000/udp)

OB Details:
username=nnnnnnnnn
type=friend
secret=nnnnnnnnnn
host=ha-sip01.directvoip.co.uk
fromuser=nnnnnnnnnn
context=a2billing ; change for proper context
allow=alaw ; we support ulaw,alaw,ilbc,gsm,g723.1,g726,g729a
trustrpid=yes
sendrpid=yes
canreinvite=no

IB Details
username=xxxxxxxxx
fromuser=xxxxxxxxx
authname=xxxxxxxxx
type=peer
insecure=invite
secret=xxxxxxxxxxx
host=ha-sip01.directvoip.co.uk
context=from-trunk ; change for proper context
allow=alaw ; we support ulaw,alaw,ilbc,gsm,g723.1,g726,g729a
trustrpid=yes
sendrpid=yes
canreinvite=no

I’ve messed about, tweaked and hacked these entries so I’m open to something in there being wrong.

looking at the sip debug, theres an odd 401 in there. I’m now so far out of my depth as a newcommer here I dont know if thats significant or not as it apears to get an OK right after.

[2012-09-22 16:47:51] NOTICE[2965]: chan_sip.c:13151 sip_reregister: – Re-registration for [email protected]
> doing dnsmgr_lookup for 'ha-sip01.directvoip.co.uk
REGISTER 11 headers, 0 lines
Reliably Transmitting (NAT) to 109.104.119.175:5060:
REGISTER sip:ha-sip01.directvoip.co.uk SIP/2.0
Via: SIP/2.0/UDP 31.54.27.36:5060;branch=z9hG4bK6640c06d;rport
Max-Forwards: 70
From: sip:[email protected];tag=as42e5ac07
To: sip:[email protected]
Call-ID: [email protected]
CSeq: 104 REGISTER
User-Agent: FPBX-2.10.1(1.8.15.0)
Authorization: Digest username=“9732720709”, realm=“asterisk”, algorithm=MD5, uri=“sip:ha-sip01.directvoip.co.uk”, nonce=“495ae467”, response="e4f70a7b543fa4d7be0fb7b3bb28f493"
Expires: 120
Contact: sip:[email protected]:5060
Content-Length: 0


<— SIP read from UDP:109.104.119.175:5060 —>
SIP/2.0 401 Unauthorized
Via: SIP/2.0/UDP 31.54.27.36:5060;branch=z9hG4bK6640c06d;received=31.54.27.36;rport=32080
From: sip:[email protected];tag=as42e5ac07
To: sip:[email protected];tag=as32b52fc3
Call-ID: [email protected]
CSeq: 104 REGISTER
Server: Asterisk PBX 1.8.15.1
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH
Supported: replaces, timer
WWW-Authenticate: Digest algorithm=MD5, realm=“asterisk”, nonce="1b58f93f"
Content-Length: 0

<------------->
— (11 headers 0 lines) —
Responding to challenge, registration to domain/host name ha-sip01.directvoip.co.uk
> doing dnsmgr_lookup for 'ha-sip01.directvoip.co.uk
REGISTER 11 headers, 0 lines
Reliably Transmitting (NAT) to 109.104.119.175:5060:
REGISTER sip:ha-sip01.directvoip.co.uk SIP/2.0
Via: SIP/2.0/UDP 31.54.27.36:5060;branch=z9hG4bK2661e58a;rport
Max-Forwards: 70
From: sip:[email protected];tag=as306888d8
To: sip:[email protected]
Call-ID: [email protected]
CSeq: 105 REGISTER
User-Agent: FPBX-2.10.1(1.8.15.0)
Authorization: Digest username=“9732720709”, realm=“asterisk”, algorithm=MD5, uri=“sip:ha-sip01.directvoip.co.uk”, nonce=“1b58f93f”, response="d340b5190e742b25916e56e17d826981"
Expires: 120
Contact: sip:[email protected]:5060
Content-Length: 0


<— SIP read from UDP:109.104.119.175:5060 —>
SIP/2.0 200 OK
Via: SIP/2.0/UDP 31.54.27.36:5060;branch=z9hG4bK2661e58a;received=31.54.27.36;rport=32080
From: sip:[email protected];tag=as306888d8
To: sip:[email protected];tag=as32b52fc3
Call-ID: [email protected]
CSeq: 105 REGISTER
Server: Asterisk PBX 1.8.15.1
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH
Supported: replaces, timer
Expires: 120
Contact: sip:[email protected]:5060;expires=120
Date: Sat, 22 Sep 2012 15:47:20 GMT
Content-Length: 0

<------------->
— (13 headers 0 lines) —
Scheduling destruction of SIP dialog ‘[email protected]’ in 32000 ms (Method: REGISTER)
[2012-09-22 16:47:51] NOTICE[2965]: chan_sip.c:20905 handle_response_register: Outbound Registration: Expiry for ha-sip01.directvoip

You problem is self evident

[2012-09-22 16:35:35] WARNING[3118]: chan_sip.c:20789 handle_response_register: Forbidden - wrong password on authentication for REGISTER for ‘9838164759’ to ‘ha-sip02.directvoip.co.uk

and

. . .
<— SIP read from UDP:109.104.119.175:5060 —>
SIP/2.0 401 Unauthorized
. . .

If you are trying to use the same account on all the boxes for inbound, something will break, “how will your provider know where to send the call?” if not then you are either using the wrong authentication or you need to check with your provider.

The boxes all have their own accounts and external IP addresses. I may be green but not that green.

Made a few more tweaks after the post and we have a new development. The system has mostly stayed accessible from the outside all weekend. When it hasnt been, its popped up again after a few monutes so I think there may be a timeout that doesnt match somewhere.

Regarding whats posted, if it were that easy, the boxes ALL register, become accessible from the outside and can route/receive calls, then it just stops with those errors. I’m gonna go over the logs again this morning and see what has happened. It does feel like something times out before the renewal takes place. Outbound calls have worked all weekend (VPN in and then 3CX softphone to test)