📜 ⬆️ ⬇️

Installing and running Asterisk on an Android smartphone

Hello, Habr!

It took me quickly to assemble a stand to demonstrate the work of an aster in a small organization. It was necessary to make several calls, demonstrate transfer, call pickup, etc. Sam VoIP server posted on your smartphone. Why on a smartphone, how and for what purpose - under the cut.



1. Why?

I work in a company that is engaged in setting up telephony for small and not-so companies in the city and region. In most cases, Asterisk is the most optimal PBX option, as it is easy to configure, scale to the needs of the organization, and you can add 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 a tuned aster, a Gigaset SIP handset, a 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 when replacing I accidentally broke the cable. While I save money for a new topcase and a train - you need to make a stand - in the morning talks. On a new laptop, there is no space for a virtual machine, there is no need to install Linux - it's a pity a working system. I decided - it is worth trying on a smartphone, at the same time assess its capabilities by hardware.
')
2. Installation

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

Install GNU / Linux on Android via Linux Deploy.



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

aptitude update aptitude upgrade aptitude install mc tmux htop asterisk 


3. Customization

After installation, configuration files will be created in the / etc / asterisk / directory. For a minimal VoIP server setup, you need to change them. Examples of settings under the spoilers:

sip.conf
 ; Main [general] context=incoming_calls allowguest=no ;match_auth_username=yes ; if available, match user entry using the allowoverlap=no ; Enable RFC3578 overlap dialing support. udpbindaddr=0.0.0.0 transport=udp 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 nat=no jbenable = yes ; Enables the use of a jitterbuffer on the receiving side of a canreinvite=no rfc2833compensate=yes limitonpeers = yes externrefresh=60 disallow=all allow=ulaw,alaw qualify=yes echocancel=yes echocancelwhenbridged=yes register => 4732453344-101:veryStrongSecret@server.prov.ru ; Provider [ext_template](!) disallow=all allow=ulaw,alaw description=fakeExampleProvider ;) type=peer context=incoming_calls nat=force_rport,comedia host=server.prov.ru fromdomain=server.prov.ru insecure=port,invite [trunk](ext_template) fromuser=4732453344-101 defaultuser=4732453344-101 authname=4732453344-101 secret=veryStrongSecret ; GSM ;Templates [global_template](!) type=friend qualify=yes host=dynamic nat=no notifyringing=yes call-limit=1 limitonpeers=yes insecure=port,invite secret=pass callgroup=1 pickupgroup=1 context=outgoing_calls ;SIP users [101](global_template) [102](global_template) [103](global_template) [104](global_template) [105](global_template) 


extensions.conf
 [default] exten => _X.,1,Hangup() [globals] [features] exten => ##,1,Pickup() [incoming_calls] ;from-trunk exten => s,1,NoOp(${CALLERID(num)}) same => n,Answer() same => n,Queue(main,tr) same => n,Hangup() [outgoing_calls] 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 [internal_calls] exten => _10[12345],1,Dial(SIP/${EXTEN},,tTr) same => n,Hangup() 


queues.conf
 [general] persistentmembers = yes autofill = yes monitor-type = MixMonitor updatecdr = yes ;musicclass = default strategy = rrmemory context = incoming_calls timeout = 20 retry = 1 weight=0 wrapuptime=1 autofill=yes maxlen = 0 announce-frequency = 0 relative-periodic-announce=no announce-holdtime = no announce-position = no monitor-format = wav ringinuse = no [main] strategy = rrmemory ringinuse=no member => SIP/101 member => SIP/102 member => SIP/103 member => SIP/104 member => SIP/105 



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

When you start the service from init.d, the mod_han_sip module does not load, writes the error chan_sip.c:28816 reload_config: Unable to create SIP socket: Permission denied . From the root it starts normally, it will come off for the demonstration.

All is ready. I connected an FXS gateway and two softphones to our PBX. On my device (Xperia M Dual) the load on the processor in 4 active channels is about 10%, it does not stutter, there are no lags. You can call internal 101-105 each other, and communicate with the outside world via a trunk from the provider.

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


Ask questions in the comments and drugs, not only within the article. Whenever possible I can prompt and help on setting up.
Thanks for attention.

For the first comment
Corrected "I do" on "I work in a company that deals with", thanks to shadowalone , at first I simply did not attach any importance, I apologize. But still, my financial problems are my own business, aren't you? ;)

Source: https://habr.com/ru/post/239419/


All Articles