Design and Implementation of a VOIP Solution for Overseas Travelers Using Asterisk and Kamailio
This article presents a comprehensive guide on building a VOIP service for overseas users, covering VOIP fundamentals, open‑source PBX selection, SIP client libraries, demo deployment, load‑balancing with Kamailio, high‑availability via Keepalived, NAT handling, TLS/SRTP support, and troubleshooting techniques.
The growing demand for overseas travel services such as Wi‑Fi, local guides, and online assistance requires a seamless VOIP solution that lets users call domestic customer service numbers from abroad; a free network‑call feature was launched and achieved over 30% adoption within seven days.
VOIP Overview – VOIP (Voice over Internet Protocol) digitizes, compresses, and transports voice packets over IP networks using protocols like RTP, UDP, and SIP. The basic processing steps include analog‑to‑digital conversion, PCM sampling, packetization, transport, jitter removal, and digital‑to‑analog conversion.
Comparison with Traditional Telephony – While traditional PSTN offers higher stability, modern VOIP services (e.g., Mimicall, VP3000) provide comparable reliability with lower cost, especially when using free data or Wi‑Fi.
Open‑Source Soft‑PBX Selection – The two popular choices are FreeSwitch ( https://freeswitch.org/ ) and Asterisk ( http://www.asterisk.org/ ); the author chose Asterisk because of prior experience, both based on SIP.
SIP Client Library – PJSIP ( http://www.pjsip.org/ ) was selected for its support of SIP, SDP, RTP, STUN, TURN, ICE, clear API, NAT traversal, and cross‑platform compatibility (desktop, embedded, mobile).
Demo Setup
1) Install PJSIP on a Linux machine (installation steps omitted). Verify the shared library:
ldconfig -p | grep pj2) Install Asterisk 13 (requires PJSIP ≥ 2.4). Configure the SIP endpoint in /etc/asterisk/pjsip.conf :
[transport-udp]
type=transport
protocol=udp
bind=0.0.0.0:5061
[8005]
type=endpoint
context=from-external
disallow=all
allow=ulaw
transport=transport-udp
auth=8005
aors=8005
[8005]
type=auth
auth_type=userpass
password=8005
username=8005
[8005]
type=aor
max_contacts=1
[8006]
type=endpoint
context=from-external
disallow=all
allow=ulaw
transport=transport-udp
auth=8006
aors=8006
[8006]
type=auth
auth_type=userpass
password=8006
username=8006
[8006]
type=aor
max_contacts=13) Add dialing rules in /etc/asterisk/extensions.conf :
[from-external]
exten => _80XX,1,NoOp()
same => n,Dial(PJSIP/${EXTEN})Start Asterisk:
service asterisk start
sudo asterisk -rvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvRegister the two extensions (8005, 8006) and test calls.
Load Balancing with Kamailio
To avoid a single point of failure, Kamailio is used as a SIP load balancer. The dispatcher list ( /usr/local/etc/kamailio/dispatcher.list ) defines backend Asterisk nodes:
1 sip:192.168.0.1 0 1 weight=50
1 sip:192.168.0.2 0 1 weight=50Key Kamailio configuration snippets:
listen=udp:192.168.0.3:5060
modparam("dispatcher", "list_file", "/usr/local/etc/kamailio/dispatcher.list")
if(!ds_select_dst("$var(dispatcher_group)", "9")) {
send_reply("404", "No destination dispatcher");
exit;
}After restarting Kamailio, calls are distributed according to the defined weights.
High Availability (HA) with Keepalived
Two servers (192.168.1.5 and 192.168.1.6) run Keepalived to provide a virtual IP (192.168.1.4). The Linux kernel parameter net.ipv4.ip_nonlocal_bind = 1 must be enabled so Kamailio can bind the virtual IP.
Keepalived is started on both nodes:
service keepalived startKamailio’s listen address is changed to the virtual IP:
listen=udp:192.168.1.4After restarting Kamailio, calls can be directed to the virtual IP, providing seamless failover.
HA Health Check
SIPSak is used to probe Kamailio:
sipsak -s sip:[email protected]:5060The exit code determines whether Kamailio is alive; a script can trigger Keepalived to switch the virtual IP when failures are detected.
Callback Solution
When a user’s mobile device cannot run VOIP, a callback mechanism holds the inbound call, notifies the other party (push or SMS), and releases the call once the second party is online, or uses a conference‑room approach.
NAT and Security
Typical enterprise firewalls and DNS require port forwarding and NAT handling; both Asterisk and Kamailio support NAT traversal. For stronger security, TLS and SRTP are added (compiled with tls.so and srtp.so ), and self‑signed certificates are sufficient.
Troubleshooting Tools
Use netcat for basic connectivity, tcpdump or ssldump for SIP/TLS analysis, and Wireshark for comprehensive packet inspection.
Conclusion
The presented architecture demonstrates a practical VOIP integration for overseas users, covering PBX selection, SIP client libraries, load balancing, HA, NAT, security, and debugging, offering a solid reference for similar projects.
Qunar Tech Salon
Qunar Tech Salon is a learning and exchange platform for Qunar engineers and industry peers. We share cutting-edge technology trends and topics, providing a free platform for mid-to-senior technical professionals to exchange and learn.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.