All SIP phones require that we configure some parameters, at least the SIP server address or name. This server address is used when the phone needs to enter the voice over IP network and registers itself to the registrar. The registrar keeps a database of the associated phone with their IP address and the UDP or TCP port they can be joined on, by default the 5060. On top of that mechanism, each call requires some exchanges with a SIP proxy, this one can route the call to its destination or some other proxy server. The proxy location can either be entered in the phone configuration or using a dynamic service that can resolve name versus IP address. Let see how these processes are working and how to implement these.
You have probably recognised the DNS service behind the previous description, effectively, in voice over IP and specially SIP, main service already existing are in the picture, no need to develop new protocols since they are available.
For this specific purpose we use in SIP the SRV entries located in modern DNS servers. These entries are tuples linking a service name with an IP address, like for standard A records, but also with protocol and port number. The Microsoft Active Directory service is using these records to inform clients and other members about the location of each services.
For our SIP world, we require for the registrar an IP address, a protocol and the port number. By default port number is 5060 and protocol should be TCP and UDP, in some implementation only UDP is supported. When the client needs to talk to the registrar or the proxy, it can ask the DNS server for SRV record and get all required information. In the DNS server we have to add the information, for example in a bind server we will add something like:
_sip._udp IN SRV 10 1 5060 asterisk-prod1
Here, the SIP registrar and proxy are available behind the server called asterisk-prod1, on the UDP port 5060. Another DNS query would be required probably to gather the IP address of the server, this one is on a standard A or AAAA record. The other interesting parameter is the priority of the information, here set at 10. If multiple records are available, the UA will test the one with the lowest priority first. This allows easy maintenance, resiliency and load balancing of SIP servers. This mechanism is similar to the MX record used for mail routing.
On the IP phone, we will enter in the configuration the domain name rather than the IP address of the registrar.
DNS service can also be used to route calls between SIP proxy, based on the domain name located in the SIP URI of the callee, but this implies that we don’t use anymore E.164 numbering for phone but something closer to email addresses (RFC 822), which requires specific phones with enhanced keyboard. But this is another story…