After confirming that Asterisk can contact the Exchange Server, we can configure our links to the outside world. Asterisk is highly customizable in this regard. You can connect to a VOIP provider, that provides you a PSTN telephone number using a 'soft line', or you can connect physical 'hard lines' to the server using relatively cheap PCI cards. These instructions will involve configuring a soft line to a VOIP provider. In my case, my ISP, iiNet, provides a VOIP line with my ADSL account, but there are companies out there that provide this service for a fee. Please note the exact configuration settings may differ slightly from provider to provider, depending on the gateway they are using. A great place to start is the Whirlpool forums, which contain a lot of information about configuring Asterisk to work with various provider settings.
Create the Trunk
In the FreePBX setup menu, click Trunks, and Add SIP Trunk. Add the following information.
Outbound Caller ID: The PSTN phone number assigned by your provider
Leave Never Override Caller ID unticked
Leave Maximum Channels blank
Leave Dial Rules blank
Leave Outbound dial prefix blank
Trunk Name: PSTNOut
In Peer Details, enter the following information
disallow=all allow=alaw&ulaw canreinvite=no context=ext-did fromdomain=iinetphone.iinet.net.au *REPLACE WITH THE PROVIDER's DOMAIN* fromuser=039029XXXX (REPLACE WITH YOUR ASSIGNED USERNAME, USUALLY THE PHONE NUMBER* host=sip.vic.iinet.net.au *REPLACE WITH YOUR PROVIDERS SIP GATEWAY* insecure=very dtmfmode=auto nat=no pedantic=no secret=**YOUR PASSWORD** type=peer username=039029XXXX *REPLACE WITH YOUR ASSIGNED USERNAME, USUALLY THE PHONE NUMBER*
User Context: PSTNIn
In User Details, enter the following information
canreinvite=no context=from-pstn fromuser=039029XXXX (REPLACE WITH YOUR ASSIGNED USERNAME, USUALLY THE PHONE NUMBER* host=sip.vic.iinet.net.au *REPLACE WITH YOUR PROVIDERS SIP GATEWAY* insecure=very dtmfmode=auto qualify=no secret=**YOUR PASSWORD** type=user username=039029XXXX *REPLACE WITH YOUR ASSINGED USERNAME, USUALLY THE PHONE NUMBER*
Register String: 039029XXXX@iinetphone.iinet.net.au:YOURPASSWORD:039029XXXX@PSTNOut/039029XXXX
Please note that register strings vary from provider to provider, please check with your provider that this information is correct. The register string is used by Asterisk to register with the gateway to receive incoming calls.
Additionally, Maurice van der Werf points out that he had to add dtmfmode=auto in order to get DTMF tones working with one VoIP provider (Xs4all), but dtmfmode=info for another provider (VoIPBuster). Check this setting with your ISP, and modify where appropriate.
Submit the changes, and now we need to modify our routes.
Modify the Route
Now we need to modify the outbound route. There is a preconfigured outbound route called 9_outside in Asterisk which we will use. If the route is not there, simply create a new route with the following information.
Click on Outbound Routes on the left hand menu, and click 9_outside. Change the trunk selection in the Trunk Sequence drop down box to SIP/PSTNOut and press Submit Changes.
The nine/pipe character combination tells Asterisk that this route will be used when someone's presses '9' for an outside line. The period is a wildcard character. This means that any calls starting with the number 9 will be use this route. You can substitute 9 with 1 or 0 if you wish. Keep in mind, we have reserved 2-8 for use by various extension pools. If you used one of these numbers, Asterisk would try to route those internal calls out to the PSTN. You may also choose to not use an 'outside line' access number. In this case, simply enter dial patterns appropriate for the phone numbers you need to dial.
Make a test call from X-Lite to a PSTN phone number. Remember to dial '9' before the phone number to get an outside line.
Configuring the Inbound Route
Asterisk by default can't forward an incoming call to any arbitrary number. It must exist as a registered extension on the system. We want our calls coming in from the PSTN to be routed to the Exchange Server's extension, which Asterisk can't do on its own. However, there is a module we can install to do this for us. We will create Miscellaneous Destinations for both the AutoAttendant and Subscriber Access Number, and configure the inbound calls to be forwarded to one of those destinations.
Click Tools on the top menu of FreePBX, then on the left hand side, click Module Admin. Scroll down to the Inbound Call Control section, and click on Misc Destinations. Select Install as the action, and press the Process button at the bottom of the screen. When the module has installed, click Setup at the top of the FreePBX menu to return to the main configuration screen. Click the Misc Destinations option that has appeared on the left hand menu. Enter the following information for our destination.
Click Submit Changes, and add a second destination
Click Submit Changes, and then Inbound Routes on the left hand menu. Enter the following information.
DID Number: 039029XXXX *Replace with your phone number*
Leave Caller ID Number blank
Leave Zaptel channel blank
Leave the Fax Handling, Privacy, and Options sections at their defaults.
Under Set Destination, select Misc Destinations, and choose either ExchangeAutoAttendant or ExchangeSubscriberAccess, depending on where you want the incoming calls to go.
Click Submit, then test the configuration by calling your provided PSTN number. The Exchange Server should answer at the other end.
You may now want to configure Exchange for outbound calls from OVA to the PSTN.