Troubleshooting
SIP ALG: What It Is and Why You Should Usually Disable It
On this page
SIP ALG (Application Layer Gateway) is a router or firewall feature that inspects SIP traffic and rewrites the IP addresses and ports inside SIP messages, to help VoIP work through NAT. It sounds helpful. In practice it's one of the most common causes of broken VoIP, and most VoIP providers tell you to switch it off.
What SIP ALG is supposed to do
NAT rewrites the IP addresses in packet headers, but SIP also carries addresses inside the message: in Via, Contact and the SDP. A phone behind NAT announces its private address there, so the far end doesn't know where to reach it. SIP ALG tries to fix this by rewriting those internal addresses to the router's public IP and opening firewall pinholes for the audio.
Why it causes problems
- Inconsistent implementations. Many ALGs only rewrite some headers, or handle UDP but not TCP, leaving messages that contradict themselves.
- It fights with proper NAT handling. Modern PBXs, phones and SBCs already handle NAT (rport, symmetric RTP, STUN, external address settings). Double-fixing breaks things.
- It can corrupt messages. Wrong Content-Length after rewriting, mangled SDP, or changed ports can cause 400 Bad Request errors.
- It can't see encrypted SIP. With SIP over TLS the ALG can't read anything, so it's useless at best.
Symptoms that point to SIP ALG
- One-way audio, or no audio, on some calls (see fixing one-way audio).
- Calls dropping after about 30 seconds.
- Phones randomly unregistering, or registering but not receiving inbound calls.
- Transfers or hold failing, with 481 errors.
- Problems that disappear when the phone is moved to a different network, such as a mobile hotspot.
How to tell for sure
Capture the same SIP message on both sides of the router, for example on the phone (or a PC on the LAN) and on the PBX or provider side. If the Contact header or SDP c= line has been changed in transit and your PBX isn't doing it, an ALG is rewriting the packets.
How to disable SIP ALG
The setting lives in different places on different devices. Common locations:
- MikroTik: IP → Firewall → Service Ports → disable sip. From the terminal:
/ip firewall service-port disable sip - pfSense / OPNsense: no SIP ALG by default, but use static outbound NAT port mapping for the PBX so source ports stay the same.
- Fortinet FortiGate: the SIP session helper and VoIP profile. Removing the session helper (
config system session-helper) and settingdefault-voip-alg-mode kernel-helper-basedunderconfig system settingsare the usual steps. Check Fortinet's docs for your firmware version. - Cisco ASA:
no inspect sipunder the global policy-map. - Consumer and ISP routers: look under Advanced, NAT, Firewall or ALG for "SIP ALG", "SIP helper" or "SIP passthrough". Some ISP-supplied routers hide it, so ask your ISP or replace the router.
After disabling it, reboot the router (or clear connection tracking) so old SIP sessions are dropped, then re-register the phones.
When SIP ALG might help
Very occasionally, with simple old devices that have no NAT support of their own and a router whose ALG works correctly, it can help. If everything works with it switched on, leave it. But if you see any of the symptoms above, turning it off is the first thing to try.
What to use instead of SIP ALG
Turning the ALG off only helps if something else handles NAT properly. Use one or more of these:
- NAT settings on the PBX. Tell the PBX its public address and which networks are local, and enable symmetric RTP and rport for endpoints behind NAT. The one-way audio guide lists the Asterisk and FreePBX settings.
- Keep-alives on phones. Phones behind NAT should send regular keep-alive packets or re-register often enough to keep the router's pinhole open.
- An SBC or media relay. For many remote users, a session border controller or RTP relay on a public address fixes signalling and media centrally.
- SIP over TLS. Encrypted signalling on port 5061 can't be read or rewritten by an ALG, so it sidesteps the problem completely, and protects credentials too.
Some people move SIP to a non-standard port (not 5060) because many ALGs only inspect the standard port. That can work as a quick workaround, but it doesn't fix the underlying NAT handling, so treat it as temporary.
After you disable it: a quick checklist
- Reboot the router or clear its connection table so old, rewritten sessions are gone.
- Re-register phones and trunks, and confirm registrations stay up past their expiry time.
- Make test calls in both directions, including a call longer than one minute, and test hold and transfer.
- Check an inbound call to a phone that has been idle for a while, which proves the NAT pinhole is being kept open.
- If something still fails, capture a trace and compare the Contact and SDP addresses on both sides of the router.
Try the SIP Response Codes
Every SIP status code from 100 to 608, with plain-English meanings, causes, fixes and example traces.
Keep reading
How to Fix One-Way Audio on VoIP Calls
One side can't hear the other? A step-by-step guide to fixing one-way and no-audio VoIP calls caused by NAT, SIP ALG, firewalls and wrong SDP addresses.
SIP Registration Failed? Troubleshooting Checklist
Fix failed SIP registrations step by step: read 401, 403, 404, 408, 423 and 503 replies, then check DNS, ports, NAT, fail2ban bans and Asterisk PJSIP.
Calls Dropping After 30 Seconds
Why VoIP calls drop after about 32 seconds: lost ACKs, NAT, wrong Contact headers and SIP ALG, how to prove it in a trace, and fixes for Asterisk and routers.
Capture SIP Traces With sngrep and Wireshark
Capture SIP and RTP with sngrep and tcpdump, then analyse calls in Wireshark: call flows, RTP stream analysis, jitter, loss, audio playback and safe sharing.