Fixing FreeSWITCH 32-Second Call Drops and NAT Audio Failures
calricon / field note
FreeSWITCH instances running behind AWS or GCP cloud NAT
Fixing FreeSWITCH 32-Second Call Drops and NAT Audio Failures
On FreeSWITCH deployments hosted inside cloud VPCs (AWS EC2, GCP Compute Engine, or Azure VMs) behind 1:1 NAT, inbound calls answer normally—yet disconnect abruptly at exactly 32 seconds, often with one-way or completely silent audio. Packet captures in sngrep show FreeSWITCH repeatedly retransmitting 200 OK until SIP Timer H expires and FreeSWITCH sends a BYE because the caller's ACK never arrived.
The verified root cause is private IP advertisement in Sofia SIP and SDP headers. When ext-sip-ip and ext-rtp-ip are left at auto-nat or unset in a cloud environment, FreeSWITCH places its private RFC 1918 NIC address (such as 10.0.1.25) into the Contact header and SDP c= connection line. The remote carrier SBC sends its ACK and RTP media to that unreachable private IP, triggering the 32-second ACK timeout.
Problem Diagnosis & Root Cause Architecture
- ext-sip-ip vs. ext-rtp-ip Split Responsibility: In
mod_sofia,ext-sip-ipcontrols the public address advertised in SIPContact,Via, andRecord-Routeheaders, whereasext-rtp-ipcontrols the media address advertised in SDPc=andm=lines. Missing either causes signaling drops or one-way audio. - Why auto-nat Fails in Cloud VPCs: Setting
auto-natqueries the local gateway via NAT-PMP (RFC 6886) and UPnP IGD. Cloud hypervisors and enterprise routers disable NAT-PMP/UPnP, leavingext-sip-ipunresolved and falling back to the privatelocal_ip_v4. - Startup-Only Resolution Caching: FreeSWITCH resolves
stun:andhost:values once when the Sofia profile loads; if an Elastic IP or DHCP address changes, a simplereloadxmldoes not update the active profile. - Missing local-network-acl Exclusions: Without a properly scoped
local-network-acl, FreeSWITCH may advertise its public Elastic IP toward internal LAN trunks or PBX peers, breaking intra-VPC media routing.
Never rely onauto-naton cloud instances or behind enterprise firewalls. Explicitly bindext-sip-ipandext-rtp-ipto your static public IPv4 (orstun:resolver) and pair them withlocal-network-aclso internal VPC traffic stays on private routing.
Why Standard Implementations Fail
Using auto-nat on AWS EC2 or Docker Hosts
Because cloud VPC gateways never respond to UPnP or NAT-PMP probes, auto-nat silently fails to resolve an external address and leaves private 10.x or 172.16.x addresses in outbound Contact headers.
Running reloadxml Instead of Restarting the Sofia Profile
reloadxml refreshes the XML configuration tree in memory, but mod_sofia only reads ext-sip-ip and ext-rtp-ip when a SIP profile starts or restarts.
Enabling NDLB-force-rport Without Symmetric RTP
Forcing rport on SIP signaling without matching ext-rtp-ip and rtp-autoflush-during-bridge leaves signaling intact past 32 seconds while RTP media remains one-way.
Validated Step-by-Step Resolution Playbook
Step 1: Verify Advertised Contact and SDP Addresses in Live Traces
Inspect an inbound call's 200 OK response in fs_cli or sngrep to confirm whether FreeSWITCH is advertising its private IP instead of its public Elastic IP.
# Enable Sofia SIP tracing in fs_cli
fs_cli -x "sofia global siptrace on"
# Check currently resolved external IPs on the external profile
fs_cli -x "sofia status profile external"Step 2: Define Static External IPs in vars.xml
Set your static public IPv4 address in /etc/freeswitch/vars.xml (avoiding auto-nat in cloud environments).
<!-- /etc/freeswitch/vars.xml -->
<X-PRE-PROCESS cmd="set" data="external_sip_ip=203.0.113.25"/>
<X-PRE-PROCESS cmd="set" data="external_rtp_ip=203.0.113.25"/>Step 3: Configure ext-sip-ip, ext-rtp-ip, and local-network-acl in Sofia Profiles
Update /etc/freeswitch/sip_profiles/external.xml (and internal.xml if serving remote NATed extensions) to reference the external IP variables and preserve local VPC routing via local-network-acl.
<!-- /etc/freeswitch/sip_profiles/external.xml -->
<param name="rtp-ip" value="$${local_ip_v4}"/>
<param name="sip-ip" value="$${local_ip_v4}"/>
<param name="ext-rtp-ip" value="$${external_rtp_ip}"/>
<param name="ext-sip-ip" value="$${external_sip_ip}"/>
<param name="local-network-acl" value="localnet.auto"/>
<param name="aggressive-nat-detection" value="true"/>Step 4: Reload XML and Restart the Sofia Profile
Apply the configuration by reloading XML and restarting the target Sofia profile (or restarting FreeSWITCH during a maintenance window if global variables changed).
fs_cli -x "reloadxml"
fs_cli -x "sofia profile external restart"Step 5: Verify Public Contact, ACK Delivery, and Two-Way RTP
Place a test inbound call exceeding 45 seconds and confirm that Ext-SIP-IP and Ext-RTP-IP match your public address, the remote ACK arrives immediately, and bidirectional RTP flows cleanly.
# Confirm Ext-SIP-IP and Ext-RTP-IP in Sofia status
fs_cli -x "sofia status profile external" | grep -E "Ext-SIP-IP|Ext-RTP-IP"
# Verify active channels stay up past 32 seconds
fs_cli -x "show channels"Experiencing this issue in your production systems?
Calricon conducts senior-level VoIP, SIP trunking, Asterisk, and cloud infrastructure audits. We review your live configs, identify packet drops or contention bottlenecks, and provide exact remediation runbooks.