Search the Asterisk Blog

The PJSIP Outbound Registration ‘line’ Option

By Joshua C. Colp

Outbound SIP registrations are a commonly used practice in Asterisk. They allow an upstream server, such as one in use by an ITSP, to know where you are and to route calls to you. This is easy to configure and see in practice. Where many people have difficulty though is identifying calls from that upstream server. This is important to do as it allows you to restrict what you allow accessible to the outside world. In res_pjsip this operation is called “endpoint identification”. Given an incoming message identify who they are and what endpoint is associated with them. Every message received by res_pjsip goes through this, none are spared. Traditionally what has been done in both chan_sip and res_pjsip is that the source IP address of the incoming message is used to determine who they are. For a single upstream server this works fine but an ITSP might have multiple servers spanning many IP addresses.

In the case of chan_sip you’d have to do something like:

For res_pjsip this has been improved to allow subnet masks:

However if your ITSP adds servers in other regions with different IP addressing and you don’t keep track you may find that a subset of your calls are not able to be received.

The “line” option to outbound registrations in res_pjsip helps to eliminate this in some cases.

Take a look at the following registration:

As you can see it’s pretty normal. It’s talking to and adding a Contact of ‘sip:s@’ to AOR ‘5201’.

With line support enabled the registration turns into the following:

A new parameter is added to the Contact: line=vqqgygs. This is important because the remote server is supposed to call us using the Contact we provide to them. Therefore if they send us a call and preserve the parameter we are able to establish a relationship between an incoming call and the outbound registration. This eliminates any need for IP based matching.

So how do you configure it? Pretty easily, actually. The following options can be added to an outbound registration (type=registration section) to enable line support.

If your upstream server preserves the line information then any incoming calls will be automatically identified as the provided endpoint. No extra work required! If they don’t preserve it I’m afraid you will have to use the IP based matching mechanism. While servers are supposed to preserve the information not all do.

No Comments Yet

Get the conversation started!

Add to the Discussion

Your email address will not be published. Required fields are marked *

About the Author

Joshua C. Colp

Joshua Colp is a Senior Software Developer at Digium and a long time Asterisk developer. He originally started in the community submitting simple patches and grew into improving and creating new core components of Asterisk itself. He is a self-taught programmer who believes in finding the balance between doing things the way they should be done and doing what is right for the people using the software. In his spare time he enjoys smashing fax machines.

See All of Joshua C.'s Articles