SIP failed authentication -sip.conf "template" not loading

I am very new to asterisk. However, I am using the book Asterisk the definitive guide.

I want to set up two softphones within my system so that I can do some testing. I have created the SIP.conf modules.conf and the extensions.conf.

I am running asterisk 11 on a Ubuntu server.
I am running asterisk using the concole. " asterisk -cvvvvv"
These are the modules loaded

*CLI> module show Module Description Use Count app_dial.so Dialing Application 0 chan_local.so Local Proxy Channel (Note: used internal 0 chan_sip.so Session Initiation Protocol (SIP) 0 codec_gsm.so GSM Coder/Decoder 0 codec_ulaw.so mu-Law Coder/Decoder 0 res_crypto.so Cryptographic Digital Signatures 0 res_http_websocket.so HTTP WebSocket Support 0 res_rtp_asterisk.so Asterisk RTP Stack 0 8 modules loaded

I am getting the following error message when I attempt to register the softphone from my MAC computer.

[Jul 5 17:00:19] NOTICE[18421]: chan_sip.c:27829 handle_request_register: Registration from '"ivan"<sip:ivan@192.168.1.185;transport=UDP>' failed for '192.168.1.12:5060' - Wrong password

Here is my sip.conf

[general]
context=unauthenticated           ; default context for incoming calls
allowguest=no                           ; disable unauthenticated calls
srvlookup=no                             ; disable DNS SRV record lookup on outbound calls
                                                ; (unless you have a reliable DNS connection,
                                                ; in which case yes)
udpbindaddr=0.0.0.0                 ; listen for UDP requests on all interfaces
tcpenable=no                           ; disable TCP support
;  
;
[softphone](!)                          ; create a template for our devices
type=friend                             ; the channel driver will match on username first,
                                               ; IP second
context=softphone                  ; this is where calls from the device will enter
                                              ; the dialplan
host=dynamic                         ; the device will register with asterisk
nat=force_rport,comedia        ; assume device is behind NAT
                                             ; *** NAT stands for Network Address Translation,
                                             ; which allows multiple internal devices to share an
                                             ; external IP address.
dtmfmode=auto                     ; accept touch-tones from the devices, negotiated
                                             ; automatically
disallow=all                           ; reset which voice codecs this device will accept or offer
allow=g722                            ; audio codecs to accept from, and request to, the device
allow=ulaw                            ; in the order we prefer
allow=alaw                            ;
;
;
[tp_local_100](softphone)         ; test account 1
username=ivan                          ;
secret=pwivan12                     ;
[tp_local_101](softphone)         ; test account 2
username=bob                         ;
secret=pwbob34                      ;

I am using Zoiper to make the call. This softphone only requires the following

IP address - {my local ip address} 192.168.1.185
username - ivan
password - pwivan12
Auth. username - ivan

Why would I be getting a wrong password error during registration? The password is correct.
Is the username/password formatted correctly? How can I check the format of the authentication?

Do I need to reload something or save the configuration?

username should be tp_local_100

Thanks for the input

I changed the user name in Zoipher so the username is tp_local_100 but that did not help.

I changed the sip.conf so I have more options for testing to the following:

[tp_local_100](softphone) ; test account 1 secret=pwivan11 ; [tp_local_101](softphone) ; test account 2 username=tp_local_101 ; authuser=tp_local_101 ; secret=pwbob12 ; [tp_local_102] ; test account 3 username:scott ; secret=pwscott13 ;

After updating the Sip and restarting Asterisk I opened Zoipher to test these options. I tried using the Username and the deceleration as the user name in both the username field and the Auth. username field.

All of these do not work. I get the same error.


I set “spi set debug on” and then tested the phone tp_local_100. Here is the output.
SIP Debugging enabled

sip set debug on
SIP Debugging enabled
*CLI> Really destroying SIP dialog 'N2E4YjdkODVkZmI2ZTk4NWFkMDc4NTkyZDBkMjEzMWY.' Method: REGISTER

<--- SIP read from UDP:192.168.1.12:5060 --->
REGISTER sip:192.168.1.185;transport=UDP SIP/2.0
Via: SIP/2.0/UDP 192.168.1.12:5060;branch=z9hG4bK-d8754z-9106429f55798b80-1---d8754z-
Max-Forwards: 70
Contact: <sip:tp_local_100@192.168.1.12:5060;rinstance=5404efeb8db380cd;transport=UDP>
To: <sip:tp_local_100@192.168.1.185;transport=UDP>
From: <sip:tp_local_100@192.168.1.185;transport=UDP>;tag=c470b643
Call-ID: NGFlYTY4ZWIwYzYwOTYzZDQwMmJmOWNjYmFjYmY3N2I.
CSeq: 1 REGISTER
Expires: 3600
Allow: INVITE, ACK, CANCEL, BYE, NOTIFY, REFER, MESSAGE, OPTIONS, INFO, SUBSCRIBE
Supported: replaces, norefersub, extended-refer, X-cisco-serviceuri
User-Agent: Zoiper Communicator 2.04.10164 rev.10204
Allow-Events: presence, kpml
Content-Length: 0

<------------->
--- (14 headers 0 lines) ---
Sending to 192.168.1.12:5060 (no NAT)
Sending to 192.168.1.12:5060 (no NAT)

<--- Transmitting (no NAT) to 192.168.1.12:5060 --->
SIP/2.0 401 Unauthorized
Via: SIP/2.0/UDP 192.168.1.12:5060;branch=z9hG4bK-d8754z-9106429f55798b80-1---d8754z-;received=192.168.1.12
From: <sip:tp_local_100@192.168.1.185;transport=UDP>;tag=c470b643
To: <sip:tp_local_100@192.168.1.185;transport=UDP>;tag=as356a03ea
Call-ID: NGFlYTY4ZWIwYzYwOTYzZDQwMmJmOWNjYmFjYmY3N2I.
CSeq: 1 REGISTER
Server: Asterisk PBX 11.4.0
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH
Supported: replaces, timer
WWW-Authenticate: Digest algorithm=MD5, realm="asterisk", nonce="533e33ca"
Content-Length: 0


<------------>
Scheduling destruction of SIP dialog 'NGFlYTY4ZWIwYzYwOTYzZDQwMmJmOWNjYmFjYmY3N2I.' in 32000 ms (Method: REGISTER)

<--- SIP read from UDP:192.168.1.12:5060 --->
REGISTER sip:192.168.1.185;transport=UDP SIP/2.0
Via: SIP/2.0/UDP 192.168.1.12:5060;branch=z9hG4bK-d8754z-2972ce7b48c3b94b-1---d8754z-
Max-Forwards: 70
Contact: <sip:tp_local_100@192.168.1.12:5060;rinstance=5404efeb8db380cd;transport=UDP>
To: <sip:tp_local_100@192.168.1.185;transport=UDP>
From: <sip:tp_local_100@192.168.1.185;transport=UDP>;tag=c470b643
Call-ID: NGFlYTY4ZWIwYzYwOTYzZDQwMmJmOWNjYmFjYmY3N2I.
CSeq: 2 REGISTER
Expires: 3600
Allow: INVITE, ACK, CANCEL, BYE, NOTIFY, REFER, MESSAGE, OPTIONS, INFO, SUBSCRIBE
Supported: replaces, norefersub, extended-refer, X-cisco-serviceuri
User-Agent: Zoiper Communicator 2.04.10164 rev.10204
Authorization: Digest username="tp_local_100",realm="asterisk",nonce="533e33ca",uri="sip:192.168.1.185;transport=UDP",response="654bce3df8836e5fe573788d7d574bfa",algorithm=MD5
Allow-Events: presence, kpml
Content-Length: 0

<------------->
--- (15 headers 0 lines) ---
Sending to 192.168.1.12:5060 (no NAT)

<--- Transmitting (no NAT) to 192.168.1.12:5060 --->
SIP/2.0 403 Forbidden
Via: SIP/2.0/UDP 192.168.1.12:5060;branch=z9hG4bK-d8754z-2972ce7b48c3b94b-1---d8754z-;received=192.168.1.12
From: <sip:tp_local_100@192.168.1.185;transport=UDP>;tag=c470b643
To: <sip:tp_local_100@192.168.1.185;transport=UDP>;tag=as356a03ea
Call-ID: NGFlYTY4ZWIwYzYwOTYzZDQwMmJmOWNjYmFjYmY3N2I.
CSeq: 2 REGISTER
Server: Asterisk PBX 11.4.0
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH
Supported: replaces, timer
Content-Length: 0


<------------>
[Jul  6 11:51:41] NOTICE[2730]: chan_sip.c:27829 handle_request_register: Registration from '<sip:tp_local_100@192.168.1.185;transport=UDP>' failed for '192.168.1.12:5060' - Wrong password
Scheduling destruction of SIP dialog 'NGFlYTY4ZWIwYzYwOTYzZDQwMmJmOWNjYmFjYmY3N2I.' in 32000 ms (Method: REGISTER)

<--- SIP read from UDP:192.168.1.12:5060 --->
SUBSCRIBE sip:tp_local_100@192.168.1.185;transport=UDP SIP/2.0
Via: SIP/2.0/UDP 192.168.1.12:5060;branch=z9hG4bK-d8754z-36d3e521289f3578-1---d8754z-
Max-Forwards: 70
Contact: <sip:tp_local_100@192.168.1.12:5060>
To: <sip:tp_local_100@192.168.1.185;transport=UDP>
From: <sip:tp_local_100@192.168.1.185;transport=UDP>;tag=4e71e930
Call-ID: YjJhMTJhOWFiZTNkMTBmNjY2NTQ1NzQ1OTEzNjU0NzE.
CSeq: 1 SUBSCRIBE
Expires: 3600
Accept: application/simple-message-summary
Allow: INVITE, ACK, CANCEL, BYE, NOTIFY, REFER, MESSAGE, OPTIONS, INFO, SUBSCRIBE
Supported: replaces, norefersub, extended-refer, X-cisco-serviceuri
User-Agent: Zoiper Communicator 2.04.10164 rev.10204
Event: message-summary
Allow-Events: presence, kpml
Content-Length: 0

<------------->
--- (16 headers 0 lines) ---
Sending to 192.168.1.12:5060 (no NAT)

<--- Transmitting (no NAT) to 192.168.1.12:5060 --->
SIP/2.0 403 Forbidden (policy)
Via: SIP/2.0/UDP 192.168.1.12:5060;branch=z9hG4bK-d8754z-36d3e521289f3578-1---d8754z-;received=192.168.1.12
From: <sip:tp_local_100@192.168.1.185;transport=UDP>;tag=4e71e930
To: <sip:tp_local_100@192.168.1.185;transport=UDP>;tag=as321bf740
Call-ID: YjJhMTJhOWFiZTNkMTBmNjY2NTQ1NzQ1OTEzNjU0NzE.
CSeq: 1 SUBSCRIBE
Server: Asterisk PBX 11.4.0
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH
Supported: replaces, timer
Content-Length: 0


<------------>
Really destroying SIP dialog 'YjJhMTJhOWFiZTNkMTBmNjY2NTQ1NzQ1OTEzNjU0NzE.' Method: SUBSCRIBE

I do not see anything here that tells me why this would give me the Wrong password error. …

I took a look at the template [softphone] and found that the value within the template are not being applied to the individual device.

I was able to get the device tp_local_100 by adding host, type,and context under the device declaration. So now my new issue is Why does the values in the template not apply to the device.

Here is my sip.conf

[general] ;context=unauthenticated ; default context for incoming calls ;allowguest=no ; disable unauthenticated calls ;srvlookup=no ; disable DNS SRV record lookup on outbound calls ; (unless you have a reliable DNS connection, ; in which case yes) ;udpbindaddr=0.0.0.0 ; listen for UDP requests on all interfaces ;tcpenable=no ; disable TCP support ; ; [softphone](!) ; template type=friend context=customerphone host=dynamic ; [tp_local_100] ; test account 1 type=friend context=customerphone host=dynamic secret=pwivan11 ; [tp_local_101](softphone) ; test account 2 using template secret=pwbob12 ; [tp_local_102] ; test account 3 type=friend host=dynamic secret=pwscott13 context=customerphone

I am able to register the accounts tp_local_100 and tp_local_102 using the same device ( Zoipher) but tp_local101 I am unable to register…because the template is not being accessed.