How-to guide

Connect FreePBX, FusionPBX, or Asterisk to Cloud SIP

Short answer

Add your SIP domain as a trunk or gateway that doesn't register, accept calls from both Enfonica signaling addresses, and use +E.164 numbers for caller IDs and inbound routes. Then point your phone numbers at the PBX through a load balancer in the Enfonica Console.

Applies to
Cloud SIP, Phone Numbers
Works with
FreePBX, FusionPBX, Asterisk with chan_pjsip
Who can do this
Whoever manages your PBX and your Enfonica project
On this page
  1. Before you start
  2. How these PBXs connect to Cloud SIP
  3. Create your SIP domain
  4. Asterisk and FreePBX (chan_pjsip)
  5. FusionPBX
  6. Allow Enfonica through your firewall
  7. Send incoming calls to your PBX
  8. Check that it worked
  9. Questions
  10. What to send us
  11. Related

Before you start

  • An Enfonica project with the phone numbers you want the PBX to use.
  • Admin access to your PBX, and to its configuration files if you run Asterisk directly.
  • Your PBX's public IP address, or a dynamic DNS name if the address changes.
  • Access to the firewall in front of the PBX, or the person who manages it.

How these PBXs connect to Cloud SIP

FreePBX is built on Asterisk, and FusionPBX is built on FreeSWITCH. All three connect to Cloud SIP the same way. Your PBX (private branch exchange, your phone system) sends outgoing calls to your SIP domain, which is your SIP trunk on Enfonica. Cloud SIP sends incoming calls to the address you give it in the Console.

The PBX doesn't register to Cloud SIP. Cloud SIP recognizes your outgoing calls by the SIP domain in each call, plus your PBX's public IP address, a username and password, or both. A trunk or gateway set to register gets 405 Method not allowed.

This guide gives the value each setting needs. FreePBX and FusionPBX lay out their settings differently between releases, so match each value to the field that sets it on your system.

Create your SIP domain

  1. Sign in to the Enfonica Console, and go to Cloud SIP.
  2. Select New SIP domain, and create a Standard SIP domain, such as acme-pbx. It's ready instantly, with a name like acme-pbx.sip.enfonica.com.
  3. Under Termination settings, set Call termination mode to PSTN Trunk, so that outgoing calls go to the phone network.
  4. Choose how Cloud SIP knows that a call is yours:
    • If your PBX has a static public IP address, under IP access control list, select Add IP range, and enter the address with /32 on the end, for example 203.0.113.10/32.
    • If its address changes, leave the IP list empty. Under Users, select Add user, and create a username and password instead.
    • You can also use both. A call must then come from a listed address and carry the password.
  5. Select Save Changes. Changes take up to a minute to apply.

Asterisk and FreePBX (chan_pjsip)

Use a chan_pjsip trunk with no registration. On Asterisk, this pjsip.conf example has everything the trunk needs. Replace acme-pbx with your SIP domain. If you authenticate by IP address only, leave out outbound_auth and the [enfonica-auth] section.

[enfonica]
type=endpoint
transport=transport-udp
context=from-enfonica
disallow=all
allow=alaw,ulaw
outbound_auth=enfonica-auth
aors=enfonica
from_domain=acme-pbx.sip.enfonica.com

[enfonica-auth]
type=auth
auth_type=userpass
username=your-username
password=your-password

[enfonica]
type=aor
contact=sip:acme-pbx.sip.enfonica.com
qualify_frequency=60

[enfonica-identify]
type=identify
endpoint=enfonica
match=34.87.239.197,34.87.254.143

Make sure that the transport-udp transport and the from-enfonica context exist elsewhere in your configuration. Incoming calls from Enfonica arrive in that context.

In FreePBX, you set the same options on the chan_pjsip trunk's screens. Field names vary between releases, so match each value in this table to the field that sets it.

What the setting doesValuepjsip option
Where outgoing calls goYour SIP domain, for example acme-pbx.sip.enfonica.com, port 5060contact
The domain in the From headerYour SIP domainfrom_domain
RegistrationNoneNo registration section
AuthenticationOutbound only, with your SIP user's username and password, or none for IP-onlyoutbound_auth
Which addresses incoming calls come from34.87.239.197 and 34.87.254.143match
CodecsG.711 A-law and u-law (G.729 also works)allow

Next, set up the calls themselves:

  • Outgoing calls. Send them to the trunk, for example with Dial(PJSIP/${EXTEN}@enfonica) in Asterisk, or with an outbound route that uses the trunk in FreePBX.
  • Caller ID. Set every outgoing call's caller ID to a number you hold, in +E.164 (full international format with a plus), for example +61255501234. In Asterisk, add Set(CALLERID(num)=+61255501234) before the Dial.
  • Incoming calls. Cloud SIP sends numbers in +E.164, so create an inbound route for each number in that format, such as +61255501234.

FusionPBX

FusionPBX connects through a gateway for outgoing calls and an access control list for incoming calls.

  1. Add a gateway, with your SIP domain as the address it sends calls to, for example acme-pbx.sip.enfonica.com. If you created a SIP user, enter its username and password.
  2. Set the gateway's Register to False.
  3. Go to Advanced > Access Controls, and open Providers.
  4. Add a node with type allow, CIDR 34.87.239.197/32, and the domain left empty.
  5. Add a second node with type allow, CIDR 34.87.254.143/32, and the domain left empty.
  6. Select Reload ACL.
  7. Create your inbound routes with each number in +E.164, for example +61255501234.
  8. Set outbound caller IDs in the same format.

FusionPBX is multi-tenant, so one server can keep many customers apart, such as households on a residential voice service. FreePBX is single-tenant. On a shared FreePBX, you'd need to stop one customer's extensions from calling another's.

Allow Enfonica through your firewall

Cloud SIP sends call signaling and call audio from different addresses. In the firewall in front of your PBX, allow all four addresses in both directions. Include any cloud provider firewall.

TrafficIP addressesPorts
Signaling34.87.239.197
34.87.254.143
5060 (UDP), 5061 (TLS)
Media (call audio)35.189.19.106
35.189.6.179
All UDP ports

Cloud SIP supports UDP and TLS, not TCP. Some SIP messages are large enough to be split into fragments, so allow UDP fragments as well. For more information, see Firewall configuration for Cloud SIP.

Send incoming calls to your PBX

Because the PBX doesn't register, you need to tell Cloud SIP where it is. Create a load balancer once, and then point each number at it.

  1. In the Console, go to Cloud SIP, and open your SIP domain.
  2. Under Load balancers, select Add load balancer, and enter an Alias ID, such as pbx.
  3. Select Add endpoint.
  4. In Endpoint URI, after the sip: that's already shown, enter your PBX's public IP address or hostname, for example 203.0.113.10 or pbx.example.com. If the address changes, use a dynamic DNS name.
  5. Select Add, select Save, and then select Save Changes.
  6. Go to Phone Numbers > My numbers, and open a number.
  7. Under Call settings, in Incoming call handlers, select Add, and then select SIP.
  8. Select Load balancer, and then select your load balancer.
  9. Select Save Changes.

Repeat steps 6 to 9 for each number.

If you delete a load balancer, numbers that pointed at it stop receiving calls. Move them to the new load balancer first.

Check that it worked

  1. On Asterisk, run pjsip show aors. The Enfonica contact shows as available, because Cloud SIP answers your PBX's keepalive checks.
  2. Call a mobile from an extension. The mobile rings and shows your caller ID.
  3. Call one of your Enfonica numbers from a mobile. It rings on your PBX, and you can hear each other both ways.
  4. In the Console, go to Cloud Voice > Calls. Both test calls are listed there with their SIP traces.

If a test call fails, its SIP response code points to the cause. To find the code, see Find a call and read its SIP trace. To learn what each code means, see Outbound calls aren't going through. When numbers fail to dial, the format is often the cause. For every format, see Which number format should my PBX use?

Questions

My PBX says the trunk can't register. What's wrong?

Nothing is wrong with the trunk. Cloud SIP doesn't accept registration, so turn registration off:

  • On Asterisk, remove the registration section.
  • In FreePBX, choose no registration on the trunk.
  • On a FusionPBX gateway, set Register to False.

Calls still authenticate with your IP address or your username and password.

Incoming calls never reach the PBX. Where do I look?

Open the call in Cloud Voice > Calls. If its SIP trace shows Cloud SIP sending the call with no reply from your PBX, a firewall in front of the PBX is almost always the cause. Make sure that both signaling addresses are allowed, including in your cloud provider's firewall. For other causes, see Calls aren't reaching your PBX.

My PBX is on site behind NAT, with an address that changes. Will it work?

Yes, with two changes:

  • Use a username and password for outgoing calls.
  • Give the load balancer a dynamic DNS name that follows your address, and have your router forward SIP to the PBX.

It's simpler to host the PBX in the cloud with a static IP address, and connect your on-site handsets to it.

Can I connect handsets or softphones directly to Cloud SIP?

No. Cloud SIP is a trunk for phone systems and doesn't accept registrations. Register handsets, softphones, and ATAs (analog telephone adapters) to your PBX as extensions. The PBX connects them to the phone network through Cloud SIP.

What to send us

Include these and we can find the call straight away.

  • The number that made the call and the number it called, in full international format (for example +61255501234).
  • The date and time of the call, with your timezone.
  • Whether the call was inbound or outbound.
  • The call ID, if the Console shows the call.
  • What happened: an error message, silence, a busy tone or a dropped call.
Contact support

Our support team are telco specialists, backed by the engineers who run the network.