Skip to Content
《Asterisk:权威指南》第 5 版
book

《Asterisk:权威指南》第 5 版

by Jim Van Meggelen, Russell Bryant, Leif Madsen
May 2025
Intermediate to advanced
414 pages
5h 2m
Chinese
O'Reilly Media, Inc.
Content preview from 《Asterisk:权威指南》第 5 版

第 7 章 外部连接 外部连接

本作品已使用人工智能进行翻译。欢迎您提供反馈和意见:translation-feedback@oreilly.com

你不能总是控制外面发生的事情。但你总能控制内心的变化。

韦恩-戴尔

在前几章中,我们已经介绍了许多对 Asterisk 系统工作至关重要的重要信息。不过,我们还没有讨论对任何有用的 PBX 都至关重要的东西:即与外部世界的连接。本章我们将讨论外部连接 。

Asterisk 的开创性架构 意义重大,这在很大程度上是因为它将所有通道类型一视同仁。这与传统 PBX 形成鲜明对比,在传统 PBX 中,中继(连接到外部世界)和分机(连接到用户和资源)在逻辑上是分开的。 Asterisk 拨号规划以类似的方式对待所有信道,这意味着在 Asterisk 系统中,你可以非常轻松地完成在传统 PBX 上更难实现(或不可能实现)的事情。

不过,这种灵活性也是有代价的。由于系统本身并不了解内部资源(如电话机)和外部资源(如电信电路)之间的区别,因此您必须确保拨号计划能适当处理每种类型的资源。

中继的基础知识

中继的目的是在两个实体之间提供共享连接。树木有树干,树根和树叶之间的一切都要通过树干。铁路使用 "主干 "一词来指将支线连接在一起的主要线路。

在电信领域,中继线将两个系统连接在一起。运营商使用中继线将网络相互连接起来。在 PBX 中,连接PBX 与外部世界的电路(从 PBX 的角度看)通常被称为中继线(尽管运营商本身通常不认为这些是中继线)。 从技术角度看,中继线的定义不像以前那么清晰(PBX 中继线使用的技术与站内电路完全不同,但现在两者通常都是 SIP),但作为一个概念,中继线仍然很重要。有了 SIP,一切在技术上都是点对点的,因此从技术角度看,中继线其实已经不存在了(或许说一切都属于中继线更准确)。 从功能角度看,区分连接到外部世界的 VoIP 资源(中继线、线路、电路等)和连接到用户终端的 VoIP 资源(站、套餐、分机、听筒、电话等)仍然很有用。

在 Asterisk PBX 中,您可能有中继线与 VoIP 提供商进行国内长途通话,有中继线用于海外通话,还有中继线将各个办公室连接在一起。在 Asterisk 中,这些中继线可能实际上是通过同一个网络连接运行的,但在拨号计划中,你可以对它们进行不同的处理。 在 Asterisk 中,你甚至可以有一个中继线,它可以简单地在自己身上循环(这通常是一些笨拙的黑客手段,可以解决一些命名空间或 CDR 问题,而这些问题用其他方法是无法解决的)。

外部连接的基本拨号计划

在传统的 PBX 中,外线一般通过必须在号码前拨号的接入码来接入。1为此,通常使用数字 9。

在 Asterisk 中,同样可以指定 9 来路由外部呼叫,但由于 Asterisk 的拨号计划要智能得多,因此实际上没有必要强迫用户在拨打电话前拨 9。通常情况下,系统会有一个分机范围(如 100-199)和一个功能代码范围(*00 至 *99)。在这些范围之外的任何符合国家或地区拨号模式的呼叫都可以被视为外部呼叫。

如果由一家运营商提供所有外部路由,则可以通过一些简单的模式匹配来处理外部拨号。本节中的示例适用于北美号码计划 (NANP)。如果您的国家不在 NANP 范围内(NANP 服务于加拿大、美国和许多加勒比海国家),则需要使用不同的模式匹配。

[globals] 部分包含两个变量,分别名为LOCALTOLL2这两个变量的作用是在需要更换运营商时简化拨号计划的管理。通过这两个变量,您只需对拨号计划进行一次更改,就可以影响到引用指定信道的所有地方: ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

What Successful Brick-and-Mortar Retailers Get Right

What Successful Brick-and-Mortar Retailers Get Right

Rob Angell
What Successful Project Managers Do

What Successful Project Managers Do

W. Scott Cameron, Jeffrey S. Russell, Edward J. Hoffman, Alexander Laufer
Three Essentials for Agentic AI Security

Three Essentials for Agentic AI Security

Paolo Dal Cin, Daniel Kendzior, Yusof Seedat, Renato Marinho

Publisher Resources

ISBN: 9798341659568