• No results found

Using the translation-rule Command

Two basic methods exist to manipulate input numbers and translate them into other numbers:

The translation-rule command

The voice translation-rule command

Although they sound similar, they are created and applied slightly differently.

When an input number matches the translation rule, it is replaced with the matched string. The translation-rule command has been superseded by the newer voice translation-rule command. The voice translation-rule command was introduced in Cisco IOS Software Release 12.2(11)T. The translation-rule command is still supported in the latest versions of the Cisco voice IOS. This chapter provides the information to configure both commands. A few differences exist between the translation rule and voice translation rule, including support for a maximum of ten translation statements per translation rule, as opposed to a maximum of 15 translation statements per voice translation rule. Voice translation rule also supports translation of redirect numbers, such as when digits are forwarded to voice mail. This is not supported with regular translation rules. The translation-rule command is easier to understand and configure. The labs in this chapter focus on this command, but the theory can be directly applied to the voice translation-rule. The basic command structure for the two types of translation rules are as follows:

translation-rule number

rule precedence match-pattern replace-pattern translate {called | calling} translation-rule-tag

voice translation-rule number

rule precedence /match-pattern/ /replace-pattern/

voice translation-profile name

translate {called | calling | redirect-called} voice-translation-rule-tag

Table 6-2 describes the syntax used with the rule command to configure voice translation rules.

Chapter 6: Digit Manipulation 105

Table 6-2 Syntax Used in the rule Command

Syntax Description

precedence Sets the priority of the translation rule. The range is 1 to 15.

/match-pattern/ An expression that is used to match incoming call information. The slash (/) is part of the command and is a delimiter in the pattern.

/replace-pattern/ The expression used to replace the matched pattern in the call information.

The slash (/) is part of the command and is a delimiter in the pattern.

reject The match-pattern that is used for call reject purposes.

Table 6-3 describes the pattern matched with wildcard characters used to configure the voice translation rules.

Table 6-3 Characters Used in the rule Command

Voice Translation Rule Character Description

. Any single digit.

0 to 9, *, or # Any specific character.

[0-9] Any sequence of numbers in a range or in consecutive order.

* Repeat the preceding regular expression zero or more times.

? Repeat the preceding regular expression zero times or one time.

(Use Ctrl-V followed by the question mark (?) character to enter this character in IOS.)

.* Any digit (including null) followed by one or more occurrences.

.+ Any digit (except null) followed by one or more occurrences.

^$ No digits.

/ A delimiter that marks the start and end of both the matched and replaced strings.

^ Matched digits must occur at the beginning of the digit string.

+ Repeat the expression (digit) just prior to this symbol. The digit can be repeated one or more times.

\ Escape the meaning of the next character.

The first step of configuring a translation rule is to create a translation rule number using the

translation-rule number command or the voice translation-rule number command. The number can be any number from 1 to 2,147,483,647 and is simply used to uniquely identify the translation rule. The translation-rule and voice translation-rule commands are applied in global configuration mode.

After you configure the translation-rule or voice translation-rule command, you need to apply the rule command. The rule command defines a number pattern and then the parameters that are applied when the number pattern is dialed. There are two types of rules:

The match and replace rule defines a number pattern that is “matched.” The number(s) are replaced with a different set of digits.

The reject rule type specifies a dial pattern that prevents the call from being placed.

106 IP Telephony Using CallManager Express Lab Portfolio

The slash (/) and backslash (\) characters are used with the voice translation-rule number command. The translation-rule number command does not use the slash character. Depending on where it is used, the slash could indicate when to slice or replace a number.

Note: The voice translation-rule command requires additional configuration steps but is not discussed further in this chapter. The remaining sections focus on understanding the rules. The basic rules apply to both kinds of translation rules. The router configuration examples in this chapter use the translation-rule command and not the voice translation-rule command.

The following example shows a dial peer that is configured to use translation rule number 2, which con-tains one translation rule:

translation-rule 2 rule 0 ^7 1904

ephone-dn 3 dual-line number 5002

call-forward busy 5555028

call-forward noan 5555028 timeout 18 translate called 2

dial-peer voice 4 pots

destination-pattern 1904...

port 0/2/1

The rule defined is rule 0, in which 7 is the pattern that must be matched and replaced. The 1904 in the command is the pattern that is substituted for the number 7. Notice in the ephone-dn 3 section how the translate called command is used to associate a translation rule with a specific extension number (directory number). The translate called 2 command under ephone-dn 3 references the translation-rule 2 command.

The called number is 75555029. The previous configuration strips the leading digit 7 from any called num-ber that begins with 7 (dialed from extension 5002) before the numnum-ber is forwarded by the outbound POTS dial peer (dial peer 4).

The caret (^) symbol used in the rule command specifies that the matched digits must occur at the start of a dial string. Some companies use 7 to acquire an outside long-distance line. This translation rule strips the 7 and replaces it with a 1904 to dial a long-distance phone number to a particular area code.

A translation rule set can have multiple translation rules (there is a maximum of 11). For example, the fol-lowing translation rule set has ten translation rules:

translation-rule 3

Chapter 6: Digit Manipulation 107

destination-pattern 7...

translate-outgoing called 3 session target ipv4:12.91.0.1

This example could apply to companies that use the number 7 to acquire a long-distance outside line. When applied to the dial peer, each rule would evaluate the telephone number dialed until a match is found.

Two examples based on the preceding translation rule show that if someone dials 710 as the first three digits, the numbers 710 are replaced with a 0. If someone dials 719, these three digits are replaced with a 9.

The following example provides the basic steps for configuring a simple translation rule. This simple configuration translates a number that is not part of a dial peer into a number that is assigned to a dial peer.

translation-rule 2 rule 0 1234567 5555028

The translation-rule 2 command creates the translation rule with the number 2. (Any number from 1 to 2147483647 can be used.) The rule 0 in this example translates the dialed numbers 1234567 into the numbers 5555028 when applied to an ephone-dn.

The following configuration shows translation-rule 2 being applied to ephone-d 2.

ephone-dn 2 dual-line number 5031

call-forward busy 6900

call-forward noan 6900 timeout 3 translate called 2

In this case, ephone-dn 2’s extension is 5031. The translate called 2 command references

translation-rule 2. Because you are applying this translation rule to only one ephone-dn (extension 5031), only this phone is affected by the translation rule. Other ephone-dns will not translate the numbers. If this rule wasn’t applied to any ephone-dn, the numbers 1234567 would cause the phone to ring fast busy as soon as the number 1 was dialed if no other dial peer matched the number 1.

The following dial-peer voice 1 pots is configured to forward the numbers 5555028 (to port 0/2/0):

dial-peer voice 1 pots destination-pattern 5555028 port 0/2/0

This dial peer forwards only the numbers 5555028; it does not forward the numbers 1234567. This dial peer never “sees” the numbers 1234567 because they are translated into the numbers 5555028 before they reach this dial peer.

Table 6-4 provides examples for voice translation rules. The Match String and Replace String are applied to the Dialed String column to create the Replaced String Value (the actual telephone number forwarded).

Table 6-4 Simple Translation Rule Examples

Match Replace Dialed Replaced

Rule String String String String Value Comments

rule 1 123 456 123 456 123 456 Replaces the number

pattern 123 located anywhere in the called number with 456.

108 IP Telephony Using CallManager Express Lab Portfolio

Match Replace Dialed Replaced

Rule String String String String Value Comments

rule 33 123 456 123 456 6123 6456 Replaces the number

pattern 123 anywhere in the called number with 456.

rule 126 123 456 123 456 99123 99456 Replaces the number

pattern 123 anywhere in the called number with 456.

rule 29 ^123 456 ^123 456 1238 4568 Replaces the number

pattern 123 only at the beginning of the called number with 456.

rule 9 ^123 456 ^123 456 1236870 4566870 Replaces the number

pattern 123 only at the beginning of the called number with 456.

rule 35 ^123 456 ^123 456 99123 99123 Replaces the number

pattern 123 only at the beginning of the called number with 456.

Because the dialed string does not start with 123, no match (and therefore no replacement) occurs.

rule 57 ^123.. 5551050 ^123.. 5551050 12389 5551050 Replaces the called number beginning with 123 and any other two digits with the number 5551050.

rule 62 ^12... 8562344 ^12... 8562344 1237409 856234437409 Replaces the called number that begins with 12 and any other three digits with the number 8562344.

rule 48 /^1..../ /7561491/ /^1..../ /7561491/ 18745 7561491 Replaces the called number beginning with 1 and any other four digits with 7561491. The slashes are used only with the voice translation-rule command.

rule 83 /.+/ /2890116/ /.+/ /2890116/ 123740 2890116 Replaces all called numbers (except null) with 2890116.

Chapter 6: Digit Manipulation 109

continues

www.info4arab.com

Table 6-4 Simple Translation Rule Examples continued

Match Replace Dialed Replaced

Rule String String String String Value Comments

rule 99 /^0+/ /813/ /^0+/ /813/ 04567145 8134567145 Replaces all called numbers starting with any combination of zero(s)—

0, 00, 000, and so on—

with 813.

rule 71 /^0+/ /555/ /^0+/ /555/ 0009644 5559644 Replaces all called numbers starting with any combination of zero(s)—

0, 00, 000, and so on—

with 555.