Users will want to make calls to the public telephone network (PSTN). You may have facilities for this, but if not you will need to buy service from one or more carriers. These are companies who will take your calls and forward them to the PSTN. You can use as many carriers as you wish, using different carriers for inbound and outbound, and for different outbound destinations. It's common to use one carrier for most outbound calls, and other carriers who can offer cheaper rates for calls to specific destinations.

A peer is any machine that Enswitch can send calls to reach the PSTN. Typically, there will be one peer for each carrier used for outbound calls. SIP, IAX, and Zaptel (E1 or T1) peers can configured through the Enswitch web interface. Any other method for connecting to carriers that Asterisk supports can be configured by sending calls to a context in Asterisk's extensions.conf. Advanced number mangling can also be done in this way.

The peer that is used for any given number is set per route. This allows the choice of peer to be set down to an individual external number. For instance, if a customer is complaining that calls to their home are poor quality, the peer can be changed for just this number.

If you are familiar with Asterisk's concept of peers, please note that Asterisk and Enswitch peers have a similar meaning, but the two are separate; a peer configured in Enswitch is not available to Asterisk, and vice versa.

Peers are only used for outbound calls. Inbound calls are not matched against peers, and peers have no effect at all on inbound calls.

To add a new peer

  1. Log in to the Enswitch web interface.
  2. Go to System » Peers.
  3. Click the "New" button.
  4. If Enswitch has a pre-defined peer for the carrier you wish to use, click "Pre-defined". Otherwise, click "Manually configured".
  5. If you chose pre-defined, select the carrier. If you chose manually configured, skip this step.
  6. Fill in the peer's details as desired. Depending upon the protocol you choose, different options will appear. For SIP and IAX, leaving the username and password blank will prevent any from being sent. For context, the context specified must be the same as in extensions.conf ("to-carrier" in the example below).
  7. Click the "Save" button.
  8. If using the context protocol, on each Asterisk machine add an entry to /etc/asterisk/zapata.conf, /etc/asterisk/sip.conf, /etc/asterisk/iax.conf, or similar with the appropriate settings. If unsure how to do this, please contact your Enswitch vendor.
  9. If using the context protocol, on each Asterisk machine add an entry to /etc/asterisk/extensions.conf similar to:
    exten => _X., 1, Dial(SIP/${EXTEN}@carrier,,)
    If unsure how to do this, please contact your Enswitch vendor.
  10. Go back into the peer's settings, and click the "Outbound costs" link.
  11. For each outbound group this peer can route calls to, click the "New" link.
  12. Fill in the following:
    • Choose the outbound group.
    • The starting time for this cost. It will not be used before then.
    • The ending time for this cost. It will not be used after then.
    • The priority of this cost. If multiple costs are currently active, the highest priority one will be used.
    • The connect fee that is charged as soon as the call is answered.
    • The number of seconds included free with the connect fee.
    • The cost per minute after that.
    • The increment for the cost per minute.
    • The minimum cost for the call.
  13. Click the "Save" button.
  14. Repeat for any other outbound groups this peer can route calls to.

Once the peer has been created, routes can be set to use it.

Independent routing table for peer costs

If possible, the peer's costs should be configured using the system routing table. This is simpler to configure, and works with least cost routing (LCR). However, it may not always be possible to manipulate the costs table provided by a carrier to match the system routes. If this is the case, then peer costs may be loaded using a routing table that does not match the system routes. To do this:

  1. Change the "Peer has independent costs table" setting to yes.
  2. Save the peer.
  3. Go back to the edit page for peer, and click on the new "Outbound call costs, using independent routing table" link at the bottom of the page.
  4. Create costs as desired.

Note that these costs will not be considered when calculating least cost routing. You may therefore wish to load approximate pricing according to the system routes as a backup.