Numbers

SIP trunk setup on an IP PBX: 3CX, Yeastar, FreePBX

How to configure a SIP trunk on your IP PBX step by step: registration or IP authentication, settings in 3CX, Yeastar and FreePBX, codecs and the usual faults.

OV

OVOKY Team

· 4 min read

Antique brass skeleton key on a ring with a plum tag, on a warm gray background

Setting up a SIP trunk connects your IP PBX to a provider so it can make and receive calls on the public phone network. It only takes a handful of fields, as long as you have the right details at hand and pick the right connection method. This guide covers what to ask your provider for, how to configure a SIP trunk in 3CX, Yeastar and FreePBX, and what causes the most common faults: calls with no audio, rejected registrations and calls that drop after 30 seconds.

If you're new to the subject, start with our guide to SIP trunking, which explains how a trunk works, what channels are and what it costs.

Before you start: the details to collect

Hand taking notes in a notebook beside a closed laptop and a coffee cup

Depending on the connection method, your SIP trunk provider gives you:

DetailRegistrationIP authentication
SIP server address (hostname or IP) and portYesYes
Username and passwordYesNo
Your IP PBX's public IP address, registered with the providerNoYes
Transport (UDP, TCP or TLS)YesYes
Supported codecsYesYes
DID numbers assigned to the trunkYesYes

On your side, note the public IP address of your site or server, and make sure it is static if you're going with IP authentication.

Registration or IP authentication: which one?

Office receptionist checking an ID card and handing over a visitor badge

There are two ways for the provider to recognize your IP PBX:

  • Registration: the IP PBX checks in with the provider's server at regular intervals using a username and password, much like a phone signing in to an account. It is the simplest option when your IP address changes or the PBX sits behind an ISP router.
  • IP authentication: the provider accepts traffic coming from your IP PBX's public IP address, with no username. It suits a PBX hosted in a data center or behind a static IP, and high call volumes.

Either way, use a long, unique password and restrict international calling on the PBX to the destinations you actually need: the first thing a hacked trunk is used for is calling premium-rate numbers abroad.

Configuring the trunk in 3CX

System administrator typing at a standing desk with a headset around her neck

In the 3CX admin console, trunks are created from Admin > Voice & Chat > Add Trunk, where you choose the country and the provider. If your provider has no ready-made template, 3CX offers two generic types:

  • Generic VoIP Provider (Registration), for a trunk with a username and password;
  • Generic SIP Trunk (IP-Based), for a trunk authenticated by IP address.

Then enter the SIP server address and port, and the authentication mode: "Register/Account based", with the authentication ID and password, or "Do not require - IP Based". Finally, add your DID numbers and your inbound and outbound call rules.

Configuring the trunk in Yeastar (P-Series)

Technician plugging an Ethernet cable into a small phone system appliance

On a Yeastar P-Series PBX, go to Extension and Trunk > Trunk and click Add. Select the General provider template, then the trunk type:

  • Register Trunk: a trunk with a username and password. Fill in the transport, hostname or IP address, port, domain, username, password and authentication name. This type requires at least one DID number.
  • Peer Trunk: a trunk authenticated by the PBX's IP address and port.

Then assign the DID numbers and create your inbound and outbound routes.

Configuring the trunk in FreePBX or Asterisk

Two engineers working at an open server rack in a data center

In FreePBX, open the Trunks module and choose Add SIP (chan_pjsip) Trunk. The pjsip Settings > General tab holds the key fields: Username, Secret (the password), Registration, SIP server and port, context (usually from-pstn) and transport.

On a hand-configured Asterisk, a PJSIP trunk is built from several sections: transport, registration, auth, aor, endpoint and identify. Use outbound_auth rather than auth on the endpoint, because it is your PBX that authenticates with the provider, not the other way around, and add an identify section to match all traffic coming from the provider's IP address to the trunk.

Don't build on the old chan_sip driver: it has been deprecated since Asterisk 17 and was removed in Asterisk 21.

Which codecs to enable

Close-up of a contact center agent adjusting her headset microphone

Enable the codecs your provider supports on the trunk, in order of preference:

CodecWhat it offersBandwidth per call
G.711The reference phone quality, uncompressedabout 87 kbps
G.729Compressed voice that saves bandwidthabout 31 kbps
OpusQuality that adapts to the available bandwidth6 to 510 kbps

If the caller and the called party share no codec, the call fails or has to be transcoded: keep G.711 enabled as a fallback.

Common faults and their causes

Technician crouching under a desk inspecting an internet router with a flashlight
SymptomLikely causeWhat to do
Registration is rejectedWrong username, password or domainRe-enter the credentials you were given, and check the authentication name and domain
Inbound calls rejected with IP authenticationThe IP address registered with the provider isn't the PBX'sCheck your public IP and have the provider update it
The call connects but there's no audio, or audio in one direction onlyNetwork address translation (NAT) handled badly, often by the router's SIP ALGDisable SIP ALG and open the PBX's RTP ports
The call drops after about 30 secondsConfirmation messages don't reach the PBX, often for the same reasonDisable SIP ALG and check the PBX's NAT settings
"Codec not supported"No codec in common with the providerEnable G.711 on the trunk
Outbound calls fail to some countriesDestinations blocked on the PBX or by the providerCheck your outbound routes and allowed destinations

SIP ALG, a feature found on many routers, including the ones internet providers supply, is meant to help VoIP by rewriting SIP messages. In practice, it often corrupts them: Yeastar and 3CX both recommend turning it off.

Test before going live

Two colleagues testing a call, one on a mobile and one on a desk phone
  1. Check the registration in the PBX's trunk status, if you're using registration.
  2. Call a mobile from an internal extension, and make sure audio flows both ways.
  3. Call one of your DID numbers from a mobile, and check the call reaches the right extension.
  4. Look at the caller ID shown on the mobile you called: it's the number your customers will see.
  5. Keep a call going for more than a minute to rule out drops at 30 seconds.
  6. Test failover: if your provider offers backup routing, unplug the PBX and call a DID number.

The OVOKY SIP trunk

Busy contact center with agents in headsets and a team lead walking between desks

The OVOKY SIP trunk is built for businesses keeping their IP PBX and for VoIP operators:

  • Connection by IP authentication or by registration (SIP username and password).
  • G.711, G.729 and Opus codecs.
  • Channels (simultaneous calls) sized to your traffic.
  • Calls to destinations worldwide, and numbers in France, Belgium, Switzerland, Spain and Canada.
  • Failover routing for inbound calls when the PBX or the link is down.

Pricing is by quote. Number porting isn't offered: your current lines can be forwarded to your new numbers.

  • SIP trunk
  • SIP trunk setup
  • IP PBX
  • 3CX
  • FreePBX
Share

Questions readers ask

Short answers to what teams ask us most. Something else on your mind? Talk to us

  • In the 3CX console, open Admin > Voice & Chat > Add Trunk and choose your country and provider, or a generic type: "Generic VoIP Provider (Registration)" for a trunk with a username, "Generic SIP Trunk (IP-Based)" for a trunk authenticated by IP. Enter the SIP server and the authentication mode, then your DID numbers and call rules.

  • With registration, the IP PBX signs in to the provider with a username and password: the simplest option behind an ISP router or with an IP address that changes. With IP authentication, the provider accepts traffic from the PBX's public IP address, with no username: the right fit for a PBX in a data center or on a static IP.

  • Most often, the router handles network address translation (NAT) badly, especially through SIP ALG, which rewrites SIP messages. Disable SIP ALG on the router and make sure the PBX's RTP ports are open.

  • Yes, in most cases. Yeastar and 3CX both recommend turning off the router's SIP ALG, because it alters SIP messages and causes calls with no audio, drops after 30 seconds or failed registrations.

Bring every customer conversation into one place

Calls, SMS, WhatsApp, email and chat in one inbox, on one invoice. Start with one team and add the others when you're ready.