(D241024) IP PBX call distributor VoIP Gateway GSM/3G/4G/5G for home and small office
PROOF OF CONCEPT
1. Requirement and concept
We're building a PBX system for our business. It will handle:
- automatic distribute incoming calls
- call outside by specific phone numbers, automatic route to reduce call cost
- sms send api for OTP maybe?
Since we don't have any SIP trunk from our carriers, we will take incoming calls from regular sim cards.
- Disadvantage:
- Single-line: only one concurrent call per SIM card at a time
- Need more work to handle system failure due to OS, power..
- Not sure:
- Voice over LTE (VoLTE) are supported by all carriers.
- Voice over Wi‑Fi (VoWiFi) are supported by VinaPhone, Mobifone?
Call flow as bellow:
Our stack:
- Hardwares:
- Mini PC / Router: ZOTAC ZBOX CI323 nano
- 2G/3G/4G/5G module: Quectel EC20CEFRG-MINIPCIE-C (Vietnam frequency bands: B1/B3/B8), PCIE to USB adapter (sim card slot included), antena
- VoIP phone: haven't bought yet
- Softwares
- OS: TrueNAS SCALE 24.10 - Electric Eel
- VM: jailmaker
- PBX: Asterisk
- Softphone: Linphone (Linux / iOS), Baresip (Android), MicroSIP (Windows)
2. Step by step
2.1 Asterisk Installation
- OS: Debian 12 ("Bookworm")
$ mkdir tmp
$ cd tmp/
$ wget https://downloads.asterisk.org/pub/telephony/asterisk/asterisk-22-current.tar.gz
$ tar zxvf asterisk-22-current.tar.gz
$ cd asterisk-22*/
$ sudo ./contrib/scripts/install_prereq install
$ ./configure
$ make menuselect
Most of IP phones are support G722 and / or G729 codecs now.
- Under Add-ons:
- Select [*] format_mp3
- Under Codec Translators:
- Select [*] codec_opus
- Select [*] codec_silk
- Select [*] codec_siren7
- Select [*] codec_siren14
- Select [*] codec_g729a
- Under Core Sound Packages:
- Deselect [*] CORE-SOUNDS-EN-GSM
- Select [*] CORE-SOUNDS-EN-WAV
- Select [*] CORE-SOUNDS-EN-G722
- Select [*] CORE-SOUNDS-EN-G729
- Under Extras Sound Packages:
- Select [*] EXTRA-SOUNDS-EN-WAV
- Select [*] EXTRA-SOUNDS-EN-G722
- Select [*] EXTRA-SOUNDS-EN-G729
$ make
$ sudo ./contrib/scripts/get_mp3_source.sh
$ sudo make install
$ sudo make config
$ sudo make samples
$ sudo mkdir /etc/asterisk/samples
$ sudo mv /etc/asterisk/*.* /etc/asterisk/samples/
$ sudo asterisk -rvvvv
Most important config files:
- extensions.conf
- pjsip.conf
2.2. Virtual machine vm1
Purpose: VoIP GSM Gateway to handle voice call from and or to 3G/4G/5G MNOs.
- OS: Debian 12
- IP: 192.168.1.11
- Software: Asterisk
- Driver: asterisk-chan-quectel
2.3. Virtual machine vm0
Purpose: Local PBX.
- OS: Debian 12
- IP: 192.168.1.10
- Software: MikoPBX
3. Resource
Softwares:
- Servers:
- Clients:
- Docs:
- Ref:
4. Miscellaneous
- Linux KVM is much more complicated than FreeBSD Bhyve so maybe we sould run FreeBSD host and Linux guest
- Debian has no Asterisk in their repo, we moved our guest to Ubuntu since we don't want to complie Asterisk ourself
- Run MikoPBX as a Local PBX, Asterisk as a trunk provider. We found that MikoPBX is better than FreePBX in our case.
- Call quality seems not good enough, need to check jitter buffer again
- https://github.com/RoEdAl/asterisk-chan-quectel
test@vm0:~$ cat /etc/asterisk/pjsip.conf
;===============TRANSPORT
[system-udp]
type=transport
protocol=udp
bind=0.0.0.0
;===============TRUNK
[miko0]
type=aor
contact=sip:192.168.1.11:5060
[miko0]
type=endpoint
context=quectel-incoming
disallow=all
allow=ulaw
aors=miko0
[miko0]
type=identify
endpoint=miko0
match=192.168.1.11
test@vm0:~$ cat /etc/asterisk/extensions.conf
[quectel-incoming]
exten => _+84XXXXXXXXX,1,Dial(PJSIP/200@miko0)
exten => s,n,Hangup()
edit /etc/asterisk/indications.conf
on vm1
#!/bin/bash
configPath="$1" # Path to the original config file
sed -i 's/country=ru/country=vn/g' "$configPath"
cat >> "$configPath" <<EOF
[vn]
description = Vietnam
; Clone from China
ringcadence = 1000,4000
dial = 450
busy = 450/350,0/350
ring = 450/1000,0/4000
congestion = 450/700,0/700
callwaiting = 450/400,0/4000
dialrecall = 450
record = 950/400,0/10000
info = 450/100,0/100,450/100,0/100,450/100,0/100,450/400,0/400
stutter = 450+425
EOF
5. Test
Number: 0918026858
- [x] Voice
- [ ] SMS
- [ ] 4G internet?