I Configured a SIP Trunk in Asterisk—No More Call Drops | Brav

Set up a reliable SIP trunk in Asterisk with Firstcom Europe. Configure pjsip, dial plan, and avoid call drops. Step-by-step guide for small-business admins.

I Configured a SIP Trunk in Asterisk—No More Call Drops

Published by Brav

Table of Contents

TL;DR

  • I added a SIP trunk to my Asterisk server using Firstcom Europe.
  • I set up a static public IP, matched the provider’s IP range, and defined the trunk in pjsip.conf.
  • I created a clean outbound context that rings for 25 s and hangs up if unanswered.
  • I verified registration with pjsip show endpoints and saw Firstcom registered.
  • The result? No dropped calls, full inbound/outbound routing, and a script I can copy for any small-business PBX.

Why this matters

I was tired of hearing the “Ring, ring, hang up” chorus on every outbound call. The Asterisk server would register, but the call would drop or never connect. Small businesses like mine need reliable voice, but the cost of a full-fledged carrier can be a stretch. Choosing the right SIP trunk provider and configuring the trunk correctly is the fastest way to solve the problem.

Core concepts

ParameterUse CaseLimitation
SIP trunkConnect PBX to carrierRequires static IP and correct credentials
pjsip.confDefine trunk, endpoints, registrationsSyntax-heavy, errors hard to spot
extensions.confDial plan, outbound routingLimited to static rules, no dynamic routing

SIP trunk

A SIP trunk is a virtual circuit that connects your PBX to a carrier’s network. It looks like a phone line but uses IP packets.

pjsip.conf

Asterisk’s pjsip.conf is where trunks, endpoints, and registrations live. It is the file you edit to tell Asterisk how to talk to the carrier.

AOR (Address of Record)

The AOR is the URI that the server uses to identify itself. It must match what the carrier expects.

Identify section

The identify section matches the provider’s IP range so the server accepts inbound traffic only from the carrier. If you get “403 Forbidden”, check the IP block.

Context

A context is a logical grouping in the dial plan that dictates how calls are routed. It keeps inbound and outbound logic separate.

Pattern matching

Pattern matching lets you match an entire range of numbers with a single rule. For a UK business you’ll often need a pattern for 11-digit DIDs.

Ringtime

Ringtime is how long the destination rings before the call is hung up. A short ringtime can make it look like calls are dropping.

How to apply

Below is the step-by-step process I followed. Copy the snippets, adjust the values, and you’re good to go.

1. Prepare the server

ssh admin@asterisk-server
sudo apt update
sudo apt install asterisk

Verify you have Asterisk 16+ and pjsip support:

asterisk -rx 'core show version'

2. Create a trunk directory

sudo mkdir /etc/asterisk/trunks
cd /etc/asterisk/trunks

I keep all trunk files in one place so the main pjsip.conf stays tidy.

3. Write the Firstcom.conf file

The following file pulls together all the provider details and matches the requirements you read in the provider’s UI.

[Firstcom]
type=registration
transport=udp
outbound_auth=firstcom_auth
outbound_auth_user=1234
outbound_auth_password=5678
server_uri=sip:proxy.voip.co.uk:5060
client_uri=sip:[email protected]
retry_interval=60
direct_media=no
; The following AOR is what Firstcom expects us to register as
aor=Firstcom
; Match the provider's IP range so only they can register us
identify=firstcom
    type=ip
    uri=193.203.210.0/23

Firstcom Europe — Configuring PJSIP (2025) Firstcom Europe — Service Updates (2025) Cisco — SIP Trunk Configuration for VoIP.co.uk (2025) VoIP.co.uk — IP Block Info (2025) Asterisk — pjsip.conf Sample (2025)

4. Include the file in pjsip.conf

Add this line to your main pjsip.conf:

include=trunks/Firstcom.conf

Restart Asterisk so it reads the new file:

sudo asterisk -rx 'module reload'

5. Verify registration

asterisk -rx 'pjsip show endpoints'
asterisk -rx 'pjsip show registrations'

You should see a line that says Firstcom and Registered. If not, check the log file for errors.

6. Set up a static public IP

Your router or DHCP server must hand out the same IP to the Asterisk machine. I set a static lease in my router’s web UI. If the IP changes, the identify block will no longer match and you’ll lose registration.

Firstcom Europe — Business Connectivity (2025)

7. Create the outbound dial plan

Edit extensions.conf (or create outbound.conf if you prefer a separate file) and add:

[outbound]
exten => _[0-9]{11},1,Answer()
 same => n,Set(RINGTIME=25)
 same => n,Dial(PJSIP/${EXTEN}@Firstcom,30)
 same => n,Hangup()

This pattern matches any 11-digit number, answers the call, sets a 25-second ring, and then calls the SIP trunk.

Asterisk — Pattern Matching (2025) Asterisk — Channel Variables (2025) Asterisk — Configuring Outbound Registrations (2025)

8. Reload Asterisk again

sudo asterisk -rx 'dialplan reload'

9. Test the call

  1. From a softphone on extension 200, dial an 11-digit number.
  2. The call should ring for up to 25 s on the destination and then either connect or hang up.
  3. Check the logs to ensure no 403 or registration errors.

10. Keep an eye on logs

tail -f /var/log/asterisk/full | grep 'PJSIP'

This lets you spot problems quickly.

Pitfalls & edge cases

ProblemCauseFix
No registrationWrong server_uri or outbound_authDouble-check credentials
403 Forbiddenidentify IP block mismatchedUpdate the IP range or add the provider’s IP
Calls droppingUDP port 5060 blocked by firewallOpen port 5060 or change transport to TCP
Ringtime too shortRINGTIME set lowIncrease the value
Static IP changesDHCP lease changedReserve the same IP in your router

Sam from Sheridan Computers mentioned that the provider’s IP range can change after a firmware update, so I always keep the IP block in a variable file that I can tweak quickly.

Quick FAQ

QuestionAnswer
Who do you use for SIP trunk services throughout the UK?Firstcom Europe – reliable, no call drops.
What is the IP range for other providers such as Gamma?Check the provider’s portal or ask support; it varies.
How do you set a static public IP address for the Asterisk server?In your router, create a static DHCP lease for the server’s MAC.
What is the significance of the ‘context’ in the dial plan?It determines which set of rules Asterisk uses for a call.
How does the provider’s IP range affect registration and connectivity?The identify block only accepts traffic from that range; mismatch prevents registration.
How can I test the trunk without making a real call?Use asterisk -rx ‘pjsip show registrations’ and pjsip show endpoints.
Where can I find the provider’s SIP credentials?They’re in your account portal or provided by the support team.

Conclusion

If you’re a small-business IT staff, Asterisk admin, or PBX engineer, the steps above give you a proven, drop-free SIP trunk with Firstcom Europe. Once you’re comfortable, you can add more providers or move to a cloud-based PBX. If you run into trouble, Sam at Sheridan Computers can review your configuration or walk you through any of the steps.

Actionable next steps

  1. Follow the steps above to set up the trunk.
  2. Run pjsip show registrations to confirm you’re registered.
  3. Make a test call and watch the logs.
  4. Reach out to Sam or Firstcom support if something fails.

Happy calling!

References

Last updated: December 20, 2025

Recommended Articles

Asterisk Architecture Demystified: Build, Configure, and Scale Your PBX | Brav

Asterisk Architecture Demystified: Build, Configure, and Scale Your PBX

Discover how to master Asterisk’s modular architecture, configure channels, dial plans, and APIs. Build a scalable PBX from scratch with step-by-step guidance.