Disclaimer2: For this tutorial you'll have to be prepared for Asterisk terminologies like trunks and channels. If you're not familiar with this vocabulary, please take a quick look at this documentation.
Description of the environment: The server1 is placed on the Brazilian side. It's a Raspberry Pi model B that runs an asterisk-modded-for-raspberry-pi distro called raspbx. Attached to it there's an USB GSM dongle with a SIM card for the local Brazilian operator. In the same network of my server1 there's a Cisco PAP2t Internet Phone Adapter and, attached to it, a regular land line telephone. The same setup is duplicated on the German side, except that the Raspberry Pi is model B+.
- Someone in Brazil calls my Brazilian number, the dongle1 answers the call, redirects to an IAX2 trunk directly to server2. The server2 takes this incoming call and uses the dongle2 to place a new call to my german cellphone. The other way is still pinned to a single phone -- like, call my dongle2 to reach a single number in Brazilian side -- but improvements are coming.
- Someone uses phone1 on Brazilian side to call extension phone2 on German side (and vice-versa) like a regular landline phone.
- Someone uses phone1 or phone2 to reach my german cellphone.
Ok, so LET'S DO IT!!
I'm gonna skip the PAP2t configuration because I think it's too much. This is only needed if you want to use land line telephones, it's not required for the GSM bridge. If anyone is interested in doing that, please leave a comment and I'll write a new post only for that configuration.
Important note: All the configuration explained from now on is identical on both servers.
Important note: All the configuration explained from now on is identical on both servers.
- Install raspbx on your RPi's SD card. Also take a time to read through the raspbx documentation, which is very useful
- Use the script install-dongle (built-in inside raspbx) to install your dongle on your RPi. Important notes regarding problems I got:
- There's a list of GSM dongles that are tested with voice, SMS and USSD. I bought the Huawei E160;
- I had to unlock the voice feature with DC-Unlocker for Windows;
- Plug your dongle and only after that plug your RPi power. If you try to plug your dongle while the RPi turned on, you may experience your RPi to reboot due to power consumption failures;
- If your RPi starts rebooting it's because it can't handle the gsm dongle power consumption, in this case, use a proper powered USB hub. I bought the D-Link Dub-H7
- Find out the IMEI and the IMSI code of your dongle and set the correct values under /etc/asterisk/dongle.conf because /dev/ttyUSB1 or /dev/ttyUSB2 may change;
- Before you start configuring raspbx itself, it's important that you have both sides with network configured properly with static IPs and (in my case) DynDNS. I didn't want to open too many ports on the routers on both sides so I just setup an OpenVPN vpn;
- Setup a new custom trunk for your dongle under Connectivity → Trunks → Add Custom Trunk and set these values:
Trunk Name: to-my-cellphone
Outbound CallerID: Your SIM card number with country code (with a plus sign at the beginning)
Custom Dial String: dongle/dongle0/$OUTNUM$
Note: This is the trunk that will actually place the inbound calls to your personal telephone. - Setup a new IAX2 trunk under Connectivity → Trunks → Add IAX2 Trunk and set these values:
General Settings:
Trunk Name: Something that would remember the incoming connection from the other server
Outbound CallerID: Your personal phone number
Outgoing Settings:
Trunk Name: (same as above, I also used the same name and it's ok)
host=static IP under vpn of the remote serverusername=any usernamesecret=any passwordtype=friendtrunk=yesqualify=yesqualifyfreqok=25000tos=0x18
- Setup a new inbound route under Connectivity → Inbound Routes → Add Incoming Route:
DID Number: Your SIM card number with country code (with a plus sign at the beginning)
CallerID Number: Your personal cell phone number
Set Destinations: Trunk and your recently created IAX2 trunk.
Note: This is the route responsible to redirect an inbound call on your local dongle over the IAX2 trunk and then to your remote server.
If you noticed any omitted fields in the above configurations, it's because I didn't fill with anything or it's not important. I also did some extra work on Claning the SIM card memory for SMS every once in a while, I set a static IP for the OpenVPN so each server can always see each other, an additional service to check my credit balance every month and so and so forth. If you also want details like that please let me know in the comments :-)
That's it! You did it! If you need more help setting up anything else please let me know in the comments of this post. Good luck and have fun! :-)
4 comentários:
hi, thank you for such great article. Can you kindly make PAP2t configuration article too.
Regards
Hi, thanks for your post. I have just installed Raspbx-10-10-2020, set up Huawei E1752C modem and sending and receiving SMS messages works just fine.
I also set up trunk and added SIP extension. Here is a little change, because now you need to go to Applications - Extensions and and chan_pjsip extension (PJSIP listening on Port 5060 (UDP)).
It was real pain to set up Linphone on iPhone, but I managed it and it says it is connected.
However, when someone tries to call me, line is busy, and I am also not able to call. Any idea how to start debugging?
Hi, I managed to resolve all the problems. Everything is working just nice.
Maybe this will help someone: https://github.com/MatejKovacic/RasPBX-install
Postar um comentário