Dialing directly with username and password

It seems I am not finding the right syntax to dial directly using an username/password. If I insert in my dialplan something like:

    12345 => {
          Dial(SIP/823*********:5***********@78.11.22.33/01342244560);
          hangup();
    }

Then I get:

[Nov 21 20:09:01] NOTICE[9069][C-0001689e]: chan_sip.c:29713 sip_request_call: Conflicting extension values given. Using ‘823************’ and not ‘01342244560’
== Using SIP RTP TOS bits 184
== Using SIP RTP CoS mark 5
– Called SIP/823*********:5************@78.11.22.33/01342244560
[Nov 21 20:09:01] NOTICE[12287][C-0001689e]: chan_sip.c:22914 handle_response_invite: Failed to authenticate on INVITE to ‘“Leandro Dardini” sip:100@91.11.22.33;tag=as1c0d8470’
– SIP/78.11.22.33-000144c3 is circuit-busy
== Everyone is busy/congested at this time (1:0/1/0)

Which is the correct syntax to use to dial directly with username and password?

I don’t think that is supported.

I found in a lots of places reference to this syntax for dialing.

Like the-asterisk-book.com/1.6/applik … -dial.html

whihc is reporting the general format:

Dial(technology/user:password@host/extension,timeout,options)

and even example are given:

exten => s,1,Dial(SIP/richard:secret@widgets.biz)

or

exten => s,1,Dial(IAX2/user:secret@widgets.biz/500)

I stand corrected. However, user@domain and domain/user are two alternative ways of specifying the same thing. Both set the user field in the request URI. That’s why it is complaining.

Most system authenticate on the From header user.

Before you can go any further, you need to tell us exactly what fields in the SIP request you want to be set to which value.

You may have to push set(CALLERID(…) to the limit.

My provider gives me an username and password and I can dial any number by defining the credentials in the sip.conf like

[provider]
type=friend
defaultuser=user
secret=password
host=my.provider.ip

and then using Dial(SIP/provider/number);

I’d like to use something Dial(SIP/user:password@my.provider.ip/number);

or at least Dial(SIP/user:password@provider/number) but without storing defaultuser and secret in the sip.conf

Really thank you for your help…

Your provider doesn’t seem to need a user for INVITE, as defaultuser is for incoming registrations. They may require that you register before you send INVITE, in which case you will have to use sip.conf for the registration.

If defaultuser should have been fromuser, you will need to set CALLERID(num) to the user value.

Sorry, I copied just a part of the definition for the provider. The user is requested and it is set in the “username” configuration parameter.

[provider]
type=friend
secret=************
defaultuser=4999999751
username=4999999751
host=sip.provider.com
dtmfmode=rfc2833
context=fromoutside
canreinvite=no
allow=ulaw
allow=alaw
allow=gsm
insecure=port,invite
fromdomain=sip.provider.com

username is the deprecated name for defaultuser. As far as I know, it is hardly ever used in anger.

Thank you for the information, I will get rid of it… but in the mean time, what about dialing directly with the username:password@FQDN/number?

Leandro

That syntax is actually username:password@FQDN/username

I am having the same issue and couldn’t really find an answer. Using Asterisk 1.8.23
I need to dial with user/pass + port.

If I create a peer in my sip.conf

[foobar] disallow=all allow=ulaw allow=alaw type=peer username=user@domain secret=superpass host=foo.bar.com port=5061 dtmfmode=rfc2833 context=trunkinbound fromdomain=foo.bar.com nat=no

and an alias

then Dial like this:

exten => _0043.,2,Dial(${TESTTRUNK}/${EXTEN},,To)

the INVITE goes to port 5060.

If I change the Dial to

SIP/${EXTEN}@foo.bar.com:5061 the invite is rejected due to the missing auth.

port= works for us.

it works for me as well as long as host=ip of the carrier.
The carrier expects Authentication and number@domain in the to: field.
The Domain unfortunately doesn’t resolve so I added it to /etc/hosts
Adding the domain to the host= sends the correct domain, but ignores the port.

The Solution:

set host=ip
use ! after the dial to send a different to:
Dial(${TESTTRUNK}/${EXTEN}!${EXTEN}@domain,To)