Page 131 - Asterisk™: The Future of Telephony
P. 131

type=friend
                   secret=welcome
                   context=osaka_incoming
                   host=dynamic
                   disallow=all
                   allow=ulaw
               And the configuration for the Osaka box:
                   [general]
                   register => osaka:welcome@192.168.2.202/toronto

                   [toronto]
                   type=friend
                   secret=welcome
                   context=toronto_incoming
                   host=dynamic
                   disallow=all
                   allow=ulaw
               Many of the previous options may be familiar to you by now, but let’s take a look at
               them further just in case they are not.

               The second line of the file tells our Asterisk box to register to the other box, with the
               purpose of telling the remote Asterisk box where to send calls when it wishes to send
               a call to our local Asterisk box. Remember how we mentioned a little oddity in the
               configuration? Notice that at the end of the registration line we tag on a forward slash
               and the username of the remote Asterisk box? What this does is tell the remote Asterisk
               box what digest name to use when it wants to set up a call. If you forget to add this,
               then when the far end tries to send you a call, you’ll see the following at your Asterisk
               CLI:
                   [Apr 22 18:52:32] WARNING[23631]: chan_sip.c:8117 check_auth: username mismatch,
                                                     have <toronto>, digest has <s>
               So by adding the forward slash and username, we tell the other end what to place in
               the Digest username of the Proxy Authorization field in the SIP INVITE message.
               The rest of the file is the authorization block we use to control the incoming and out-
               going calls from the other Asterisk box. On the Toronto box, we have the [osaka]
               authorization block, and on the Osaka box, we have the [toronto] block. We define
               the type as a friend, which allows us to both receive and place calls from the other
               Asterisk box. The secret is the password the other system should use when authenti-
               cating.  The  context  is  where  incoming  calls  are  processed  in  the  dialplan
               (extensions.conf). We set the host parameter to dynamic, which tells our Asterisk box
               that the other endpoint will register to us, thereby telling us what IP address to set up
               calls when we want to send a call to the other end. Finally, the disallow and allow
               parameters control the codecs we wish to use with the other end.
               If you save the file and reload the SIP channel on both Asterisk boxes (sip reload from
               the Asterisk console), you should see something like the following, which will tell you
               the remote box successfully registered:


                                                      Connecting Two Asterisk Boxes Together via SIP | 103
   126   127   128   129   130   131   132   133   134   135   136