Connecting Asterisk / FreePBX to voip.co.uk / Firstcom SIP trunks


Firstcom / voip.co.uk present the SIP headers in a different way than Asterisk / FreePBX expects, so you need to do some twiddling when a call comes in to get the right DID.

Here are the settings for the SIP trunk after you've chosen to add a SIP trunk in FreePBX:

General Tab first:
Trunk name:  firstcom-SIP


SIP Settings tab next. It has two sub-tabs.


Outgoing sub-tab:
Trunk name:firstcom-SIP

PEER Details:
type=peer
secret=<password>
insecure=very
host=single-01.proxy.voip.co.uk
defaultuser=<username>
context=custom-get-did-from-sip


Incoming sub-tab:
USER Context:<username>

USER Details:
type=user
secret=<password>
insecure=very
context=custom-get-did-from-sip

Register String: <username>:<password>@single-01.proxy.voip.co.uk/<username>



After this, we need to add some custom code to the dialplan to create the context "custom-get-did-from-sip" mentioned above that we're routing voip.co.uk's inbound calls to. To do this, we need to edit /etc/asterisk/extensions_custom.conf

With Asterisk, you will need to SSH in as root and edit this file using vim or nano.  For FreePBX you can do it via the GUI by going to Admin/Config Edit.  You'll see extensions_custom.conf listed there, just click on it to edit it.

Add the following code:

[custom-get-did-from-sip]
exten => _.,1,Noop(Getting DID from SIP header)
exten => _.,n,Set(pseudodid=${SIP_HEADER(To)})
exten => _.,n,Set(pseudodid=${CUT(pseudodid,@,1)})
exten => _.,n,Set(pseudodid=${CUT(pseudodid,:,2)})
exten => _.,n,Goto(from-trunk,${pseudodid},1)

Once you've added the code, save it and reload the dialplan by typing fwconsole reload in SSH or Apply Settings in the GUI.

Once that is in place, calls should come in from voip.co.uk (As opposed to from an Unknown) and route properly with the correct DID.


Need some Asterisk/FreePBX/Wildix help?
Contact us on support@hellocomtec.com or call +441752422950, option 2 or visit hellocomtec.com to chat with us.



Did you find this article useful?