VoIP on Ubuntu server 18.04 with Asterisk

Submitted by zubanst on Mon, 08/31/2020 - 11:44

Want your own VoIP to build your own communication system, Asterisk is a free and open source framework for that. With Asterisk VoIP server, you can make calls to and from your Android phone and other SIP phones without any cost. This is very cost effective solution for small, medium to large corporate offices.

In this post we will show you how to install Asterisk VoIP server and use it with an Android app.

  • Update your distribution

sudo apt update

  • Install Ubuntu distribution Asterisk

sudo apt install asterisk asterisk-dahdi

  • After the installation, check the service status, see how to stop, start or restart the service

sudo systemctl status asterisk

sudo systemctl stop asterisk

sudo systemctl start asterisk

sudo systemctl restart asterisk

  • Configuration

ls /etc/asterisk

    • Backup configuration files

sudo cp sip.conf sip.conf.bak

sudo cp extensions.conf extensions.conf.bak

    • Create new sip.conf file with the following content:

[general]

context=default

allowoverlap=no

udpbindaddr=0.0.0.0

tcpenable=no

tcpbindaddr=0.0.0.0

transport=udp

srvlookup=yes

[1001]

type=friend

host=dynamic

secret=1001

[1002]

type=friend

host=dynamic

secret=1002

In this configuration we created 2 subscribers, 1001 and 1002 with passwords 1001 and 1002 respectively. You can add subscribers or amend the passwords as you need

  • Create a new extensions.conf file with the following content:

[general]

static=yes

writeprotect=no

priorityjumping=no

autofallthrough=yes

clearglobalvars=no

 

[default]

exten => 1001,1,Dial(SIP/1001,10)

exten => 1002,1,Dial(SIP/1002,10)

  • Restart the service and check the status

sudo systemctl restart asterisk

sudo systemctl status asterisk

  • Adapt Ubuntu firewall if active (we advise activate ufw)

sudo ufw allow 5060/udp

sudo ufw allow 10000:20000/udp

  • Test the setup in the local network with Android SIP phones (use 2 phones for that matter). We used Zoiper free, you can download here QR
  • Start the app and register one account for each phone

  • Now you can test your phone. On PCs you can also install SIP soft phones, such as MicroSIP
  • Configure your router to allow inbound UDP traffic on ports 5060 and 10000:20000 and you can use your SIP phone everywhere

The quality is excellent. Should you want to encrypt the traffic end to end, contact us www.pennyitsupport.eu