Creating SIP trunk: Failed to authenticate user <PSTNnumb

I have a problem creating a SIP trunk.

I want to connect to a SER which is owned and maintained by an external provider. That provider switches my calls to the “normal” phone network.

To get inbound access I placed the following in sip.conf:

register => user1:pass@domain.tld:5060
register => user2:pass@domain.tld:5060

That works perfect. I can call the normal phone number that belongs to that SIP user and my asterisk box picks it up nicely.

Step 2: Outbound access to the PSTN network. To get that I put the following in sip.conf:

[outbound1]
type=peer
secret=pass
username=user1
host=domain.tld
nat=yes
fromuser=user1
fromdomain=domain.tld
context=maincontext
disallow=all
allow=alaw

[outbound2]
type=peer
secret=pass
username=user2
host=domain.tld
nat=yes
fromuser=user2
fromdomain=domain.tld
context=maincontext
disallow=all
allow=alaw

And that works OK too. I test this by using the following in
extensions.conf:

exten => _9.,1,Dial(SIP/${EXTEN:1}@outbound1,30,r)
exten => _8.,1,Dial(SIP/${EXTEN:1}@outbound2,30,r)

No problem there. But when I activate the outbound stuff I described in step 2, my inbound traffic doesn’t work anymore. I get the following error message:

Nov 18 11:51:36 NOTICE[12741]: chan_sip.c:9386 handle_request_invite: Failed to authenticate user “0656843325” sip:0656843325@121.92.147.18:5065;tag=as7c82636b

where “0656843325” is the cellphone number I use to test this.

Now why does Asterisk want to authenticate this? I don’t get it. When I remove the outbound sip clients, everything works perfectly. Any ideas where this comes from?

I use Asterisk 1.2.0 Beta1 on a Gentoo 2.6.12 box. I have no PSTN, ISDN or other zap/capi interfaces, just SIP.

Sounds like something weird your ITSP is doing? Which one do you have your SIP account with?

Infopact ( a beginning Dutch VoIP provider)

I mailed the technical person at Infopact, and he said it had something to do with the order in wich the phones are placed in sip.conf. He also said that I had to make a SIP entry with the name of the server, like -->
[sip.infopact.nl]

One thing that occurs to me: if you want both outbound and inbound calls, you have to have

type=friend

(not “peer”) in the sip.conf config for that provider.type=friend

In sip.conf you should have only a section for your sip provider, define its type as friend (inbound and outbound calls ) and name it as you like, you should not let Asterisk try authenticate the incoming calls from your sip provider, insecure is the related parameter (from the great Asterisk TFOT book, page 225), set it to invite and your problem should be solved, see below for a sample config:
type=friend
secret=pass
username=user1
host=domain.tld
nat=yes
fromuser=user1
fromdomain=domain.tld
context=maincontext
disallow=all
allow=alaw
insecure=invite

Regards.

Marco Bruni

Great thanks to mbruni I had same issue also.
Your configuration advice helped!
It works.