why kamailio server does not send 401 unauthorized message and if i want to send it manually then what i have to do? i am sending the bellow registration message format,

REGISTER sips:ss2.biloxi.example.com SIP/2.0
     Via: SIP/2.0/TLS 
     client.biloxi.example.com:5061;branch=z9hG4bKnashds7
     Max-Forwards: 70
     From: Bob <sips:[email protected]>;tag=a73kszlfl
     To: Bob <sips:[email protected]>
     Call-ID: [email protected]
     CSeq: 1 REGISTER
     Allow: INVITE, ACK, CANCEL, BYE, PRACK, UPDATE, REFER, MESSAGE, 
     OPTIONS, NOTIFY, SUBSCRIBE
     Contact: <sips:[email protected]>
     Max-Forwards: 70
     Expires: 3600
     Content-Length: 0

1 Answers

0
Nick On
sl_reply("401", "Unauthorised");

That'll send back a stateless 401 Unauthorised message, but it'll respond with that to all SIP Messages.

You'd probably want to do this only to REGISTER messages, by adding this into your request_route{} block:

    if(method=="REGISTER"){
            sl_reply("401", "Unauthorised");
            exit;
    }

That'll see any REGISTER messages sent to your Kamailio instance getting back a 401 response with the text "Unauthorised".

Taking a bit of guess here in that you probably want to see the 401 Unauthorised so you can authenticate the request, in which case you'd want to add authentication vectors (nonce, realm, etc) to the 401 response, have a database backend with the allowed users in it, and store the Address on Record for it as a registrar. I've written some posts in the past on setting up a SIP Registrar in Kamailio and adding Database backed Authentication if that is what you're trying to achieve.