FreePBX and Asterisk are often installed correctly — but calls still fail because the firewall is missing 1–2 critical ports, or because too many ports are exposed to the internet.
This guide gives a production-safe firewall checklist for FreePBX + Asterisk, covering: SIP (UDP/TCP/TLS), RTP media, WebRTC, ARI, AMI, and the FreePBX admin UI — with practical commands for validation.
You will also learn the most common real-world problems: one-way audio, registration fails, WebRTC WSS not connecting, and “it works on LAN but fails from outside”.
Reference links used in this guide: Asterisk Official Docs, FreePBX Wiki, RFC 3261 (SIP), RFC 3550 (RTP), RFC 5764 (DTLS-SRTP).
The #1 production mistake is leaving SIP + Web UI open to the world without IP allowlisting. Asterisk boxes get scanned constantly.
This diagram shows why “SIP opens but no audio” happens: SIP (signaling) can connect on one port, but RTP (media) needs a whole UDP range.
If SIP is open but RTP range is blocked, calls may ring/answer but audio is silent or one-way.
Use this as your base reference. Always verify your own configured ports because deployments vary.
| Component | Port(s) | Protocol | Expose to Internet? | Why It’s Needed |
|---|---|---|---|---|
| FreePBX Admin UI | 80 / 443 | TCP | Prefer NO (or strict allowlist) | Web UI access (HTTP/HTTPS) |
| SIP (PJSIP / chan_sip) | 5060 | UDP (and sometimes TCP) | Only if required + allowlist | Call signaling for phones/trunks |
| SIP over TLS | 5061 | TCP | Only if required + allowlist | Encrypted SIP signaling |
| RTP Media | Typically 10000–20000 | UDP | Only if required + allowlist | Actual audio (RTP/SRTP) |
| Asterisk HTTP (ARI / AMI over HTTP, REST, WS/WSS) | 8088 / 8089 (common) | TCP | Prefer NO (internal only) | ARI + WebSocket + optional services (depends on config) |
| AMI (Asterisk Manager Interface) | 5038 | TCP | Never public (internal/VPN only) | Management/integration API (high risk if exposed) |
| IAX2 (optional) | 4569 | UDP | Only if used | Alternative trunking protocol |
If you are using WebRTC clients (browser phones), you will usually need HTTPS + WSS reachable, and correct RTP handling (often SRTP). The exact WebRTC ports depend on your stack and whether you proxy WSS via NGINX.
Many teams open the “standard” ports but their server is listening somewhere else. Run these checks first.
sudo ss -lntup
sudo ss -lnup | grep -E '5060|5061|5038|8088|8089|443|80'
sudo asterisk -rx "pjsip show transports"
sudo asterisk -rx "pjsip show settings"
sudo asterisk -rx "rtp show settings"
If your RTP range is not 10000–20000, open the range shown by rtp show settings (and update your firewall accordingly).
Production best practice:
If you cannot allowlist (dynamic remote agents), use VPN. Opening SIP to the full internet is a high-risk choice.
If you use UFW, start from a deny-by-default policy, then allow only required ports. Replace IPs with your real office/VPN/carrier IPs.
sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw allow from 203.0.113.10 to any port 22 proto tcp
sudo ufw allow from 203.0.113.10 to any port 443 proto tcp
# SIP
sudo ufw allow from 198.51.100.20 to any port 5060 proto udp
sudo ufw allow from 198.51.100.20 to any port 5060 proto tcp
# SIP TLS (only if you use it)
sudo ufw allow from 198.51.100.20 to any port 5061 proto tcp
# RTP range (match your rtp.conf)
sudo ufw allow from 198.51.100.20 to any port 10000:20000 proto udp
sudo ufw enable
sudo ufw status verbose
If you have multiple provider IPs, repeat the allow rules per IP. Avoid “allow from any”.
Many Debian/Ubuntu servers now use nftables. Below is a minimal example conceptually. You should integrate into your existing nftables policy instead of pasting blindly.
# View existing ruleset
sudo nft list ruleset
Minimal inbound allowlist idea (example only):
sudo nft add table inet filter
sudo nft add chain inet filter input { type filter hook input priority 0 \; policy drop \; }
# Allow established traffic
sudo nft add rule inet filter input ct state established,related accept
# Allow loopback
sudo nft add rule inet filter input iif lo accept
# Allow SSH from trusted admin IP
sudo nft add rule inet filter input ip saddr 203.0.113.10 tcp dport 22 accept
# Allow HTTPS admin UI from trusted IP
sudo nft add rule inet filter input ip saddr 203.0.113.10 tcp dport 443 accept
# Allow SIP + RTP from provider IP
sudo nft add rule inet filter input ip saddr 198.51.100.20 udp dport 5060 accept
sudo nft add rule inet filter input ip saddr 198.51.100.20 tcp dport 5060 accept
sudo nft add rule inet filter input ip saddr 198.51.100.20 tcp dport 5061 accept
sudo nft add rule inet filter input ip saddr 198.51.100.20 udp dport 10000-20000 accept
You must also ensure the nftables rules persist on reboot (method depends on your distro setup).
FreePBX includes a firewall module in many editions. If you use it:
If you are unsure, apply OS firewall rules first (UFW/nftables) and then carefully align FreePBX firewall rules.
This is almost always RTP blocked or NAT misconfigured:
sudo asterisk -rx "rtp show settings"
sudo asterisk -rx "pjsip show settings"
sudo asterisk -rx "pjsip show transports"
# Replace eth0 with your interface
sudo tcpdump -n -i eth0 udp portrange 10000-20000
If SIP works but tcpdump shows no RTP traffic during a live call, your RTP range is blocked upstream.
Firewall changes can cause SIP to look like “auth failures” because packets are missing or source IP changes. Common causes:
sudo asterisk -rx "pjsip show registrations"
sudo asterisk -rx "pjsip set logger on"
Watch logs during registration. If you see no inbound responses, it’s often network/firewall — not credentials.
WebRTC introduces additional requirements:
Typical symptoms:
sudo asterisk -rx "http show status"
If your WebRTC stack uses NGINX as a reverse proxy, confirm you allow WebSocket upgrade headers and the correct backend port (commonly 8088/8089 depending on setup).
If you are integrating tools like dialers, CRMs, or AI calling (ARI/AMI), these are the key points:
sudo ss -lntp | grep 5038
sudo asterisk -rx "manager show settings"
sudo ss -lntp | grep -E "8088|8089"
sudo asterisk -rx "http show status"
If your integration server is separate, connect it over VPN or private LAN.
This is the safest real-world pattern: expose as little as possible publicly, and use VPN for admin + internal APIs.
Security is not just “open the right ports” — it is “open the minimum ports” and restrict who can reach them.
# On a remote machine (replace IP)
nc -vz your-public-ip 443
nc -vz your-public-ip 5061
# UDP checks are trickier; use packet capture + Asterisk logs for SIP UDP
sudo asterisk -rx "pjsip set logger on"
sudo tcpdump -n -i eth0 udp portrange 10000-20000
With these three checks, you can quickly tell whether the problem is: (a) signaling, (b) media, or (c) a routing/NAT issue.
A correct FreePBX + Asterisk firewall is not “open everything telecom-related.” It is: open only what your topology requires, restrict by IP, and validate with real SIP + RTP tests.
If you want, next we can produce a companion article: “Router Configuration for SIP/VoIP: NAT, Port Forwarding, and SIP ALG” to cover the upstream side of the same issues.