Asterisk SIP Trunk Configuration Guide

Use this Asterisk configuration cookbook to generate working examples for PJSIP, chan_sip, SIP peering / IP authentication, and IAX2. Enter your Tel2 trunk details, choose your protocol, select your codec and transport preferences, then copy the generated configuration into your Asterisk files.

This guide is designed for engineers, developers, resellers, and businesses running their own Asterisk, FreePBX, or open-source PBX platform. If you need a reliable UK-based SIP trunk provider with Asterisk-aware support, Tel2 can help with both the trunk and the technical setup.

Need an Asterisk SIP trunk?

Tel2 provides SIP, IAX2, and SIP peering connectivity for Asterisk and FreePBX systems, with support from engineers who understand real PBX deployments.

View Asterisk SIP Trunking View SIP Trunk Pricing

Build your Asterisk configuration

Basic settings

Advanced settings

Important Asterisk configuration notes

This generator produces a strong starting point, but your local dialplan, firewall, NAT, TLS certificates, RTP settings, and PBX security settings may require further changes. Do not publish real SIP or IAX2 passwords in screenshots, support tickets, or public forums.

For IAX2, if your incoming context is not from-trunk, update the IAX2 context in the Tel2 Portal under Preferences > Voice Quality & Networking.


Asterisk SIP Trunk Setup Options

Asterisk can connect to Tel2 in several ways. The best option depends on your PBX version, network design, firewall rules, and whether you want to use username/password registration or IP authentication.

PJSIP

Recommended for most modern Asterisk systems. PJSIP is flexible, actively used, and suitable for new SIP trunk deployments.

chan_sip

Best reserved for legacy Asterisk systems that still use the older SIP driver. New installations should normally use PJSIP.

SIP Peering

Uses IP authentication instead of a SIP password. This is often preferred for fixed-location PBX platforms and wholesale-style deployments.

IAX2

Useful for Asterisk-to-Asterisk connectivity, simple firewall traversal, and efficient trunking when multiple calls are active.

Asterisk PJSIP Configuration Example

PJSIP is the preferred SIP stack for modern Asterisk installations. A basic PJSIP trunk configuration normally includes a transport, registration, authentication object, AOR, endpoint, and identify section.

; Example only - replace placeholders with your own Tel2 details

[simpletrans-udp]
type=transport
protocol=udp
bind=0.0.0.0

[tel2-registration]
type=registration
transport=simpletrans-udp
outbound_auth=tel2-auth
server_uri=sip:sip.tel2.co.uk:5060
client_uri=sip:441234567890@sip.tel2.co.uk
retry_interval=60

[tel2-auth]
type=auth
auth_type=userpass
password=yourpassword
username=441234567890

[tel2-aor]
type=aor
contact=sip:sip.tel2.co.uk:5060

[tel2-endpoint]
type=endpoint
transport=simpletrans-udp
context=from-external
disallow=all
allow=alaw
allow=ulaw
outbound_auth=tel2-auth
aors=tel2-aor
from_user=441234567890

[tel2-identify]
type=identify
endpoint=tel2-endpoint
match=sip.tel2.co.uk

Asterisk chan_sip Configuration Example

chan_sip is the older Asterisk SIP driver. It is still found on many legacy systems, but for new deployments, PJSIP is normally the better option.

; Example only - replace placeholders with your own Tel2 details

[general]
registerattempts=0
registertimeout=20
register => 441234567890:yourpassword@sip.tel2.co.uk/441234567890

[Tel2]
type=friend
username=441234567890
fromuser=441234567890
secret=yourpassword
host=sip.tel2.co.uk
context=from-trunk
dtmfmode=rfc2833
disallow=all
allow=alaw
allow=ulaw
nat=yes
canreinvite=no
insecure=invite,port

Asterisk IAX2 Trunk Configuration Example

IAX2 can be useful for Asterisk deployments where simple firewall handling is important. IAX2 signalling and media use UDP port 4569, which can make it easier to manage than SIP/RTP in some network environments.

; Example only - replace placeholders with your own Tel2 details

[general]
bindport=4569
bandwidth=low
disallow=all
allow=alaw
allow=ulaw
trunkfreq=20
trunktimestamps=yes
tos=ef

register => 441234567890:yourpassword@iax2.tel2.co.uk

[441234567890]
type=friend
username=441234567890
trunk=yes
context=from-trunk
host=iax2.tel2.co.uk
port=4569
secret=yourpassword
auth=md5
disallow=all
allow=alaw
allow=ulaw

Asterisk Troubleshooting Guide

PJSIP not registering

If your PJSIP trunk is not registering, check the username, password, SIP host, transport, and port. Also confirm that your firewall allows outbound SIP traffic and that your PBX can resolve the Tel2 SIP hostname.

No inbound calls

If outbound calls work but inbound calls do not, check your incoming context, endpoint identify match, firewall rules, and whether the inbound call is reaching Asterisk at all.

One-way audio

One-way audio is usually caused by NAT, RTP, or firewall issues. Check your external address, local network settings, RTP port range, and any SIP ALG settings on the router.

DTMF problems

DTMF issues often relate to mismatched DTMF modes. For SIP trunks, RFC2833 / RTP events are commonly used. IAX2 handles DTMF differently and can be simpler in some Asterisk-to-Asterisk scenarios.

IAX2 connection problems

For IAX2, ensure UDP port 4569 is open and that the correct username, password, host, and context are configured. If calls connect but behave unexpectedly, check the IAX2 debug output in the Asterisk CLI.

Asterisk CLI Commands for Debugging

The Asterisk command line is often the fastest way to identify SIP trunk registration, authentication, NAT, and routing issues.

; PJSIP registration status
asterisk -rvvv
pjsip show registrations
pjsip show endpoints
pjsip set logger on

; chan_sip registration status
sip show registry
sip show peers
sip set debug on

; IAX2 status and debugging
iax2 show registry
iax2 show peers
iax2 set debug on

Asterisk SIP Trunk Security Tips

  • Use strong SIP and IAX2 passwords.
  • Restrict SIP access by IP address where possible.
  • Do not expose unnecessary PBX services to the public internet.
  • Disable international or premium-rate destinations unless required.
  • Monitor call usage for unusual patterns.
  • Keep Asterisk, FreePBX, and the operating system updated.

Asterisk SIP Trunk FAQ

What is the best SIP driver for Asterisk?

PJSIP is recommended for most modern Asterisk systems. chan_sip is legacy and should generally only be used where an older system depends on it.

Can I use Asterisk with SIP peering / IP authentication?

Yes. SIP peering uses trusted IP addresses instead of username/password registration. It is commonly used for fixed PBX platforms and larger deployments.

Does Tel2 support IAX2?

Yes. Tel2 supports IAX2 for Asterisk systems, including IAX2 registration and trunking options.

Which codecs should I enable?

alaw and ulaw are safe starting points for most SIP trunk setups. Other codecs such as GSM, iLBC, and G.729 may be useful depending on bandwidth, compatibility, and licensing requirements.

Can this guide be used for FreePBX?

Yes. FreePBX uses Asterisk underneath, so the same SIP trunk concepts apply. However, FreePBX normally stores and manages the configuration through its web interface rather than direct file editing.