Setting up an Inbound (DID/DDI) number in FreePBX can be tricky. We have to do 2 things to get it to work. First we need to tell FreePBX/Asterisk that the incoming call is allowed, the second is to say what to do with that incoming call.
Lets look at allowing the call first. One of the easiest ways to do this is allow Anonymous SIP Calls in FreePBX. I recommend you do not do this though as you don’t really want Asterisk/FreePBX trying to process any call fired at it.
So if we’re not going to allow anonymous SIP calls we need to tell Asterisk what IPs to allow calls from, and we do this by setting up a trunk. When a call comes to our server we will receive a SIP INVITE from the remote server, asking us to accept the call, so let’s have a look at the SIP INVITE messages coming in …
First we’ll install ‘tcpdump’ if it’s not already on the system. In CentOS we do –
Next we run the following command to list all the INVITE messages coming in. You will need to change the network adapter name if you’re not on a VPS, probably from venet0 to eth0 –
Now if we ring the number we should see the SIP INVITE message coming in. If you don’t then you should double check that the call provider is definitely passing the call to your server.
Here’s mine –
The above tells us that the call came from 220.127.116.11 (the call provider) to 18.104.22.168 (my Asterisk server) and the destination telephone number is 441604283321
That should be all the information we need. Now lets set up the trunk. We’re going to add a SIP trunk with the following details –
Those are the minimum details we need. Basically it just tells Asterisk to allow calls from that host IP address.
Now we create the Inbound Route to tell FreePBX where to send the call. The important part here is to make sure you enter the “DID Number” in the format it appears in the SIP INVITE message above –
One other thing I do when testing an inbound call for the first time is set the destination to “Terminate Call/Put caller on hold forever”. That way you should get music when calling the number (if you set the destination to an extension and it doesn’t work it may be that the extension is not working!)