当你公司的分公司也在使用Asterisk的时候,就有把两个公司的电话连接在一起的需求。
假设现在有server A 和server B 两台Asterisk服务器,分别分布在两个不同的公司A和B,其中A公司的分机是以80开头
的四位(如:8001),B公司是以60开头的四位(如:6001)。需要把这个两服务器连接起来,让两个公司的员工可以实现互通。
步骤如下:
在Server A上的配置如下:
 1、修改sip.conf文件,添加以下内容:
  [serverB]   ----值得注意的是这个serverB是B服务器上的username的值。
   ; Specify the SIP account type as 'peer'. This means that incoming
    指定SIP帐户类型为“peer”,这就是说,打进来的电话将会匹配IP和端口号。
   ; calls will be matched on IP address and port number. So, when Asterisk
   ; receives a call from 192.168.1.102 and the standard SIP port of 5060,
    所以当Asterisk接收到一个来自192.168.1.102并且是标准的SIP 5060端口的呼叫的时候,
   ; it will match this entry in sip.conf. It will then request authentication
   它将会匹配这个[serverB],并且它将会要求进行认证,需要提供下面secret指定的密码。
   ; and expect the password to match the 'secret' specified here.
  type = peer

   ;This is the IP address for the remote box (serverB). This option can also  be provided a hostname.
   这是对端ServerB的IP地址,当然这里也可以是一个域名。
  host = www.serverB.com

   ;When we send calls to this SIP peer and must provide authentication, we use 'serverA' as our username.
   当我们需要向对方也就是ServerB发出呼叫的时候,我们必须使用ServerA来当我们的用户名。
  username = ServerA

   ; This is the shared secret with serverB. It will be used as the password when either receiving a call from serverB, or sending a call to serverB.
   这是一个和ServerB共享的一个密码。当从ServerB接收呼叫或是发送呼叫到ServerB的时候都 需要用到这个密码
  secret = p@ssw0rd

    ;When receiving a call from serverB, match it against extensions in the 'incoming' context of extensions.conf.
   当从ServerB接收到一个呼叫后,它就会与extensions.conf中定义的名为incoming的context
  context = incoming

   ; Start by clearing out the list of allowed codecs.
   在一开始就禁用所有的×××
  disallow = all
   ;Only allow the ulaw codecs
   只允许使用ulaw×××
  allow = ulaw

 2、修改extensions.conf文件,添加以下内容:
  [incoming]
  exten => _60XX,1,Answer()
     same => 2,Dial(sip/${EXTEN}@serverB)
     same => n,Playback(nobody-here)
     same => n,Hangup()
     same => 103,Playback(busy)
     same => n,Hangup()

B服务器上的配置和A上面的差不多了,