How to use many phone numbers within a single VoIP Account

This article aims to present how it'll be possible to implement a SIP trunking as described in title.

black-yellow-black-warning-1.svg Warning! black-yellow-black-warning-1.svg

What here follows is intended to be more specific than the standard Messagenet VoIP service and is not required unless explicitly requested.
If you want to proceed this way, you should check your VoIP PBX or client capabilities and request for a free activation of this feature to the support (via e-mail to support@messagenet.it or using this web portal) selecting the mode you want to implement. Messagenet support cannot offer direct help in this service implementation on the customer PBX or client, we can just give you generic help related to the needed requirements and feedback related to SIP traces on our proxies for debug purposes.

Premise

We commonly assign to a customer VoIP Account (SIP URI of authentication username) a single geographical number (as a FreeNumber or SmartNumber product), but this is not really a requirement for every services (e.g. to call outbound to PSTN): we can assign many phone numbers to the same VoIP Account, or none.

These numbers would have then two distinct roles:

  • target in order to get calls from the PSTN;
  • caller ID to be shown to PSTN destination in outbound calls (as CLI);

In case of a VoIP Account without any phone number association, it'll be impossible to get calls from the PSTN (it'll be called only by other Messagenet VoIP Account, calling directly this username) and also CLI presentation will be always screened (as the customer doesn't own a number).

Regardless this, it should be observed that:

  • Messagenet does not currently offer a proper SIP Trunking service and inbound calls could be received by SIP client only via SIP Registration: the client will periodically present itself to our Registrar/Proxy using a custom SIP Contact Header field and revealing its IP source address and port; if the client registers successfully, every call to this client will be sent using this contact field value as the Request URI to the client (via a SIP INVITE to the port and IP address of registration request source);
  • related to the step before, for inbound calls the actual called number from the PSTN (obviously related to this VoIP Account) could be completely different from this contact field value and is deeply wrong to simply consider the received request URI as a DID number; in any case, the actual called number will be always specified if the "To:" header user-part (unless anonymous);

Inbound called number Identification (as in DID Service)

As said before, in this scenario where a VoIP Account has many geographical number, the possibility to identify which number was actually called from the PSTN matters.

In this case, your client must be able to read this SIP "To:" userpart and consequently act as you want in your inbound dialplan rules.

Asterisk PBX configuration example

As an example, we'll consider two different fixed-line numbers related to the same VoIP Account 5xxxxxx with password as password. We should be able to receive call made to:

  • first geographical number: 0612345678 (Rome number in Italian national format);
  • second geographical number: 0212345678 (Milan number in Italian national format);
  • the VoIP Account username itself: 5xxxxxx;

First of all, we'll have a "register" string in sip.conf file:

register => 5xxxxxx:password@sip.messagenet.it:5061/200

Pay attention to the last part of this string, the register extension (we set it as "200"): this will be the local dialplan extension to which every inbound call from this peer will be used in our registration context.

In order to identify the called number then, we need to configure as extension 200 a function to directly read SIP Headers and use retrieved values to make choice (e.g.: use the value as new extension); here follows an example:

[sipin]
exten => 200,1,Set(CALLED=${CUT(CUT(SIP_HEADER(TO),@,1),:,2)})
exten => 200,n,Verbose(Call from Messagenet to ${CALLED})
exten => 200,n,GotoIf($["${CALLED}" == "0612345678"]?to-rome,s,1)
exten => 200,n,GotoIf($["${CALLED}" == "0212345678"]?to-milan,s,1)
exten => 200,n,GotoIf($["${CALLED}" == "5312345"]?to-internal,s,1)
exten => 200,n,Goto(to-other,s,1)

[to-rome]
exten => s,1,Verbose(Call to Rome)
exten => s,n,Dial(SIP/201)
exten => s,n,Hangup()

[to-milan]
exten => s,1,Verbose(Call to Milan)
exten => s,n,Dial(SIP/202) exten => s,n,Hangup()

[to-internal]
exten => s,1,Verbose(Call to Messagenet VoIP Account)
exten => s,n,Dial(SIP/203) exten => s,n,Hangup()

[to-other]
exten => s,1,Verbose(Call to invalid number)
exten => s,n,Playback(pbx-invalid) exten => s,n,Hangup()

Now an explanation follows:

  • inbound calls are placed to extension 200 in sipin context;
  • the CALLED channel variable is filled with the correct portion of "To:" SIP Header: it should now contain our DID number;
  • in the same context, some checks are performed in order to filter the correct DID numbers and bring the call to the right context (and call another peer in out case);

The result is to bring different calls to different DID numbers (all related to the same account) to different local SIP Peers.

N.B.: from all those contexts and extensions, to the whole retrieving mode, are intended to be just an example: the focus should be brought only on the DID number identification;

N.B.: other SIP client and PBX, especially if derived from Asterisk PBX itself (as FreePBX, for example) should be capable to be configured in a similar way in order to let you reach this goal: check this in your product documentation;

Dynamic CLI Selection

As in the previous paragraph, we're now focusing on the possibility to choose which phone number to use in call to PSTN destinations.

In every cases:

  • the customer cannot freely specify the CLI to use in calls to PSTN destination: the network operator should perform screening to this CLI in order to ensure that every outbound call to the PSTN are placed using a valid and allowed CLI related to the calling customer. A CLI that differs from the VoIP Account default will then be actually used only:
    1. from Messagenet VoIP network to the PSTN; within Messagenet VoIP network calls are placed only between Messagenet VoIP Account in SIP and every called party will present the calling party using Display Name (the "From:" SIP Header display part) unless differently chosen in receiving client configurations;
    2. if previously agreed with Messagenet Support, as described above;
    3. if correctly configured, related to the previous step, in your SIP PBX or client configurations;
  • every Messagenet VoIP Account should have a default CLI (the same geographical number for inbound calls) that will be used in outbound calls to PSTN unless restricted in presentation (by the customer) or in case of screening error (see the previous step);

 

If you choose to relate more geographical number to the same VoIP Account, you can configure your client to specify which one to use as CLI using one of these two alternative methods:

1- Using P-Preferred-Identity (or Remote-Party-ID) SIP Header

If you choose this way, you should have a SIP Client or PBX able to add a custom SIP Header to the INVITE Request. This field is the "P-Preferred Identity" and should be evaluate using the chosen CLI in e164 format (with leading plus) as user part.
Here follows an example using an Italian fake CLI +3912345678900:

P-Preferred-Identity: <sip:+3912345678900@sip.messagenet.it>

The whole INVITE payload should be similar to this example:

U 2012/12/06 11:15:40.188965 212.97.35.XX:5003 -> 212.97.59.76:5061
INVITE sip:3XXXXXXXXX@sip.messagenet.it SIP/2.0.
Via: SIP/2.0/UDP 192.168.130.10:5060;branch=z9hG4bK2400e757.
Max-Forwards: 70.
From: "Pinco Pallino" <sip:5XXXXXX@192.168.130.10>;tag=as5ac44caf.
To: <sip:3XXXXXXXXX@sip.messagenet.it>.
Contact: <sip:5XXXXXX@192.168.130.10:5060>.
Call-ID: 5717ebf5402014bc4e96bebe6d361b64@192.168.130.10:5060.
CSeq: 103 INVITE.
User-Agent: AsteriskPBX.
Proxy-Authorization: Digest username="5XXXXXX", realm="sip.messagenet.it", algorithm=MD5, uri="sip:3XXXXXXXXX@sip.messagenet.it", nonce="UMBxdlDAcEqmHgHBDkXEs9Mh9I4cpRQ1gIlnlIH6fznfgXG0r
Sz7yUk1LA+C", response="13e09ead6b93cf47efa9a23a76c5ee54", qop=auth, cnonce="311d4651", nc=00000001.
Date: Thu, 06 Dec 2012 10:15:40 GMT.
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH.
Supported: replaces, timer.
Privacy: none.
P-Preferred-Identity: <sip:+3912345678900@sip.messagenet.it>.
Content-Type: application/sdp.
Content-Length: 355.
...

N.B.: you can use a "Remote-Party-ID" header instead of the "P-Preferred-Identity" in the same way; if both the headers have been specified, the "P-Preferred-Identity" will then take precedence;

Asterisk PBX configuration example

Imagine to relate both the Italian numbers 021234567 and 061234567 to the same VoIP Account: in order to dynamically select between them a SIP Header is to be added to the outbound INVITE Request to Messagenet: in our dialplan, we'll find an extension "ext" with "n" priority, where a Dial() application will be called in order to use our VoIP Account 5xxxxxx to call, for example, 3212345678 as PSTN destination:

...
exten => ext,n,Dial(SIP/5xxxxxx/3212345678)
...
exten => h,1,HangUp()

In order to reach our target, we need to add a directive using a lower priority in order to execute this before the Dial() application (we here use "n-1" or "n-2" in order to let this dialplan to be understand, but priorities are numeric in Asterisk):

...
exten => ext,n-1,SipAddHeader(P-Preferred-Identity: <sip:+39021234567@sip.messagenet.it>)
exten => ext,n,Dial(SIP/5xxxxxx/3212345678)
...
exten => h,1,HangUp()

Using this setup, we'll call outbound the destination using 021234567 as CLI.

N.B.: other SIP client and PBX, especially if derived from Asterisk PBX itself (as FreePBX, for example) should be capable to be configured in a similar way in order to let you reach this goal: check this in your product documentation;

2- Using "From:" header display part

This mode let you specify an allowed CLI evaluating the Display Name (again, the SIP "From:" Header display part) with the CLI itself expressed in e164 (with leading plus) format:

From: "+3912345678900" <sip:5XXXXXX@192.168.130.10>;tag=as5ac44caf.

Pay Attention to this: we're talking about the display part (the Display Name) and not the SIP "From:" Header user part: this part should always been specified using the VoIP Account Username (5xxxxxx in this case); outbound calls to PSTN will be refused with SIP causecode 403 by our proxy if different!

Asterisk PBX configuration example

Looking at the same example and at the same scenario related to the previous example, here our dialplan could look like this:

...
exten => ext,n-1,Set(CALLERID(name)="+39061234567")
exten => ext,n,Dial(SIP/5xxxxxx/3212345678)
...
exten => h,1,HangUp()

N.B.: other SIP client and PBX, especially if derived from Asterisk PBX itself (as FreePBX, for example) should be capable to be configured in a similar way in order to let you reach this goal: check this in your product documentation;

CLI presentation using "Privacy" SIP Header

CLI presentation follows the same default configuration statically imposed on our systems (and freely manageable from our website).

A part from the CLI choice, you can also act in order to dynamically (per call) change this presentation behaviour and let your CLI been presented or not (if allowed) regardless the static configuration.

You can perform this using the "Privacy" SIP Header, adding it in your SIP INVITE to our proxy; value can be:

  • none
    let the CLI been presented to destination, presentation allowed;
  • id
    hide the CLI to the destination, presentation restricted;

Asterisk PBX configuration example

You can configure this regardless the dynamic CLI choice and the way you selected this CLI. In this example, we'll continue the first diaplan example in this paragraph, but could be used in any case and with any allowed CLI:

...
exten => ext,n-2,SipAddHeader(P-Preferred-Identity: <sip:+39021234567@sip.messagenet.it>)
exten => ext,n-1,SipAddHeader(Privacy: none)
exten => ext,n,Dial(SIP/5xxxxxx/3212345678)
...
exten => h,1,HangUp()

Using this, we'll outbound calls to the PSTN destination showing 021234567 as CLI, explicitly allowing presentation regardless the default configuration for this VoIP Account CLI presentation

N.B.: other SIP client and PBX, especially if derived from Asterisk PBX itself (as FreePBX, for example) should be capable to be configured in a similar way in order to let you reach this goal: check this in your product documentation;

Further request for information and service provisioning

If you want to proceed this way, you should check your VoIP PBX or client capabilities and request for a free activation of this feature to the support (via e-mail to support@messagenet.it or using this web portal) selecting the mode you want to implement. Messagenet support cannot offer direct help in this service implementation on the customer PBX or client, we can just give you generic help related to the needed requirements and feedback related to SIP traces on our proxies for debug purposes.