Inbound Number (DDI/DID) with FreePBX 2.10

Setting up an Inbound Number with FreePBX can be tricky. There are a few different things to consider and in the past I’ve written some posts for setting up specific call providers. This post will try to describe what the different options mean, and will hopefully help you set up a DDI number with any provider.

The first thing you need to know is that all SysAdminMan templates have “Allow Anonymous Inbound SIP Calls” set to No. This means that an unknown SIP server can not pass a call to your system to be processed. This is to help prevent hackers route calls through your system. It’s strongly recommended that you leave Anonymous SIP calls set to No, unless you really know what the implications are when setting it to Yes.

So, if we don’t let any SIP servers pass calls to us then we need a way to tell FreePBX to allow calls from our DDI provider. We do this by setting up a SIP trunk.

Setting up a SIP trunk

We are going to put all of the settings under “Outgoing settings”, and leave “Incoming settings” blank. This is a little confusing to say the least! but we are not creating a user on our system for the call provider to connect to, we are just allowing their IP. So we add a new SIP trunk and see these details –

Give the trunk a name, and even though it will let you, don’t use and spaces in there. We are then going to set some basic settings.

“host” will be provided by your call provider. As many call providers will have multiple servers that could pass the call to you ideally this will be a DNS name that resolves to all addresses that could pass the call. If you are using IP addresses, and they have multiple IP addresses that could pass the call to your system, you will need to create a trunk for each IP address.

“type” should probably be set to peer. Usual settings are either peer or friend. Peer is the most restrictive and should be used where possible.

“disallow and allow” lines tell the trunk what codecs can be used. This is the format that the audio is sent in. You may not need to enter these lines, if you don’t then the defaults for your system will be used. The “disallow” line should always be before the “allow” line.

“context” should always be set to from-trunk when using FreePBX unless you are sure this is not correct. A lot of times you will see example Asterisk configurations from providers where context is set to something different. When using FreePBX you should set it to from-trunk. This ensures the call is passed to the FreePBX Inbound Routes for processing. Setting it to something different could be a security issue.

Another common option you may see is the “insecure” option –

sip insecure

This is required if your call provider uses a SIP proxy. You will normally see it listed in example configurations from your call provider if it is required. You may also see “insecure=invite,port”. The “port” option is required if your call provider is using NAT, which is unlikely.

The “Register String”

The Register String setting is at the bottom of the SIP trunk setup page. Whether you need this or not will depend how the call provider passes the call to your system. This will normally happen in one of two different ways –

1 – You log in to the call provider control panel and enter a SIP URI to send the call to. This will normally be something like “[email protected]” where 44200100200 is your DID number and 1.2.3.4 is the IP address of your Asterisk/FreePBX server. If you are sending the call to a SIP URI in this way you probably don’t need to enter a Register String

2 – Your Asterisk server tells the call provider where to send the call to. The way it does this is by registering with your call provider. In this case you will need to enter a register string on your SIP trunk. The register string will look something like this, with the details you need being provided by your call provider –

register

One of the downsides of using method 2 where you register with the call provider is that you don’t control the SIP URI that the call is sent to. This can make it difficult to figure out what DID number to enter in you Inbound Route.

Creating an Inbound Route

Once you have created your trunk to tell Asterisk that the incoming call is allowed you need to create anĀ Inbound Route to tell FreePBX what to do with the incoming calls.

Incoming Route

The DID number should match the number being passed to you by your call provider. If the call doesn’t work, and you’re not 100% sure what number is being passed by your call provider, you could set DID number to “X.” as this should match any number.

I normally suggest people initially set the destination to music on hold, because if you forward the call to an extension, and it doesn’t work, it’s difficult to tell if it’s an issue with the inbound number or the extension –

Incoming Route - music on hold

Troubleshooting

Figuring out why an inbound call isn’t working can be a pain. The best way is to use the command line to view the call packets being sent to your server like this – http://sysadminman.net/blog/2012/freepbx-inbound-number-not-working-help-4435

If you are a SysAdminMan customer and can’t get your inbound calls working just open a support ticket for assistance.

2 thoughts on “Inbound Number (DDI/DID) with FreePBX 2.10

  1. Saif

    Deatr Matt,
    You are sharing free info here which i am sure all of us appreciate that , i have a question, if the DID provider sends from different IP for example they have 16 IPs they send from we have to create 16 trunk ? and what if the IPs are continuous for example subnet of 16 IPs is there any way to solve that in 1 trunk ?

    Many thanks Matt.

  2. Matt Newcombe Post author

    Unfortunately yes. You either need a DNS that resolves to those IP, or to set up separate trunks. Regards – Matt

Comments are closed.