Username Mismatch on SIP Trunk

I have had this problem reoccuring and I just can’t sort it out.

My Asterisk is connected to another PBX via a Digium ISDN gateway.
These are the peer details of the SIP trunk from the gateway to Asterisk.


When I make a call to Asterisk I get a username mismatch.
Have 2250, digest has hamlet.
Now 2250 is the calling party number, why does Asterisk think it is the username?
“hamlet” is the username of the SIP endpoint on the Digium.
I thought type=peer wasn’t matching on names.

[2015-03-03 17:03:28] WARNING[14455][C-000002b1]: chan_sip.c:16491 check_auth: username mismatch, have <2250>, digest has
[2015-03-03 17:03:28] NOTICE[14455][C-000002b1]: chan_sip.c:25611 handle_request_invite: Failed to authenticate device “2250 O.Matt” sip:2250@;tag=as3164e14

I have solved username mismatch issue, adding fromuser option

And what do you set the username option to be?

Using the username of the digium SIP endpoint results in “anonymous” CallerID.
Can I set username to be the the actual CallerID?

I haven’t setup that device, My opinion was based on a basic trunk setting

Can I use username option in the trunk settings and still retain incoming callerID?

Check this option
match_auth_username=yes if available, match user entry using the’username’ field from the authentication line instead of the From: field.


  The parameter "username" is not the username and in most cases is
    not needed at all. Check below. In later releases, it's renamed
    to "defaultuser" which is a better name, since it is used in
   combination with the "defaultip" setting.

fromuser option override any callerid set.

You can use dialplan Function_CALLERID to pass the desired caller id

How would I alter the dialplan to pass callerID exactly, can you give me the string to include?

This is in extensions.conf:

include => from-trunk-sip-G200AG-custom
exten => _.,1,Set(GROUP()=OUT_19)
exten => _.,n,Goto(from-trunk,${EXTEN},1)

;–== end of [from-trunk-sip-G200AG] ==–;


Thanks for the advice.
Is below how the dial plan would like like?
Not sure how and where to include the dial string you gave me, still new on Asterisk.

include => from-trunk-sip-G200AG-custom
exten => _.,1,Set(GROUP()=OUT_19)
exten => _.,n,Goto(from-trunk,${EXTEN},1)