FreeSWITCH for Wholesale VoIP Operations

FreeSWITCH wholesale operations are transforming how VoIP carriers manage large-scale telephony infrastructure, offering unmatched flexibility, scalability, and cost-efficiency. As a powerful open-source softswitch, FreeSWITCH has become a cornerstone for wholesale VoIP providers seeking control over their routing logic, billing integration, and call quality optimization. Unlike proprietary systems that lock operators into rigid architectures, FreeSWITCH enables deep customization—critical when handling millions of minutes across international routes with fluctuating rates and compliance requirements. When configured properly, FreeSWITCH can act as both a Class 4 and Class 5 platform, making it ideal for carriers who want to originate, terminate, or transit voice traffic at scale. Its modular design supports SIP, RTP, SRTP, and advanced codecs like Opus and G.722, ensuring high MOS scores and low PDD. For businesses buying or selling VoIP routes through platforms like Buy VoIP Routes or Sell VoIP Routes, deploying FreeSWITCH allows direct integration with real-time LCR engines and CDR processing pipelines. This article provides a detailed technical walkthrough of setting up and optimizing FreeSWITCH for wholesale operations, covering architecture, security, rate management, failover strategies, and integration with billing systems.

Why FreeSWITCH for Wholesale VoIP?

FreeSWITCH stands out in the wholesale VoIP space due to its open-source nature, modularity, and ability to scale from small VoIP startups to Tier-1 carrier operations. Unlike closed systems such as VOS3000 or PortaBilling, which require licensing fees and restrict access to core logic, FreeSWITCH allows full control over every aspect of call handling. This is critical when managing complex routing policies, regulatory compliance (e.g., CLI/NCLI requirements in Europe), and real-time fraud detection. The platform supports both IPv4 and IPv6, DNS SRV lookups, and TLS/SRTP encryption out of the box—essential for secure inter-carrier communication. With FreeSWITCH, operators can deploy a Class 4 switch that only routes calls between providers or expand into Class 5 services like DID provisioning and IVR, depending on business needs.

One of the biggest advantages of FreeSWITCH wholesale deployments is cost efficiency. There are no per-channel or per-minute licensing fees, which makes it ideal for high-volume operations. For example, terminating 10 million minutes per month on a proprietary softswitch could incur tens of thousands in licensing costs, whereas FreeSWITCH eliminates those expenses entirely. Additionally, the community and enterprise support ecosystems provide extensive documentation, modules, and third-party tools for monitoring, billing, and fraud prevention. Operators can integrate FreeSWITCH with existing infrastructure using APIs, ODBC connections, or custom Lua/Python scripts.

Compared to alternatives like Asterisk Wholesale VoIP Configuration, FreeSWITCH offers superior concurrency handling and lower latency under load. While Asterisk excels in small-scale PBX environments, FreeSWITCH was built from the ground up for carrier-grade performance. It uses an event socket architecture that allows external applications to monitor and control calls in real time—perfect for integrating with LCR engines or dynamic rate switches. For operators evaluating platforms, a comparison like Best Softswitches Compared for 2026 highlights FreeSWITCH’s dominance in scalability and protocol support.

FreeSWITCH Architecture for Carrier Environments

Designing a FreeSWITCH architecture for wholesale operations requires understanding the distinction between Class 4 and Class 5 functionality. In a wholesale context, most deployments focus on Class 4 switching—routing calls between providers without end-user services. This means the system must efficiently handle SIP signaling, RTP media streams, and session border control (SBC) features like topology hiding and NAT traversal. A typical FreeSWITCH wholesale setup includes multiple servers: one for signaling (core), another for media (transcoding if needed), and a database server for CDR storage and rate tables. High-traffic operators may deploy clusters across data centers in different geographic regions to reduce latency and ensure redundancy.

The core component of FreeSWITCH is the Event Socket, which enables real-time interaction with external systems. This is used to feed call detail records into billing platforms, apply LCR rules dynamically, or trigger fraud alerts based on abnormal calling patterns. For example, if a trunk suddenly shows 500 concurrent calls to high-risk destinations like Somalia or Yemen, an external script can automatically block the source IP or reduce the allowed rate tier. The Event Socket also allows integration with web-based dashboards for live call monitoring and ASR/ACD reporting.

FreeSWITCH uses a modular architecture where each function—SIP stack, codec negotiation, IVR, conferencing—is handled by a separate module. This allows operators to disable unnecessary components and reduce memory footprint. In wholesale mode, modules like mod_dptools, mod_sofia, and mod_xml_curl are essential, while mod_voicemail or mod_fax can be omitted. The configuration files are XML-based and organized into directories such as sip_profiles, dialplans, and gateways. Each gateway defines a peer connection to another carrier or termination provider, specifying authentication credentials, codecs, and failover routes.

For large-scale deployments, FreeSWITCH can be deployed behind a load balancer with multiple instances sharing the same configuration via NFS or distributed version control. This ensures consistent behavior across nodes and simplifies updates. Media handling can be offloaded to dedicated transcoding servers when dealing with incompatible codecs—for instance, converting G.729 to PCMU when interfacing with legacy systems. Using this architecture, operators can achieve over 10,000 concurrent calls per server with proper tuning of kernel parameters and network buffers.

FreeSWITCH Setup: Installation and Core Configuration

Installing FreeSWITCH for wholesale use begins with selecting the right operating system—typically CentOS, Debian, or Ubuntu LTS. The official FreeSWITCH repository provides packages for all major distributions, ensuring compatibility and security updates. For production environments, it is recommended to compile from source or use the stable release packages rather than nightly builds. Once the OS is installed, dependencies such as libssl-dev, libpcre3-dev, and libcurl4-openssl-dev must be installed before building FreeSWITCH. The build process uses the ./configure, make, and make install sequence, followed by copying the default configuration files to /etc/freeswitch.

Initial configuration involves editing key files in the /etc/freeswitch directory. The main SIP profile is defined in sip_profiles/external.xml, where parameters like bind-port, accept-blind-reg, and auth-calls are set. For wholesale operations, auth-calls should be enabled to prevent unauthorized access, and accept-blind-reg disabled to block rogue registrations. The vars.xml file contains global variables such as default codecs (G.711, G.729, Opus), RTP port ranges, and log levels. It is crucial to limit RTP ports to a defined range (e.g., 16384-32768) and configure the firewall accordingly.

Gateways are configured in autoload_configs/gateway.conf.xml or via XML over HTTP using mod_xml_curl. Each gateway entry includes the provider’s domain, username, password, proxy address, and failover strategies. For example:

Dialplans control how calls are routed and processed. In wholesale mode, the default dialplan is modified to strip number formatting, apply LCR rules, and forward calls to the appropriate gateway. For instance, a call to +919876543210 would be normalized to 919876543210, matched against a rate table, and sent to the lowest-cost provider capable of delivering to Indian mobile numbers at $0.008/min. Normalization rules must account for trunk prefixes, IDD codes, and national numbering plans to avoid misrouting.

Start Building Your Wholesale VoIP Network

Join thousands of carriers already using FreeSWITCH and connecting through the VoIP Wholesale Forum to buy and sell routes. Get access to real-time rate sheets, peering partners, and technical resources.

Register Free

SIP Trunking and Peering with Other Carriers

SIP trunking is the foundation of any FreeSWITCH wholesale operation, enabling interconnection with upstream providers, downstream customers, and peer networks. Each SIP trunk is configured as a gateway in FreeSWITCH and must include authentication details, transport protocol (UDP/TCP/TLS), and codec preferences. For carrier-grade reliability, TLS and SRTP should be used whenever possible to encrypt signaling and media. However, many termination providers still operate on UDP due to legacy infrastructure, so dual-stack support is necessary.

When establishing peering relationships, operators must negotiate terms such as dial plan support, CLI/NCLI policies, and acceptable use. For example, some providers prohibit toll-free number termination or require 10-digit dialing. These rules must be enforced in the FreeSWITCH dialplan using regex patterns and condition blocks. Additionally, Session Initiation Protocol (SIP) headers like P-Asserted-Identity or Remote-Party-ID may need to be manipulated to comply with local regulations or prevent rejection by the far end.

FreeSWITCH supports both inbound and outbound trunking. Inbound trunks receive calls from customers or partners, while outbound trunks send calls to termination providers. Each trunk should have its own SIP profile to isolate traffic and apply specific settings. For example, an inbound profile might allow anonymous calls from trusted IPs, while an outbound profile enforces strict authentication and rate limiting. NAT traversal is handled via ext-rtp-ip and ext-sip-ip settings, which tell FreeSWITCH to advertise public IPs for media and signaling.

To maintain call quality, operators should monitor SIP OPTIONS pings and RTCP feedback from peers. High PDD or packet loss on a specific trunk indicates network issues or congestion, prompting automatic failover to backup providers. FreeSWITCH’s mod_sofia logs detailed SIP messages, which can be parsed using tools like Elasticsearch or Graylog for troubleshooting. Successful peering not only improves ASR and ACD but also reduces NER by minimizing call drops and SIP timeouts.

Routing and LCR: Managing International VoIP Rates

Least Cost Routing (LCR) is the heart of any profitable wholesale VoIP operation. FreeSWITCH does not include a built-in LCR engine, but it can integrate with external databases or scripts to determine the optimal route for each call. The most common approach is to use PostgreSQL or MySQL to store rate tables indexed by destination prefix. A Lua script queries the database during call setup, retrieves the lowest-cost provider capable of handling the destination, and sets the effective_caller_id_number and gateway variables accordingly.

Rate tables should include fields such as prefix, country, destination type (mobile/landline), rate per minute, connection fee, and provider ID. For example:

Prefix Country Destination Rate ($/min) Provider Updated
1 USA Landline 0.0020 ProviderA 2025-03-10
44 UK Landline 0.0035 ProviderB 2025-03-09
91 India Mobile 0.0080 ProviderC 2025-03-11
234 Nigeria Mobile 0.0250 ProviderD 2025-03-08
86 China Landline 0.0120 ProviderE 2025-03-10

LCR logic must also consider failover paths. If the primary provider is unreachable or returns a 503 error, FreeSWITCH should attempt the next best route. This is achieved using multi-leg dialing or the bridge application with failover URIs. For example: bridge({ignore_early_media=true}sofia/gateway/ProviderA/919876543210,sofia/gateway/ProviderB/919876543210). The ignore_early_media flag prevents premature media from causing confusion during handover.

Dynamic rate updates are essential in volatile markets. Operators can use cron jobs or webhook integrations to refresh rate tables hourly from partners or marketplaces like Buy VoIP Routes. Real-time rate switching allows immediate response to price wars or fraud-induced rate hikes. Additionally, margin rules can be applied—e.g., selling Indian mobile at $0.009/min when buying at $0.008/min—ensuring consistent profitability.

Security Hardening for Carrier-Grade Operations

FreeSWITCH deployments in wholesale environments are prime targets for toll fraud, denial-of-service attacks, and SIP scanning. Hardening the system is not optional—it’s a requirement for sustained operation. The first step is to disable unused services and modules. For example, mod_xml_rpc and mod_event_socket should only be accessible over localhost or a private VLAN. Remote event socket access must be protected with strong passwords and IP whitelisting.

Firewall rules should restrict SIP (5060/5061) and RTP (16384-32768) traffic to known peer IPs. Tools like fail2ban can monitor freeswitch.log for repeated registration failures and automatically block malicious IPs. SIP digest authentication should use strong passwords and avoid default usernames like "admin" or "freeswitch". Additionally, enabling rtp_secure and sip_secure forces SRTP and TLS, preventing eavesdropping on media streams.

Call filtering rules should be implemented to detect and block fraud patterns. For instance, calls to premium rate numbers (e.g., +809, +870) or high-risk countries should require pre-approval or be blocked entirely. FreeSWITCH’s mod_lua can run scripts that analyze calling behavior—such as more than 10 concurrent calls to different destinations in under a minute—and hang up suspicious sessions. CDRs should be logged in real time to a secure, write-once database to prevent tampering.

Regular audits of configuration files and system logs are essential. Operators should verify that no unauthorized gateways have been added and that