My Greeting

Hello my dear reader,

Welcome to my blog, which is dedicated to voice technologies. On its pages we will talk about the limitless world of telephony and network technologies.

We will focus on solutions and technologies in the area of IP-telephony (mostly on Cisco, but I will try to speak about the others too.). These are IP PBX based on Cisco Unified Communications Manager and Cisco Unified Communications Manager Express, Cisco contact centers, Cisco Voice Gateways, etc. Also, I will introduce you the news from the world of education: Cisco courses, my own developed training programs, our upcoming events, online learning.

If you have any questions regarding my posts, job or activities, please feel free to ask your questions. I will try to answer them when I have time.

Thursday, June 6, 2013

CUCM Call Routing Based on Calling Number

Good day,

Today's post will focus on the subject, which have been increasingly interested in by my students and blog readers. We will talk about how to route the call in CUCM depending on the number of the caller. This problem arises, typically, in situations where you want to block incoming calls from certain numbers, or, vise versa, to allow incoming calls only from certain numbers and all other call must be denied. Consider, for example, that the second task, ie, let's deny all incoming calls, except calls from certain numbers.

As always, to simulate the case we are using our lab. In the lab we have CUCM version 8.6, Cisco 2811 Voice Gateway connected to simulated PSTN (CUCME, Numbering Plan of Ukraine) via E1:

The figure shows the topology used. Incoming calls will be done from three different telephone numbers - local, long distance, international. Calls are routed to the internal phone 2001. When considering the problem, we assume that the gateway does not change Calling and Called Numbers, ie passes the call to CUCM transparently. All manipulations with the parameters of the call will be made on the CUCM, in addition, the gateway settings at the CUCM do not make any modifications to the numbers as well. We also assume that for all types of calls our PSTN sends 7-digit  Called Number 5552001. In our lab topology phone 2001 is in the partition Phones. Access to it is provided by CSS Phones_css.

Well, the problem is: allow incoming calls to the number 5552001 only from the local PSTN, but prevent calls from long-distance and international networks. It is very simple, if you have CUCM of version 8.0 or later :)

To solve this problem we will use a new property of Translation Patterns, which was introduced in CUCM release 8.0. Now there is a new option -  Route Next Hop By Calling Party Number. The idea of this new option is that the call is returned to CUCM's routing table after reaching this Translation Pattern (this is typical system behavior). Then CUCM searches appropriate route (Route Pattern / Translation Pattern / DN) and select the pattern, which best matches to the Calling Number of our call! Please note - the selected route matches not Called number, as usual, but incoming Calling Number! This is crucial for understanding the proposed solution.

Let's move on, folks! First of all, we create a new Translation Pattern A, which corresponds to the Called Number for an incoming call. In this example the Called Number is 5552001. In the settings for this Translation Pattern we check the check-box Route Next Hop By Calling Party Number. Don't forget to choose the radio-button Route this pattern. Leave all other settings as default:

Once we have checked the check-box Route Next Hop By Calling Party Number in the Translation Pattern, the following occurs. When the call reaches this Translation Pattern (ie when you call on 5552001), CUCM begins looking for an object in the routing table with pattern, which corresponds to the Calling number. If the routing table doesn't contain such object, the call is denied and released. We can say that by default when the checkbox Route Next Hop By Calling Party Number is checked, all calls from any number are denied.

Therefore, to solve the problem let's create a kind of a "white list", which contains external phone numbers allowed for incoming calls. The "white list" are additional Translation Patterns (B, C, D, etc.; their quantity depends on how many calling numbers or ranges of numbers are allowed). The patterns of these additional Translation Patterns match the allowed Calling Number / Numbers. In our example we create Translation Pattern B with the pattern 5554444 (our allowed local PSTN Calling Number). The Translation Pattern B matches our local PSTN number, but at the same time it makes the conversion of the called number 5552001 to 2001. It has also the CSS, which gives access to the internal numbers (Phones_css):

That's the trick. Easy? Definitely! If you want to allow incoming calls to 5552001 from other PSTN numbers, then configure additional similar Translation Patterns. Thus, for long-distance number in our example we need a Translation Pattern with mask of 445554444 and similar settings for 5552001 -> 2001 conversion.

In my example, the call goes like this:

A customer (5554444) dials 5552001 -> Translation Pattern A (5552001, Called) -> Translation Pattern B (5554444, comparison of the Calling Number) -> Phone 2001.

If the incoming calls to 5552001 are done from other PSTN numbers rather than local 5554444, all of them are released, and therefore our problem is solved.

If desired incoming calls from all other numbers can be sent to any other internal number (eg, 2002). For this purpose we can configure a Translation Pattern with the pattern !:

Note !!! In my lab CUCM has minimal configuration only, so I didn't not put my Translation Pattern ! into any partition (now this TP is in the partition None, ie available to all). In real situation, an additional partition for Translation Pattern ! and the corresponding CSS for Translation Pattern A (5552001) are necessary. This grants that the Translation Pattern ! applies to calls to 5552001 only, and it is not used for incoming calls to all other numbers.

If you want to solve the inverse problem - to allow calls from all PSTN numbers, but block only a few of them, you can read about it here:

This is how it works. :) As you see, it is not so complicated. Have a nice evening!


  1. Is this possible for outgoing calls as well.

    I am trying to accomplish the same ...DP is same but having 2 different DID..
    One DID should take Trunk WAN second PSTN....With this configuration I am not able to get the desired results.

  2. I enjoyed reading your article :) PLease continue publishing helpful topics like this. Regards, from Let's get gadget, a company whose into selling
    cordless phone answering machine