Install and launch Asterisk on an Android smartphone

Hello, habr!

I needed to quickly assemble a stand to demonstrate the work of an aster in a small organization. It was necessary to make several calls, demonstrate transfer, intercept a call, etc. The VoIP server itself is hosted on its smartphone. Why on a smartphone, how and for what purpose - under the cut.

1. Why

I work in a company that is involved in setting up telephony for small and not so companies in the city and region. Asterisk in most cases is the best option for PBX, as it is easily configured, scaled to the needs of the organization, you can supplement the functionality with your own scripts. There is a gentleman's kit to demonstrate the work of the PBX - an old MacBook with Linux on board and configured aster, a Gigaset SIP-pipe, SPA8000 gateway, a SIP-trunk to our PBX for external calls.
It so happened that the cat knocked over a glass of juice on a laptop. I ordered a keyboard on aliexpress, but accidentally broke the cable when replacing it. While I save money on a new top-case and a train - you need to make a stand - in the morning, negotiations. There is no place on the new laptop for the virtual machine, Linux is installed - it's a pity the working system. Decided - it’s worth a try on a smartphone, at the same time to evaluate its capabilities for iron.

2. Installation

We have - Sony Xperia M Dual, the latest build of Cyanogenmod with 4.4.4, MicroSD on 32GB class 10. The method should work for most smartphones with root rights and (preferably) custom firmware.
Google Play has a great Linux Deploy utility . It allows you to install one or several different Linux distributions on a smartphone and run them in a chroot environment. I will not describe the installation process of linux, there is a very visual video with pleasant music on the program page on Google Play, but just in case I’ll duplicate it here.

Installing GNU / Linux on Android via Linux Deploy.

We install the system according to the instructions on the video, I did as well, just chose Debian Wheezy. Click the Start button in the Linux Deploy window, the system is installed and running.
Next, we can connect with our favorite SSH client using the IP address of our smartphone, and we get into the Linux environment. The default password for the user is changeme , in root via sudo -s . For the installed Debian (Ubuntu), update the system and install the necessary packages:

aptitude update
aptitude upgrade
aptitude install mc tmux htop asterisk

3. Configuration

After installation, configuration files will be created in the / etc / asterisk / directory. To minimize the configuration of the VoIP server, you must change them. Under the spoilers, examples of settings:

; Main
;match_auth_username=yes        ; if available, match user entry using the
allowoverlap=no               ; Enable RFC3578 overlap dialing support.
srvlookup=yes                   ; Enable DNS SRV lookups on outbound calls
;pedantic=yes                   ; Enable checking of tags in headers,
disallow=all                   ; First disallow all codecs
allow=ulaw                     ; Allow codecs in order of preference
language=ru                    ; Default language setting for all users/peers
relaxdtmf=yes                  ; Relax dtmf handling
useragent=Asterisk PBX         ; Allows you to change the user agent string
dtmfmode = rfc2833             ; Set default dtmfmode for sending DTMF. Default: rfc2833
videosupport=yes               ; Turn on support for SIP video. You need to turn this
alwaysauthreject = yes         ; When an incoming INVITE or REGISTER is to be rejected,
autocreatepeer=no             ; Allow any UAC not explicitly defined to register
rtptimeout=60                  ; Terminate call if 60 seconds of no RTP or RTCP activity
recordhistory=yes              ; Record SIP history by default
dumphistory=yes                ; Dump SIP history at end of SIP dialogue
t38pt_udptl = yes,redundancy,maxdatagram=300 
faxdetect = no          ; Default 'no', 'yes' enables both CNG and T.38 detection
jbenable = yes              ; Enables the use of a jitterbuffer on the receiving side of a
limitonpeers = yes
register =>
; Provider
description=fakeExampleProvider ;)
;SIP users

exten => _X.,1,Hangup()
exten => ##,1,Pickup()
exten => s,1,NoOp(${CALLERID(num)})
same => n,Answer()
same => n,Queue(main,tr)
same => n,Hangup()
exten => _[23]XXXXXX,1,NoOp(${CALLERID(num)})
same => n,Dial(SIP/trunk/${EXTEN},,tTr)
same => n,Hangup()
exten => _8XXXXXXXXXX,1,NoOp(${CALLERID(num)})
same => n,Dial(SIP/trunk/${EXTEN},,tTr)
same => n,Hangup()
exten => _810XXXXXXXXXXXX,1,NoOp(${CALLERID(num)})
same => n,Dial(SIP/trunk/${EXTEN},,tTr)
same => n,Hangup()
include => internal_calls
exten => _10[12345],1,Dial(SIP/${EXTEN},,tTr)
same => n,Hangup()

persistentmembers = yes
autofill = yes
monitor-type = MixMonitor
updatecdr = yes
;musicclass = default
strategy = rrmemory
context = incoming_calls
timeout = 20
retry = 1
maxlen = 0
announce-frequency = 0
announce-holdtime = no
announce-position = no
monitor-format = wav
ringinuse = no
strategy = rrmemory
member => SIP/101
member => SIP/102
member => SIP/103
member => SIP/104
member => SIP/105

When the configuration is written, start the service and go to the CLI:
asterisk && asterisk -vvvvr

When starting a service from init.d, the module chan_sip is not loaded, it writes an error chan_sip.c:28816 reload_config: Unable to create SIP socket: Permission denied. From the root it starts normally, it will come down for a demonstration.

All is ready. I connected an FXS gateway and two softphones to our new PBX. On my device (Xperia M Dual), the processor load of 4 active channels is somewhere around 10%, it doesn’t stutter, there are no lags. You can call internal 101-105 to each other, and communicate with the outside world through a trunk from the provider.

4. Possibilities of application:
a) demonstration of the work of Asterisk PBX
b) portable geek PBX =)
c) for home use (they put it on routers with openwrt, you can do it on a smartphone)
d) just for fun

Ask questions in the comments and in the PM, not only within the framework of the article. If possible, I can prompt and help with the setup.
Thanks for attention.

By first comment
Исправил " Я занимаюсь" на «Я работаю в компании, которая занимается», спасибо shadowalone, сначала просто не придал значения, приношу извинения. Но все же, мои финансовые проблемы -мое личное дело, не так ли? ;)

Also popular now: