How To Setup SIP Trunk Between 2 Asterisk Servers




1. We need to configure two file.

          a. Sip.conf( /etc/asterisk/sip.conf

          b. Extenstions.conf(/etc/asterisk/extensions.conf

2. Configure for two Asterisk Servers

           a. Asterisk Server 1(name: Server_22,ip:10.105.9.22)

                   - Go to /etc/asterisk/sip.conf then add text below:

                   On [general] Section add register to server

                   register => Server_22:123456@10.105.9.21/Server_21

                   Then add this text at the end of file

                    [Server_21]
                    type=friend
                    secret=123456
                    context=21_incoming
                    host=dynamic
                    qualify=yes
                    dtmfmode=rfc2833
                    disallow=all
                    allow=ulaw

                    - Go to /etc/asterisk/extension.conf add text below:

                      [incoming_calls] 
                      [DLPN_DialPlan1] 
                      (have already when we create user.we just include internal and remote below)

                      include = CallingRule_china_mobile
                      include = CallingRule_CAMBODIA
                      include = CallingRule_INTERNATIONAL
                      include = default
                      Include = parkedcalls
                      include = conferences
                      include = ringgroups
                      include = voicemenus
                      include = queues
                      include = voicemailgroups
                      include = directory
                      include = pagegroups
                      include = page_an_extension
                      include = internal
                      include = remote

                      [internal] (set call number on the own server)
                      exten => _8XX,1,NoOp()
                      exten => _8XX,n,Dial(SIP/${EXTEN},30)
                      (rule call start with number 8 and have 3 digit )
                      exten => _8XX,n,Playback(the-party-you-are-calling&is-curntly-unavail)
                      exten => _8XX,n,Hangup()

                       [remote] (set call number to other server)
                       exten => _2XX,1,NoOp()
                       exten => _2XX,n,Dial(SIP/Server_21/${EXTEN})
                       exten => _2XX,n,Hangup()

                       [21_incoming]
                       include => internal

             b. Asterisk Server 2(name: Server_21,ip:10.105.9.21)
               - Go to /etc/asterisk/sip.conf then add text below:

                  On [general] Section add register to server

                   [general]
                    register => Server_21:123456@10.105.9.22/Server_22

                   Then add this text at the end of file

                    [Server_22]
                    type=friend
                    secret=123456
                    context=22_incoming
                    host=dynamic
                    qualify=yes
                    tmfmode=rfc2833
                    disallow=all
                    allow=ulaw

              - Go to /etc/asterisk/extension.conf add text below:

              [incoming_calls]
              [DLPN_DialPlan1]

              include = CallingRule_china_mobile
              include = CallingRule_CAMBODIA
              include = CallingRule_INTERNATIONAL
              include = default
              include = parkedcalls
              include = conferences
              include = ringgroups
              include = voicemenus
              include = queues
              include = voicemailgroups
              include = directory
              include = pagegroups
              include = page_an_extension
              include = internal
              include = remote

              [internal]
              exten => _2XX,1,NoOp()
              exten => _2XX,n,Dial(SIP/${EXTEN},30)
              exten => _2XX,n,Playback(the-party-you-are-calling&is-curntly-unavail)
              exten => _2XX,n,Hangup()

              [remote]
              exten => _8XX,1,NoOp()
              exten => _8XX,n,Dial(SIP/Server_22/${EXTEN})
              exten => _8XX,n,Hangup()

              [22_incoming]
              Include => internal

So now all extension in sever1 can call to extension in server2 and vice versa
(extension at server1 is 2xx format and Server2 is 8xx format.) beside this extension can’t call.

=================================================

Enable cdr_syslog to syslog(Call Detail Record)

This module allows logging of CDRs using syslog.
To enable this, first add an entry to the system’s syslog configuration file,  
/etc/syslog.conf or /etc/rsyslog.conf

add this line
local4.* /var/log/asterisk/asterisk-cdr.log The Asterisk module has a configuration file,
as well. Add the following section to /etc/asterisk/cdr_syslog.conf:
   
[cdr]




facility = local5
priority = info
template = ${CSV_QUOTE(${CDR(src)})},${CDR(lastapp)},${CSV_QUOTE(${CDR(dst)})},

${CSV_QUOTE(${CDR(lastdata)})},${CSV_QUOTE(${CDR(disposition)})},

Start_Time:"${CDR(start)}", Answer_Time:"${CDR(answer)}", Endtime:"${CDR(end)}",

duration of the actual call: << ${CDR(billsec)}Sec.>>

 
Here is an example syslog entry using this configuration: 
 

$ cat /var/log/asterisk/asterisk-cdr.log
  
Aug 12 19:17:36 pbx cdr: "222",Dial,"008657195188","SIP/trunk_1/008657195188","ANSWERED",Start_Time:"2015-07-16 06:36:46", Answer_Time:"2015-07-16 06:36:49", Endtime:"2015-07-16 06:52:03",duration of the actual call: << 914Sec.>>

 

Enable login asterisk message

 

if you like to log asterisk notices warning or error, you may also use in your login file:

vim /etc/asterisk/logger.conf as line such as:

syslog.local0 => notice,warning,error


Reference:

http://www.asteriskdocs.org/en/3rd