SIP trunk to Centrex

I’m a newbee to Asterisk and I really need to connect my Asterisk server to Centrex (don’t ask why, just for work). But, while my incoming calls are comming trough just fine, I’m having trouble with my outgoing calls. Correct me if I’m wrong but I think that all I need is username and password for one SIP account and host to register at. This is my configuration:

**** sip.conf ****

register=> 555555:pass@X.X.X.X/555555


**** extensions.conf *****

include => default
exten => _9XXXXXXXXX.,1,Set(CALLERID(num)=555555)
exten => _9XXXXXXXXX.,2,Set(CALLERID(name)=555555)
exten => _9XXXXXXXXX.,3,Dial(SIP/${EXTEN}@siptrunk)
exten => _9XXXXXXXXX.,4,Hangup

In debug when it’s calling this sip trunk it says:
WARNING[3612]: chan_sip.c:16406 handle_response_invite: Received response: “Forbidden” from ‘“555555” sip:555555@X.X.X.X;tag=as2803df97’

Do I need anything else to authenticate with Centrex?
Please can you help me???!!
Do I need to post some more debug?

Thanks in advance!

Forbidden suggests that you are trying to dial an invalid number, or to set a CLI that doesn’t belong to you, rather than an authentication problem.

Is Centrex a brand name here, because its generic meaning is that a telephone company switch acts like a PABX, and you have extensions that are wired up as exchange lines, where as it looks to me as though you want a trunk type connection.

Yes, Centrex is a PBX-like service providing switching at the central office instead of at the customer’s premises. So, has anyone experience with connecting Asterisk to Centrex?
Now I have made it work, but I have problem I think it’s with codecs. When I put in sip.conf:

incoming calls are going just fine, but outgoing calls are specific. Outgoing calls to PSTN (for example mobile) are ok, but out calls with Centrex there is no sound.
But when I put:

outgoing calls work, but problem is with incoming, there is no sound or it is “Call Hangup”.

So the thing is for incoming calls I need ulaw, and for outgoing needs to be without. Any way that I can solve this?
Any help would be great!!!

Why are you using a PBX with a service intended to replace a PBX?

Please provide SIP protocol traces and also information about how you connect to the the internet, in particular any NAT or firewall arrangements.