Asterisk – External SIP Binding and DID
January 9th, 2016 // 9:20 pm @ Arad Gharagozli
Introduction
In this tutorial, i am going to talk about how to setup your Asterisk to recieve calls from a legacy phone, or PSTN (public switched telephone network) .
Procedure
For this section you do need a DID (Direct Inward Dial). This something that you need to purchase from DID suppliers.there are several DID suppliers that would provide you with a phone number, for most countries, and regions.
Get a Phone Number
I get my DID numbers from https://www.carrymynumber.com/ a really good company, I won’t hesitate to advertise for them. I have several Canadian Phone numbers from them, for only 1 $/Month! doesn’t get better than that, does it.
NOTE: With most DID provider you can NOT choose your phone number. Only the area code. the company will give you a number from their block. Sometimes, they will “port” your number, meaning, if you have a cell phone/business phone number with a carrier, they will bring that over, but you can NOT choose your own phone number!
So go ahead, either with https://www.carrymynumber.com/ or some other DID provider, and get a phone number for your self. But since I have got mine through them, I will base my article on their settings. Other companies have similar settings
- On the main page, choose the country, then city.
- Under, “Select Forwarding Destination” choose “Your own SIP Server”.
- Under “Destination Detail” , select SIP for protocol
- for host, type your Asterisk Public IP address, or your Dynamic DNS (I personally don’t recommend this for production environment)
- under detail, you have to enter the destination’s username. For now, we are doing a basic setting, so just choose one username, and enter there. Later we can create more complex dialplan, that will handle calls as they come in, as opposed to targeted
finish the transaction,pay the fee, and wait! you should get your phone number activated with in few minutes. But don’t rush, it takes time!
Setup DID Binding
When all is done, the company will give you a set of IP addresses that they use. You have to ‘Bind” your server with theirs. CarryMyNumber case, their IP Binding is found here . You can ask your provider to give you this info.
Here is a snapshot of the DID Forwarding , DO NOT USE THIS CODE! refer to the providers reference guide ( I chose the first two [contexts], the list could be as long as the provider wants it to be)
[46.19.209.10]
host=46.19.209.10
dtmfmode=rfc2833
dtmf=rfc2833
type=peer
context=from-carrymy
insecure=very
nat=never
allow=all
[46.19.209.11]
host=46.19.209.11
dtmfmode=rfc2833
dtmf=rfc2833
type=peer
context=from-carrymy
insecure=very
nat=never
allow=all
NOTE: MAKE SURE that you have copied the entire forwarding code. each [context] creates a binding, depending on their load-balancer server. So if you don’t copy all, you may get a call from one their IP addresses that is not registered on your SIP, then your Asterisk will drop it! BAD things will happen!
Adding SIP Binding to DID Provider
Hopefully, you have received the DID activation email, with your new phone number!
open “sip_general_additional.conf” and append the list given to you, by your provider.
You don’t need to touch anything, leave everything as is- Just make sure “host” in every context matches the host IP address. this is providers IP address, and your Asterisk will bind over that IP.
now save and exit.
Create DialPlan/Extension
Open “extensions_additional.conf” and add the following to the end- Let’s say your new phone number is 1-902-555-3344
; [context] this should match what you have above, in SIP Config
[from-carrymy]
; Direct the call that came in for 1-902-555-3344 to our internal SIP > Username: user-one > Ring for 50 Seconds
exten=>9025553344,1,Dial(SIP/user-one,50)
So basically, we created an extension, 9025553344, which is our phone numbers as well. Now, if the DID sends us a call, with that number in the header, our server knows, that it’s meant for ‘user-one’. I will show you a copu of the incoming Asterisk log for your reference (See bottom of the page)
save and exit
Activate and Test
Like anyother change, login to CLI, and issue the reload commands for both SIP and dialplan, it should reload/compile ok!
Now, you can issue, “sip show peers” again and should see several sip connections to the DID provider
Name/username Host Dyn Forcerport Comedia ACLPort Status Description
46.19.209.10 46.19.209.10 No No 5060 Unmonitored
here is a sample, but you should see several more ip addresses with 5060 port on them
now, you should be able to call 1-902-555-3344 from ANY phone, and your SIP phone that is registered to ‘user-one’ will ring. You can pick up and you should have voice in both directions.
Making outgoing Calls to PSTN
You can NOT make outgoing calls to PSTN from Asterisk, yet. In order to do that you either need VoIP SIP Trunk to a VoIP provider Click Here to see some companies , Or you need a telephone interface card, which depending on their size/capabilities can vary in price. I will try to cover that some times this year.
Just an FYI — Digium makes these card specifically for Asterisk, they call them Telephony Cards or Analog Telephony Card that works with DAHDI (Digium/Asterisk Hardware Device Interface), it is the open source device interface technology used to control Digium and other legacy telephony interface cards.
You can see the list of the supplies here
Category : VoIP - telephony