Privacy Tools Guide

Secure VoIP Setup for Private Phone Calls Without Carrier Involvement: A Developer’s Guide

Traditional phone calls route through carrier infrastructure, exposing metadata including call duration, phone numbers, and often recording capabilities. For developers and power users seeking complete control over their voice communications, self-hosted VoIP infrastructure offers a compelling alternative. This guide walks through building a private VoIP system that operates entirely independent of telecom carriers while maintaining strong encryption and privacy properties.

Why Go Carrier-Free?

Carrier-based phone systems collect extensive metadata. Your mobile carrier knows every number you call, when you called, how long you talked, and often retains these records for years. Law enforcement routinely requests this data without requiring a warrant in many jurisdictions. By running your own VoIP infrastructure, you eliminate this metadata exposure while gaining full control over call recording policies, encryption implementation, and network architecture.

Self-hosted VoIP also enables calling capabilities without any phone number association. Users can register using arbitrary identifiers—usernames, email-style addresses, or cryptographic keys—rather than government-issued phone numbers. This provides significant privacy benefits for users in adversarial situations.

Core Components

A private VoIP system requires several functional layers:

SIP Server (PBX): Handles user registration, call routing, and authentication. Asterisk is the open-source standard here, though alternatives like FreeSWITCH or kamailio offer different tradeoffs.

Media Server: Manages the actual audio streams. Options range from simple peer-to-peer WebRTC connections to more complex architectures with media relay for NAT traversal.

Client Applications: End-user software that registers with your SIP server and handles audio encoding/decoding. Popular choices include Linphone, CSipSimple, and browser-based WebRTC clients.

Encryption Layer: Protects call content from eavesdropping. SRTP (Secure Real-time Transport Protocol) encrypts media streams, while TLS encrypts SIP signaling.

Setting Up Asterisk

Asterisk provides a complete, flexible PBX implementation. Install it on a Linux server—Debian or Ubuntu work well for this purpose:

apt-get update
apt-get install asterisk asterisk-voicemail

The core configuration lives in /etc/asterisk/. For basic peer-to-peer calling, you’ll need to configure sip.conf for user authentication and extensions.conf for call routing.

A minimal SIP user configuration in /etc/asterisk/sip.conf:

[general]
context=default
bindport=5060
bindaddr=0.0.0.0
transport=tls

[alice]
type=friend
secret=strong_password_here
context=phones
host=dynamic

This configuration defines a user “alice” with password-based authentication. The TLS transport ensures signaling is encrypted.

For call routing, edit /etc/asterisk/extensions.conf:

[phones]
exten => alice,1,Dial(SIP/alice)
exten => bob,1,Dial(SIP/bob)

This creates a simple dial plan where users can call each other by username.

Implementing SRTP Encryption

SRTP encrypts the actual audio payload, preventing eavesdropping even if someone intercepts network traffic. Asterisk handles SRTP through the res_srtp module. First, verify it’s loaded:

asterisk -rx "module show like srtp"

Enable SRTP per-peer in sip.conf:

[alice]
type=friend
secret=strong_password_here
context=phones
host=dynamic
encryption=yes

Clients must also support SRTP. Linphone enables it by default when available. Test encryption with:

asterisk -rvvvv
sip set debug on

You should see SRTP in the exchange when both endpoints support it.

WebRTC Integration

For browser-based clients or mobile apps without native SIP support, WebRTC provides a JavaScript API for real-time communication. The asterisk-res_pjsip module handles WebRTC registration.

First, install the dependencies:

apt-get install libssl-dev libsrtp2-dev

Configure PJSIP in /etc/asterisk/pjsip.conf:

[transport-wss]
type=transport
protocol=wss
bind=0.0.0.0

[alice]
type=auth
auth_type=userpass
username=alice
password=strong_password_here

[alice endpoint]
type=endpoint
auth=alice
aors=alice
media_encryption=sdes

The WebRTC client then connects using WSS (WebSocket Secure) to port 8089 by default.

A simple JavaScript client using the SIP.js library:

const SIP = require('sip.js');

const userAgent = new SIP.UserAgent({
  uri: 'sip:alice@your-server.example.com',
  transportOptions: {
    wsServers: ['wss://your-server.example.com:8089/ws']
  },
  authorizationPassword: 'strong_password_here'
});

userAgent.start();

Network Considerations

The server needs specific ports open: 5060 (SIP), 5061 (SIP over TLS), and a range for RTP media (typically 10000-20000). For WebRTC, port 8089 (or 443) must be accessible.

NAT traversal presents challenges. STUN servers help endpoints discover their public addresses:

external_media_address = stun.server.com
external_signaling_address = stun.server.com

For connections behind restrictive firewalls, TURN servers relay media traffic. The coturn project provides a free implementation:

apt-get install coturn

Configure it in /etc/turnserver.conf and point your Asterisk to use it.

Client Selection

Several clients work well with self-hosted Asterisk:

Linphone — Full-featured cross-platform client with excellent SRTP support. Available for iOS, Android, Windows, macOS, and Linux. Uses the SIP protocol natively.

MicroSIP — Lightweight Windows client, good for power users wanting minimal resource usage.

Citrus — Modern iOS client with good encryption support.

SIP.js — JavaScript library for building browser-based clients, as demonstrated above.

All these clients support TLS encryption and SRTP. Configure them to require encrypted connections—rejecting unencrypted calls ensures metadata and content remain protected.

Authentication and Security Hardening

Password-based authentication provides basic security, but key-based authentication offers stronger guarantees. Asterisk supports RSA authentication through the res_crypto module.

For additional security, implement fail2ban to block brute-force attacks:

apt-get install fail2ban

Configure it to monitor /var/log/asterisk/messages for authentication failures and ban offending IP addresses automatically.

Consider rate limiting on your firewall:

iptables -A INPUT -p udp --dport 5060 -m hashlimit \
    --hashlimit-above 10/sec --hashlimit-burst 5 \
    --hashlimit-mode srcip --hashlimit-name sip_rate_limit \
    -j DROP

Practical Usage Example

Once configured, calling works like standard VoIP:

  1. Register your client with your server using username/password
  2. Dial the other user’s SIP URI: sip:bob@your-server.example.com
  3. The call connects encrypted via SRTP

For maximum privacy, use usernames unrelated to real identities. Instead of “alice” and “bob,” consider cryptographic identifiers or pseudonyms.

You can also bridge to existing VoIP networks using gateways. An FXO gateway connects to traditional phone lines if you need to reach non-VoIP contacts, though this reintroduces carrier metadata exposure.

Maintenance and Monitoring

Regularly rotate passwords and audit logs:

asterisk -rx "sip show peers"

This displays registered users and their IP addresses. Monitor for unexpected registrations.

Keep Asterisk updated—the project releases security patches regularly:

apt-get update && apt-get upgrade asterisk

Built by theluckystrike — More at zovo.one