Sample Trunk Configuration
Trunk Name: Dead Restricted
Disable Trunk: Checked
Outgoing Settings / Trunk Name: Dead Restricted
The Dead Restricted Trunk is a special trunk that is disabled. It is intended to be used as a dead-end for restricted calls that you don't want completed. You might choose to use the Dead Restricted Trunk as a destination in your Outbound Routes for calls to 1900 numbers and 976 numbers.
2. Generic Configuration for Internet Telephone Service Providers using SIP protocol:
Trunk Name: ProviderA
Outbound Caller ID: YOUR CALLERID HERE
Dialed Number Manipulation Rules:
(18883503771) + 411 | empty
(1212) + empty | XXXXXXX
(1) + empty | XXXXXXXXXX
- The first line re-routes 411 calls to 1-888-350-3771. You can change the desired phone number if you prefer. You can also add additional lines to route calls to other X11 services, such as 211, 311, 411, and so on.
- The second line adds 1 + 212 to the beginning of any number that is seven digits long. You should change 212 to your area code.
- The third line adds 1 + to the beginning of any ten digit number.
- You can delete any of these lines if you don't prefer this functionality.
Trunk Name: Provider A
Registration String: username:[email protected]
- Replace "ProviderA" with whatever name you want to use for the provider.
- Replace "YOURCALLERIDHERE" with the Caller ID to be used on outgoing calls on this Trunk. Note that most of the time, this Caller ID will not be used, as Caller IDs set in the Outbound Routes module and the Extensions Module usually take priority (unless the CID Options field is set to Force Trunk Caller ID).
- Replace "username" with the username assigned by your ITSP.
- Replace "password" with the password assigned by your ITSP.
- Replace provideraddress.com with the IP address or domain name supplied by your ITSP.
- If the Caller-ID on incoming calls come in with a + at the beginning and you don't want them to, change "from-trunk" to "from-pstn-e164-us".
- If your inbound calls have no Caller ID, delete trustrpid=yes.
- If your outbound calls never have the correct Caller ID, delete the fromuser= line.
- If your outbound calls always fail, try deleting the sendrpid= line.
- If your inbound calls always fail, try changing "from-trunk" to "from-pstn-toheader"
3. Using a Custom Trunk to allow your callers to dial a SIP address.
A Custom Trunk is generally used to place a direct SIP Call. A SIP call is a call placed to a SIP address. For example, sip:[email protected] or sip:[email protected] Use these settings to set-up a Custom Trunk:
Trunk Name: OutboundSIPCalls
Outbound Caller ID: YOURCALLERIDHERE
Custom Dial String:
To route calls to a specific destination:
To route calls to whatever number has been dialed by the user (as modified by the Dialed Number Manipulation Rules) at a specific remote system:
- Replace "OutboundSIPCalls" with whatever name you want to use for the Trunk.
- Replace "YOURCALLERIDHERE" with your Caller ID.
- $OUTNUM$ will pass whatever number was dialed by the inside caller to the Trunk, after it is modified by the Dialed Number Manipulation Rules.
4. Connecting two FreePBX systems:
Connecting two FreePBX/Asterisk systems together requires configuring Trunks and Outbound Routes on both systems. We've written a separate article on how to connect two systems. Click here to read it.
What Does That Stuff in the PEER Details Mean?
The PEER details can contain a number of different parameters. Here are the most commonly used ones in a SIP Trunk, and what they do:
"192.168.1.99" is the IP address of the remote system that you are going to connect to. You can also put the domain name (i.e. othersystem.com). If the other system will register to your system (using the Registration String field on the remote system), you should put the word "dynamic" here.
"name" is the username that will be sent to the remote system when you attempt to place a call to authenticate the call. If the remote system requires authentication on incoming calls, the username= on the local system must match the name put in the "Trunk Name" in the PEER details on the remote system.
"password" is the password that will be sent to the remote system when you attempt to place a call to authenticate the call. It is also the password that you will expect to receive when you receive a call, unless insecure=invite is used int the PEER details (see below).
"name" is the name that will appear in the from field of the call. When you place a SIP call, the SIP headers include a to: field ([email protected]) and a from: field ([email protected]). If you include the fromuser=name line, the "callerID" in the from: field will be replaced with "name". If the remote system expects the Caller ID to appear in the from field, you should not fromuser=.
See notes above regarding fromuser=, except that "mysystem.com" will be replaced with "test.com".
"friend" means that you will both send calls to and receive calls from this server and that the PEER details will be used both for incoming and outgoing calls on this trunk.
"from-trunk" means that incoming calls from this trunk will be treated as if they are coming from an outside line, and will be routed using the rules that you setup in the Inbound Routes Module. If there is no matching Inbound Route, Asterisk will deliver a "not in service message." "from-pstn-e164-us" is the same as "from-trunk," except that any leading + in the Caller ID will be removed. "from-pstn-toheader" is the same as "from-trunk," but that the called number (the DID) will be derived from the to: header instead of the From-DID header. "from-internal" means that incoming calls from this trunk will be treated as if they were made by an internal phone, and will be routed directly to an extension number, a feature code, or through the outbound routes module.
Generally, you use "from-trunk" when routing calls from an outside source and "from-internal" for trunks that tie two trusted systems together.
"yes" means that your system will look at the Remote Party ID header for the Caller ID on received calls instead of the from: field of the incoming call. If you aren't getting Caller ID for incoming calls, you may wish to delete this line.
"yes" means that your system will send the Caller ID on outgoing calls using the Remote-Party-ID header. If your outgoing calls are always rejected, you may wish to remove this line. "pai" means that your system will send the Caller ID on outgoing calls using the "P-Asserted-Identity" header. If your outgoing calls have an incorrect Caller ID, you may wish to add this line.
"yes" means that your system will periodically send a request that the other system identify itself. If there is no answer within 2 seconds, your system will assume that the other system is down and stop sending calls to the system until the system responds. Instead of "yes," you can also put a number, in miliseconds. For example, qualify=3000 means that your system will wait 3 seconds for a response, instead of 2 seconds.
"59" is how often, in seconds, that Asterisk will send a qualify, if qualify is set to yes or a number. If qualifyfreq= is not set, the default of 60 seconds will be used.
"yes" tells Asterisk that the system you are communicating with is or may be behind a NAT, and that Asterisk should ignore the IPAddress in the from line and instead use the IP address that the packets actually come from.
"30" is the number of seconds that Asterisk will wait between sending keepalive messages. Keepalive messages are important if you are behind a NAT firewall, because if the firewall closes the port, you may not receive all incoming calls.
"5060" is the port where Asterisk will attempt to send outgoing calls and where Asterisk expects incoming calls to come from. This line is usually omitted. If omitted, Asterisk will use the default port of 5060. When used in the PEER details, this has no effect on the Port to which your system expects to receive incoming calls.
"port" tells Asterisk to accept incoming calls even if they come from a port other than the one where calls are expected to come from. "invite" means that Asterisk should accept incoming calls even if they are not accompanied by the proper username and password. Most ITSP's require this line. If only one is used, the comma separating them is omitted.
"no" in these two commands means that Asterisk will not attempt to connect two phones directly together, and will instead route the calls through itself. canreinvite is the pre-Asterisk 1.8 command and directmedia is the Asterisk 1.8 or later command.
"rfc2833" is the most common method of signaling touchtones. "inband" is another method, although less reliable.
"all" tells Asterisk to not use any audio codecs unless they are expressly allowed in an allow= line.
"ulaw" is the codec that is allowed. This command only has an effect if disallow=all appears before it.
For more details on the settings that can be included in the PEER details for a SIP Trunk, see Digium's Sample sip.conf file.
For details on the settings that can be included in the PEER details for an IAX2 Trunk, see Digium's Sample iax.conf file.
Troubleshooting Trunk Problems
1. Double check your PEER details and Registration String. Often, Trunk problems occur when the information in the PEER details or Registration String is wrong
2. Pull-down "Reports", select "Asterisk Info," and then select "Full Report" on right. In many cases, the information in this report can guide you in the right direction.
3. Refer to the General FreePBX Troubleshooting Instructions (link).