Uncategorized

How to Set Up an Asterisk VoIP Server on Linux

How to Set Up an Asterisk VoIP Server on Linux

Setting up a VoIP (Voice over Internet Protocol) server can significantly improve communication efficiency for businesses or individuals. Asterisk is one of the most popular open-source frameworks for building communications applications. In this guide, we’ll walk through the process of setting up an Asterisk VoIP server on a Linux-based system. By the end, you’ll have a fully functional VoIP server that you can customize to meet your needs.

Prerequisites
Before you start, ensure you have the following:

  • Linux Server: A server running a Linux distribution such as Ubuntu, CentOS, or Debian. This guide will focus on Ubuntu for its popularity and user-friendliness.
  • Root Access: You need root or sudo access to install the necessary packages.
  • Basic Knowledge: Familiarity with the Linux command line and basic networking concepts will be beneficial.

Step 1: Update Your System
First, it’s crucial to ensure your server is up to date. Open your terminal and run the following commands:

sudo apt update
sudo apt upgrade -y

This updates the package list and installs the latest available versions of your installed packages.

Step 2: Install Required Dependencies
Asterisk requires several packages to function correctly. Install them using:

sudo apt install -y build-essential git wget libxml2-dev libncurses5-dev libssl-dev libnewt-dev libsqlite3-dev

These packages provide the necessary tools and libraries for compiling Asterisk from source.

Step 3: Download Asterisk
Next, you need to download the latest version of Asterisk. At the time of writing, the latest version is 20.10. You can check the official Asterisk website for the most current version.

cd /usr/src
sudo wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-20.10.tar.gz

After downloading, extract the tarball:

sudo tar -xvf asterisk-20.10.tar.gz
cd asterisk-20.10

Step 4: Compile and Install Asterisk
Now, you can compile and install Asterisk. Start by running the configuration script:

sudo ./configure

After the configuration is complete, you will need to run the following commands to build and install Asterisk:

sudo make
sudo make install

Once the installation is complete, you should also install the sample configuration files:

sudo make config

Finally, load the Asterisk service into systemd:

sudo systemctl start asterisk
sudo systemctl enable asterisk

Step 5: Configure Asterisk
After installation, Asterisk’s configuration files will be located in the /etc/asterisk directory. The most critical file is sip.conf, where you will define your SIP (Session Initiation Protocol) settings.

Open sip.conf:

sudo nano /etc/asterisk/sip.conf

Add the following lines to set up a basic configuration:

[general]
context=default
allowguest=no

Next, you need to configure your extensions. Open the extensions.conf file:

sudo nano /etc/asterisk/extensions.conf

Add a simple extension configuration:

[default]
exten => 100,1,Dial(SIP/100)
exten => 101,1,Dial(SIP/101)

This example allows users with extensions 100 and 101 to call each other.

Step 6: Create SIP User Accounts
You need to create user accounts for your VoIP clients. Open sip.conf again and add the following entries:

[100]
type=friend
secret=your_password
host=dynamic

[101]
type=friend
secret=your_password
host=dynamic
Replace your_password with strong passwords for each user.

 

Step 7: Start Asterisk CLI
To interact with your Asterisk server, you can use the Asterisk Command Line Interface (CLI). Run the following command:

sudo asterisk -rvv

This command connects you to the Asterisk CLI, where you can monitor logs and manage the server in real-time.

Step 8: Test Your Configuration
You can test your VoIP server by using a softphone client such as Zoiper or Linphone. Configure the softphone with the following details:

  • SIP Server: Your server’s IP address
  • Username: 100 or 101 (as per your configuration)
  • Password: The corresponding password you set in sip.conf
    Once configured, try making a call between the two extensions.

Step 9: Enable Firewall Settings
Ensure your firewall settings allow traffic on the necessary ports. You typically need to open ports 5060 (SIP) and 10000-20000 (RTP).

For UFW, run:

sudo ufw allow 5060/udp
sudo ufw allow 10000:20000/udp

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button