Asterisk PJSIP: Setting up network (Latest Versions)
Updated guide for modern Asterisk (PJSIP era): setting up network with real configs, common mistakes, and troubleshooting steps.
Setting up the network correctly is the first and most critical step in any modern Asterisk deployment.
Most call failures, one-way audio issues, registration errors, and random disconnections are not caused by dialplan mistakes — they are caused by incorrect network configuration.
This guide explains how to configure networking for latest Asterisk versions using PJSIP, with real production-safe practices.
Why Network Configuration Matters in Asterisk
- SIP signaling depends on correct IP routing
- RTP audio requires open UDP port ranges
- NAT misconfiguration causes one-way or no audio
- Firewalls silently block providers or phones
Without proper networking, even a perfect dialplan will never work reliably.
Understand the Three Network Layers in Modern Asterisk
Asterisk networking must be correct at three levels:
- Operating System Network – IP address, routing, DNS
- Firewall Rules – SIP + RTP ports allowed
- PJSIP Transport Settings – External IP and NAT handling
Missing configuration in any one layer breaks calls.
Step 1 — Verify Server IP and Connectivity
First confirm the Linux server has a stable IP.
ip a
ip route
ping 8.8.8.8
Production telecom servers should use:
- Static private IP (LAN deployments)
- Static public IP (cloud or SIP trunk usage)
Step 2 — Open Required Firewall Ports
Modern Asterisk with PJSIP requires:
- 5060 / 5061 UDP/TCP → SIP signaling
- 10000-20000 UDP → RTP media audio
- 8088 / 8089 → HTTP / WebSocket (ARI, WebRTC)
Example using UFW:
sudo ufw allow 5060/udp
sudo ufw allow 5061/tcp
sudo ufw allow 10000:20000/udp
sudo ufw allow 8088/tcp
sudo ufw allow 8089/tcp
sudo ufw reload
Step 3 — Configure RTP Port Range
RTP settings are defined in:
/etc/asterisk/rtp.conf
[general]
rtpstart=10000
rtpend=20000
Ensure the firewall allows the same range.
Step 4 — Configure PJSIP Transport for NAT
Modern Asterisk uses: /etc/asterisk/pjsip.conf
[transport-udp]
type=transport
protocol=udp
bind=0.0.0.0:5060
external_media_address=YOUR_PUBLIC_IP
external_signaling_address=YOUR_PUBLIC_IP
local_net=192.168.0.0/16
These values tell Asterisk:
- What IP to advertise to SIP providers
- Which networks are internal (no NAT)
Common NAT Mistakes That Break Calls
- Wrong public IP in PJSIP transport
- Firewall blocking RTP return traffic
- Router SIP ALG enabled (must disable)
- Dynamic public IP changing frequently
These cause:
- One-way audio
- No audio after 30 seconds
- Calls dropping randomly
How to Test Network Configuration Safely
Useful Asterisk CLI commands:
asterisk -rvvv
pjsip show transports
pjsip show endpoints
rtp set debug on
You should verify:
- Correct external IP visible
- RTP packets flowing both directions
- No firewall packet drops
Production Best Practices
- Always use static public IP for SIP trunks
- Disable SIP ALG in routers
- Restrict firewall by provider IP when possible
- Monitor RTP with tcpdump during issues
Telecom reliability depends more on network stability than dialplan logic.
Key Takeaway
If networking is wrong, nothing else matters.
Correct firewall rules, RTP range, NAT configuration, and public IP handling are the true foundation of every successful Asterisk deployment.
Fix the network first — the rest of the system becomes predictable.
Want to see API-driven CRM + Telecom workflows in action? Try the WhatsApp bot or explore the demos.
Comments (0)
Be the first to comment.