SIP Registration and Authentication Explained: Digest, Nonces, and Expiry
SIP registration is how a device tells a registrar server where it can currently be reached, and digest authentication is how the server confirms the device is allowed to say so. A registration binds an address of record, such as sip:alice@example.com, to a contact address such as sip:alice@203.0.113.7:5060. Calls to Alice are then routed to that contact.
The Registration Handshake
- The device sends
REGISTERwith its address of record and a requested expiry. - The server replies 401 Unauthorized (or 407 from a proxy) with a
WWW-Authenticateheader containing a realm and a one-time nonce. - The device hashes its credentials with the nonce and sends the same
REGISTERagain with anAuthorizationheader. - If the response is valid, the server answers 200 OK and returns the granted expiry.
The 401 on the first attempt is normal. It is a challenge, not a failure. A problem exists only when the challenge repeats after the device has sent valid credentials.
How Digest Authentication Works
The password never crosses the wire. The device computes a hash of the username, realm, password, nonce, and request details, and the server performs the same calculation and compares. Modern deployments should use a strong hash algorithm and TLS so the exchange is also protected from observation (see SIP over TLS and SRTP setup).
Expiry and Re-registration
A registration is temporary. The server grants an expiry in seconds, and the device must refresh before it lapses. Typical engineering trade-offs:
- Short expiry reacts quickly to a device moving networks but increases signaling load.
- Long expiry reduces load but leaves stale contacts if a device vanishes.
- NAT keep-alives are separate from expiry. Devices behind NAT need frequent traffic to keep the firewall mapping open, which is a common reason for calls failing to reach a registered phone.
Registration at Scale
With thousands of devices, the registrar becomes a core component. Practical points:
- Store contacts in a fast shared store so that any proxy node can find any user
- Rate-limit failed attempts to blunt password-guessing (see VoIP security best practices)
- Use consistent hashing or a dispatcher so a device's traffic reaches the right node (see Kamailio dispatcher load balancing)
Troubleshooting Failed Registrations
| Symptom | Likely cause |
|---|---|
| Repeated 401 or 403 | Wrong username, password, or realm; account disabled; source IP not permitted |
| 408 Timeout | Firewall, wrong port or transport, or SIP ALG interference |
| Registers, but inbound calls fail | NAT mapping closed; contact address not reachable; missing keep-alive |
| Registers, then drops | Expiry too long for the NAT timeout |
For the meaning of each code, see SIP response codes explained.
Registration vs Trunk Authentication
Carrier SIP trunks often skip registration entirely and authenticate by source IP instead. Others register like a phone. Know which model your provider uses before debugging (see the SIP trunking buyer's guide).
Need a registrar that holds up under real load? Our Kamailio load balancing team builds scalable, secure SIP registration and routing layers.
Related Services
Keep Reading
Discussion
0Join the conversation
Sign in with your preferred account to comment, reply, and keep the discussion useful for other engineers.
Takes a few seconds. No separate password required.
Controva LLC
Engineering Team
We build digital empires that scale. Specializing in high-performance web architecture, AI automation, and headless commerce.
Work with us