I gathered together with my friend during the summer vacation to travel by car across Europe. And in the gray autumn there are thoughts to go closer to the equator. And the question of communication arose quite reasonably. Skype, ICQ and other services are nice, but not for the older generation. Wife and friends without question, and parents? The spouse immediately said that she would give (the person who transmits something) does not want to be. Another good idea would be to leave your work room so that people would not have the feeling that I had sunk into oblivion. Again, given the difficult roaming tariffication of our mobile operators, in which I have no desire to understand, an idea of ​​what I want to get in the end was formed.
- Calls from anywhere in the world at local rates
- Receive calls to your personal number
- Voice messages if I'm not available
- Voice mail
- Receive and send SMS
- Connection security
Software selection
')
Asterisk, which I occasionally come across for work, is the best way to implement budget VoIP. Cheap, angry and reliable.
GSM gateway is nice, but even goip is 12 thousand rubles. and more. Therefore, the only option that seemed acceptable to me was chan_dongle and a couple of huawei.
Receive and send SMS is either jabber or email.
Security is a separate topic. All the same, I think that it would not be great if an asterisk put a bare ass on public display. If you connect to an asterisk from a laptop, then in general, no matter what the VPN is. But this is not correct and it is not convenient to get a laptop each time. And considering that I have a fierce love for android, I studied the market on the subject of vpn clients and put on my old man galaxy s OpenVPN.
So let's get started
Rummaged in the far corner of the storeroom and got the old computer. Ubuntu system debian like me close. I put it exclusively from a blank, since ubuntu from a flash drive is put only after the magic pa.
Since they prefer jedi way on Habré and do not like standard installation mana, we will put an asterisk with 11 pens and hide the details under spoilers. OpenVPN will be put as mortals. The choice of 11 asterisk is due to the new xmpp module, in which the opportunity to process incoming messages has appeared.
Openvpn
Since it was decided to use the connection via OpenVPN and the computer with an asterisk will be at work behind the nat, we will use an external VPN server. For personal use, I have servachek from the Germans. But in principle, it will not be worse if you use anything that is ours. I liked the selector (never an advertisement), everything is intuitively clear, it only takes place on the way. And the cost is quite humane, you need to turn it on, do not turn it off.
In general, we roll openVPN on anything that is sticking into the network, in my case debian.
For serverWe put OpenVPN
sudo su aptitude update aptitude upgrade aptitude install openvpn
Create a directory and copy a set of scripts from the examples:
mkdir /etc/openvpn/easy-rsa/ cp -r /usr/share/doc/openvpn/examples/easy-rsa/2.0/* /etc/openvpn/easy-rsa/
Editing vars
nano /etc/openvpn/easy-rsa/vars
I ruled:
export KEY_COUNTRY="RU" export KEY_PROVINCE="REGION" export KEY_CITY="GLUBINKA" export KEY_ORG="KROILOVO CORP" export KEY_EMAIL=”KC@example.ru”
Next, we generate certificates and transfer them to the directory with settings:
cd /etc/openvpn/easy-rsa/ source vars ./clean-all ./build-dh ./pkitool --initca ./pkitool --server server cd keys openvpn --genkey --secret ta.key cp server.crt server.key ca.crt dh1024.pem ta.key /etc/openvpn/
Now you need to generate certificates for clients.
cd /etc/openvpn/easy-rsa/ source vars ./build-key client_name , clien_name
You must transfer to client devices:
/etc/openvpn/ca.crt /etc/openvpn/easy-rsa/keys/clien_name.crt /etc/openvpn/easy-rsa/keys/ clien_name.key /etc/openvpn/ta.key
My server.conf
port 1110 proto tcp dev tun ca ca.crt cert server.crt key server.key dh dh1024.pem server 192.168.100.0 255.255.255.0 ifconfig-pool-persist ipp.txt client-to-client
For linux clientsWe put OpenVPN
sudo su aptitude update aptitude upgrade aptitude install openvpn
in / etc / openvpn should lie
ca.crt clien_name.crt lien_name.key ta.key client_name.conf
My client_name.conf
Client dev tun proto tcp remote serverIP 1110 resolv-retry infinite nobind persist-key persist-tun ca ca.crt cert client_name.crt key client_name.key tls-auth ta.key 1 comp-lzo verb 3
For Android customersFrom google play we put OpenVPN for Android
We copy on the flash drive device certificates generated on the server
We set the address and port of the server, add certificates and connect.
As a result, we get all the devices in one VPN.
I got 5 devices:
- OpenVPN server
- Asterisk
- A laptop
- Phone
- Companion phone
Asterisk
Go to asterisk.org and download it. At that moment when I put asterisk.org lay. Therefore, I put 11.2.1 since it was lying on my computer. Currently 11.4.0 is available. I do not think that is very different, but did not read the changelog.
Install Asterisk sudo su mkdir /usr/src/asterisk cd /usr/src/asterisk wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-11-current.tar.gz aptitude update aptitude upgrade
We put dependences
aptitude install build-essential linux-headers-`uname -r` g++ libmysqlclient-dev libxml2-dev libncurses5-dev libsqlite3-dev libssl-dev libsrtp0-dev unixodbc-dev
Since it is planned to use jabber, iksemel and openssl should be installed. Without them, the xmpp module will not build
aptitude install libssl-dev libssl1.0.0 libiksemel-dev libiksemel3
We start to put
tar xvf asterisk-11-current.tar.gz cd asterisk-11-current ./configure make menuselect
Added xmpp and ael the rest by default
make make install
doing
make samples
to get default configs.
doing
make config
That the asterisk was started by a demon.
Chan dongle
Next we need to collect chan_dongle. A wonderful project that was supported by comrade BG2, but the roofing felts disappeared, the roofing felts, due to the insurmountable circumstances of the updates, the project was not long enough (which is regrettable) and it refuses to assemble at 11 asterisk. But github will help us.
Install chan_dongle aptitude install git cd /usr/src/asterisk wget https://github.com/jstasiak/asterisk-chan-dongle/archive/asterisk11.zip unzip asterisk11.zip
Well, then on the manual
aclocal autoconf automake –a ./configure Make Make install
Then read the wiki project
wiki.e1550.mobi and find modems from the list of supported. In my case, it turned out to be E1550 and E173. With the modems themselves, everything is simple, google for usbmodeswitch or, under windows, we only transfer to modem mode via the terminal. On my E1550, it was still necessary to activate the voice functions. I didn’t make any special changes in Dongle.conf, only IMSI added my own SIMs, according to which the module will choose that SIM, and the context for the incoming ones.
dongle.conf changes context=dongle-incoming [mts] imsi=25001xxxxxxxxxx; exten=911 [megafon] imsi=25002xxxxxxxxxx; exten=921
now we are overloading the module in the CLI of the asterisk and checking if the modems are hooked
dongle reload now dongle show devices
If everything is seen and everything is good, then you can start setting up all this stuff.
Configure Asterisk
We register users in sip.conf
sip.conf [general] language = ru; tcpenable = yes ; transport = tcp,udp; [LOCAL-USERS](!) type = friend ; host = dynamic ; context = from-office ; disallow = all ; allow = ulaw ; allow = alaw ; allow = gsm ; monitor = yes ; callcounter = yes ; callwaiting = no ; rtptimeout = 10; rtpholdtimeout = 20; dtmfmode = rfc2833 ; [10](LOCAL-USERS) ; username = 10 ; secret = passfor10 ; [11](LOCAL-USERS) ; username = 11 ; secret = passfor11 ; [12](LOCAL-USERS); username = 12 ; secret = passfor12; [13](LOCAL-USERS); username = 13 ; secret = passfor13; [14](LOCAL-USERS); username = 14 ; secret = passfor14;
Create a queue at queues.conf
queues.conf [general] persistentmembers = yes ; autofill = yes ; monitor-type = MixMonitor [WORKGROUP] strategy = ringall; ringinuse = yes ; timeout = 20 ; retry = 1 ; maxlen = 0 ; member => SIP/10 member => SIP/11 member => SIP/12 member => SIP/13 member => SIP/14
Since I consider AEL to be more convenient for perception, the dialplan wrote exclusively on it.
Extensions.ael Globals { __TRANSFER_CONTEXT=transfer; // }; context transfer{ _1X => Dial(SIP/${EXTEN},60,t); // } context from-office { includes { ; // mobile-numbers; city-numbers; local-users; }; }; context mobile-numbers { ;// _89XXXXXXXXX => Dial(Dongle/s:25002/${EXTEN},,T); // , :) }; context city-numbers { ; // _XXXXXX => Dial(Dongle/s:25002/${EXTEN},,T); }; context dongle-incoming { ;// c chan_dongle 921 => Queue(WORKGROUP,t,,,60); // workgroup 911 =>{ ;// Answer; Dial(SIP/10,60,tT); // Dial(SIP/11,60,tT); // Playback(/tmp/ya_v_otpuske); // Jabbersend(asterisk@jabber_example.ru,grasp@jabber_example.ru, {CALLERID(num)}); // jabber Hangup; }; sms => { Jabbersend(asterisk@jabber_example.ru,grasp@jabber_example.ru,${CALLERID(num)} ${SMS}); // jabber Hangup(); }; ussd => { Jabbersend(asterisk@ jabber_example.ru,grasp@jabber_example.ru,${USSD}); // // jabber ussd Hangup(); }; }; context local-users { _500 => { ; // Wait(2); Record(/tmp/ast:wav); Wait(2); Playback(/tmp/ast); Wait(2); Hangup; }; _600 => { ; // , jabber System(/usr/sbin/asterisk -x 'dongle ussd mts *100#'); System(/usr/sbin/asterisk -x 'dongle ussd megafon *100#'); }; _1X => { Dial(SIP/${EXTEN},60,tT); // }; };
The logic is as follows: When calling a work number, the calls are wrapped in a queue. In this queue, all my devices and the second line on the partner's VoIP phone, which is in the office. When I call my personal number, asterisk will first try to connect with the android, then with the laptop and if I am not available, a voice message will be played that I am on vacation and will be able to contact all the thirsty at the first opportunity. Well, at the end of the message in jabber.
On the android I installed 2x clients 3cx and CSipSimple. There were problems with sound in one direction, but there was no time to deal with it, so openVPN ticked off “redirect all traffic through VPN” and it all worked. Checked through 3G and wifi, it does not work.
For jabber raised openfire. I think it is not worth describing and you can use something third-party. In xmpp.conf I registered the settings and everything started from the floor of the kick. OpenFire put it out of curiosity, since there is a plug-in for asterisk under it, but this is another story. It remains to tighten the sending of SMS via jabber, but for the time being I have not finally decided whether I really need it. You also need to set up voice mail, but it seems that it’s not very relevant yet, I’ll be back from vacation and it will be clear.
As a result, let's see how my whole venture takes root. In my head there are thoughts on the implementation of a sort of mobile office, with redirects to colleagues, work far beyond the desktop and other buns.
Please do not judge strictly. If I forgot to specify something, I’ll correct it, because I described the sequence of actions from memory, and I could have missed something. Also, if the older comrades will share their ideas or realizations of anything like that, I will only be happy.