Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Trying to register a sip client to my asterisk server often (just about 90% of the times, not always, weirdly) results in 401 Unauthorized errors.

This is the config for one of the extensions:

[11]
deny=0.0.0.0/0.0.0.0
secret=xxxxxxxxxxxxxxxxxxxx
dtmfmode=rfc2833
canreinvite=no
context=from-internal
host=dynamic
trustrpid=yes
sendrpid=no
type=friend
nat=no
port=5060
qualify=yes
qualifyfreq=60
transport=udp
avpf=no
icesupport=no
encryption=no
callgroup=
pickupgroup=
dial=SIP/11
mailbox=11@default
permit=0.0.0.0/0.0.0.0
callerid=Caller <11>
callcounter=yes
faxdetect=no

Excerpt from the log:

<--- SIP read from UDP:192.168.178.69:60686 --->
REGISTER sip:192.168.178.26 SIP/2.0
Via: SIP/2.0/UDP 192.168.178.69:60686;rport;branch=z9hG4bKPj7IVefnk0j6Wn9oUM78ubmcURGDehvKEc
Route: <sip:192.168.178.26;lr>
Max-Forwards: 70
From: <sip:12@192.168.178.26>;tag=XOO-LeGIwZmwa2UROKMXEhZGA5mKcY0b
To: <sip:12@192.168.178.26>
Call-ID: p8gpcmxSdWwcM5xV89nm2LkEbcTPUdT1
CSeq: 62833 REGISTER
User-Agent: CSipSimple_g2-17/r2330
Contact: <sip:12@192.168.178.69:60686;ob>
Expires: 900
Allow: PRACK, INVITE, ACK, BYE, CANCEL, UPDATE, INFO, SUBSCRIBE, NOTIFY, REFER, MESSAGE, OPTIONS
Content-Length: 0

<------------->
--- (13 headers 0 lines) ---
[2014-02-08 14:54:00] DEBUG[2922]: acl.c:979 ast_ouraddrfor: For destination '192.168.178.69', our source address is '192.168.178.26'.
[2014-02-08 14:54:00] DEBUG[2922]: chan_sip.c:4031 ast_sip_ouraddrfor: Setting SIP_TRANSPORT_UDP with address 192.168.178.26:5060
Sending to 192.168.178.69:60686 (NAT)
[2014-02-08 14:54:00] DEBUG[2922]: chan_sip.c:8764 sip_alloc: Allocating new SIP dialog for p8gpcmxSdWwcM5xV89nm2LkEbcTPUdT1 - REGISTER (No RTP)
Sending to 192.168.178.69:60686 (NAT)

<--- Transmitting (no NAT) to 192.168.178.69:60686 --->
SIP/2.0 401 Unauthorized
Via: SIP/2.0/UDP 192.168.178.69:60686;branch=z9hG4bKPj7IVefnk0j6Wn9oUM78ubmcURGDehvKEc;received=192.168.178.69;rport=60686
From: <sip:12@192.168.178.26>;tag=XOO-LeGIwZmwa2UROKMXEhZGA5mKcY0b
To: <sip:12@192.168.178.26>;tag=as68275e50
Call-ID: p8gpcmxSdWwcM5xV89nm2LkEbcTPUdT1
CSeq: 62833 REGISTER
Server: FPBX-2.11.0(11.6.0)
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH
Supported: replaces, timer
WWW-Authenticate: Digest algorithm=MD5, realm="asterisk", nonce="7cdb20a0"
Content-Length: 0

Complete log of one registration attempt until the timeout message appears on the client: http://pastebin.com/sqjAqa2T

I have already tried the methods mentioned in this question: Asterisk SIP/2.0 401 Unauthorized

How can I make the registrations work properly?

share|improve this question
1  
A 401 Unauthorized response doesn't means necessary an error. In you case I can't see any error: your 401 response is the authentication challenge from your server. –  Bertera Feb 10 at 8:26

1 Answer 1

You don't have a username= set in your extension (often, just the extension number - it doesn't matter what it is, it just needs to match the client)

The log sample you have shows an extension 12 trying to register, and not sending any Authorization header, which looks odd. CSipSimple works fine for me using the extention number as the username (and of course the password - whatever secret= is set to for that extension).

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.