Configuring an Asterisk PBX (EPABX) system involves several steps, from installation to setting up extensions, trunks, and call routing. Below is a step-by-step guide to setting up Asterisk PBX on a Linux system (e.g., Ubuntu or CentOS).
Step 1: Install Asterisk
1. Update System Packages
bashsudo apt update && sudo apt upgrade -y # For Debian/Ubuntu
sudo yum update -y # For CentOS/RHEL
2. Install Required Dependencies
bashsudo apt install -y build-essential wget curl git subversion libjansson-dev \
libxml2-dev libsqlite3-dev uuid-dev
(For CentOS, use yum
instead of apt
.)
3. Download and Compile Asterisk
bashcd /usr/src/
sudo wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-20-current.tar.gz
sudo tar -xvzf asterisk-20-current.tar.gz
cd asterisk-20.*
4. Install Required Modules
bash
sudo contrib/scripts/get_mp3_source.sh
sudo contrib/scripts/install_prereq install
5. Configure & Compile Asterisk
bashsudo ./configure
sudo make menuselect
- Enable the necessary modules (like
chan_sip
,res_config_mysql
,app_macro
, etc.). - Exit and save.
bashsudo make -j$(nproc)
sudo make install
sudo make samples
sudo make config
sudo ldconfig
Step 2: Configure Asterisk PBX
1. Configure SIP Extensions
Edit the SIP configuration file:
bashCopyEditsudo nano /etc/asterisk/sip.conf
Add the following sample configuration:
ini[general]
context=default
allowguest=no
srvlookup=yes
udpbindaddr=0.0.0.0
tcpenable=no
[1001]
type=friend
secret=yourpassword
host=dynamic
context=internal
nat=yes
canreinvite=no
disallow=all
allow=ulaw
allow=alaw
callerid="User 1001" <1001>
[1002]
type=friend
secret=yourpassword
host=dynamic
context=internal
nat=yes
canreinvite=no
disallow=all
allow=ulaw
allow=alaw
callerid="User 1002" <1002>
2. Configure Extensions (Dial Plan)
Edit the dial plan:
bashsudo nano /etc/asterisk/extensions.conf
Add the following:
iniCopyEdit[internal]
exten => 1001,1,Dial(SIP/1001,20)
exten => 1002,1,Dial(SIP/1002,20)
exten => _X.,1,NoOp(Incoming call)
same => n,Answer()
same => n,Playback(hello-world) ; Play a sample message
same => n,Hangup()
3. Configure Trunks (Optional)
For a SIP trunk:
ini[voiptrunk]
type=peer
host=sip.provider.com
username=yourusername
secret=yourpassword
insecure=invite
nat=yes
canreinvite=no
context=from-trunk
Step 3: Start and Enable Asterisk
bashsudo systemctl restart asterisk
sudo systemctl enable asterisk
Step 4: Test & Connect Softphones
- Install Zoiper or Linphone on your PC or mobile.
- Add an account:
- SIP Server:
IP_of_Asterisk_Server
- Username:
1001
- Password:
yourpassword
- SIP Server:
- Try calling
1002
from1001
.
Step 5: Monitor & Debug
Run Asterisk CLI:
bashsudo asterisk -rvvv
Check logs:
bashCopyEdittail -f /var/log/asterisk/full
Additional Features
- Voicemail – Configure
/etc/asterisk/voicemail.conf
- IVR Menus – Configure
extensions.conf
- Call Recording – Configure
features.conf
- Call Queues – Configure
queues.conf