<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

 
一、概述
Translation-rule用于增加、移除和替换VoIPdial-peer拨号对等体inboundoutbound号码。它有以下几种应用:
1、  应用于所有inbound call legs
2、  应用于特定voice-port的所有inbound call legs
3、  应用于特定dial-peer的所有outbound call legs

 

二、命令格式
Translation-rule在全局模式侠有以下两种命令配置方式:
1、    (config)translation-rule rule_tag
(config-rule)rule <0-10> match pattern  replacement pattern
应用 translation-rule:

1)       所有 inbound call legs

(config) voip-incoming translation-rule rule_tag {called/calling}
2)       特定 voice-port 的所有 inbound call legs

      (config)voice-port 0/0/0
     (config-voiceport)translate {called/calling} rule_tag

3)       特定 dial-peer 的所有 outbound call legs

     (config)dial-peer voice 10 pots
     (config-dial-peer)translate-outgoing {called/calling} rule_tag

 

2、    (config)voice translation-rule rule_tag
(config-rule)rule <1-15> /match pattern/  /replacement pattern/

应用voice translation-rule:
1)      创建voice translation-profile
(config) voice translation−profile profile_name

(cfg-translation-profile) translate {called/calling} rule_tag
2)      特定的dial-peer所有incomingoutgoing call legs
       (config)dial-peer voice 10 pots
     (config-dial-peer)translation-profile {incoming/outgoing} profile_name

 

 

三、通配符
1、  数字通配符       

 

通配符号
用途
任意一个数字 (0~9)
[0-9]
区间范围内的一个数字,也可用 [0,2-4,5,8-9] 方式表示间断和连续数字。
*
0 个或多个相同数字。
     +
1 个或多个相同数字。
     ?
0 个或 1 个相同数字。
.*
任意数字,可以为 0 个。
.+
0 个任意数字。

 

  2、其他符号:

 

符号
用途
$
无数字,相当于结束符。
^
从此符号后的数字开始,相当于起始符。
^$
Null ,即没有数字。
\
match pattern 中,表示在此之前 copy; replace pattern 中,表示在此之后 paste
( )
表示一个集合,用于 copy 数字时。

 

 

 

四、用法示例

 

1 、将 40 开头的 5 位号码替换为号码 "6666000":

voice translation−rule 1

rule 1 /^40.../ /6666000/

router#test voice translation−rule 1 40123

Matched with rule 1

Original number: 40123 Translated number: 6666000

 

2 、将所有号码替换为 "5554000":

voice translation−rule 2

rule 1 /.*/ /5554000/

router#test voice translation−rule 2 123

Matched with rule 1

Original number: 123 Translated number: 5554000

router#test voice translation−rule 2 86573

Matched with rule 1

Original number: 86573 Translated number: 5554000

router#test voice translation−rule 2 ""

Matched with rule 1

Original number: Translated number: 5554000

 

3 、将所有非空号码替换为 "5554000".

voice translation−rule 2

rule 1 /.+/ /5554000/

router#test voice translation−rule 2 123

Matched with rule 1

Original number: 123 Translated number: 5554000

router#test voice translation−rule 2 ""

Didn't match with any of rules

 

4 、保留最后 3 位号码至 5554 开头的后 3 位:

voice translation−rule 2

rule 1 /^....(...\)/ /5554\1/

router#test voice translation−rule 2 1234567

Matched with rule 1

Original number: 1234567 Translated number: 5554567

router#test voice translation−rule 2 123456

Didn't match with any of rules