Asterisk
Asterisk is a software implementation of a telephone private branch exchange (PBX) originally created in 1999 by Mark Spencer of Digium. Like any PBX, it allows attached telephones to make calls to one another, and to connect to other telephone services including the public switched telephone network (PSTN) and Voice over Internet Protocol (VoIP) services. Its name comes from the asterisk symbol, “*”.
NOTE: FreeSWITCH may be a solid replacement for asterisk as it has support for the Linksys SPA3000 as well as ZRTP and SRTP support. It might be wise to look into using kamailio as a front end SIP router though this doesn't seem to be necessary unless we want to start handling multi-thousands of calls concurrently.
A few references for help when building FreeSWITCH.
Previous Reasoning
This was setup on my private network to provide a land line phone to my office using our existing internet connection. I wanted to go about doing this without having to pay for the services as I don't expect this to get a lot of use.
This Asterisk setup involves the use of Google Voice and SIPGate. SIPGate provides a single phone number, SIP connectivity and call forwarding. Google Voice doesn't provide services to receive phone calls, however, it can be setup as an intermediary that will call you and then connect to another number on your behalf, while also providing call forwarding.
Combining the three will get free incoming and outgoing to anywhere in the US and Canada. Incoming calls will come from Google Voice, which will forward the call to the SIPGate phone number, which the Asterisk PBX will be tied to and we'll in turn be able to receive the call.
Outgoing calls are a bit more tricky. Implemented using pygooglevoice, the Asterisk box will actually connect to Google Voice's APIs to dial the number and call back (making it an incoming call and thus free) to make the outgoing call.
Links
- http://ofps.oreilly.com/titles/9780596517342/asterisk-Arch.html
- http://www.asteriskdocs.org/
- http://www.voip-info.org/
- http://nerdvittles.com/index.php?p=65
- http://www.voip-info.org/wiki/index.php?page=Asterisk+LDAP
- http://download.ag-projects.com/
Security Notes
Asterisk/SIP are going to be a significant security hole in the network if I allow outside access to the SIP services (In case I want to say be able to pick up the phone from my laptop while at a cafe or from my office). I intend to research making this considerably more secure before allowing this kind of setup and will document it here.
One of the things for me to note ahead of time is to not put incoming calls into the same context as my dial plans. This alone will be a significant increase in any kind of security.
Encryption
The configurations provided have TLS enabled BUT it won't do any good until the server has a certificate. A normal webserver certificate in PKCS12 format. FOR TESTING ONLY you can generate a self signed certificate. You'll need both the certificate authority's cert and the key/cert pair for the server.
You can use the following to create a self-signed one:
|
|
Firewall Adjustments
# Allow incoming SIP calls from the local network
-A PRIMARYSERVICES -s 10.13.37.0/24 -m udp -p udp --dport 5060 -j ACCEPT
-A PRIMARYSERVICES -s 10.13.37.0/24 -m tcp -p tcp --dport 5060:5061 -j ACCEPT
# Log and allow SIP traffic from other people
-A PRIMARYSERVICES -m state --state NEW -m udp -p udp --dport 5060 -j LOG --log-prefix "SIP Traffic "
-A PRIMARYSERVICES -m state --state NEW -m tcp -p tcp --dport 5060:5061 -j LOG --log-prefix "SIP Traffic "
-A PRIMARYSERVICES -m udp -p udp --dport 5060 -j ACCEPT
-A PRIMARYSERVICES -m tcp -p tcp --dport 5060:5061 -j ACCEPT
# Allow incoming RTP traffic from the local network
-A PRIMARYSERVICES -s 10.13.37.0/24 -m udp -p udp --dport 10000:10100 -j ACCEPT
# Log and allow RTP traffic from other people
-A PRIMARYSERVICES -m state --state NEW -m udp -p udp --dport 10000:10100 -j LOG --log-prefix "RTP Traffic "
-A PRIMARYSERVICES -m udp -p udp --dport 10000:10100 -j ACCEPT
Fail2Ban
Due to the overwhelmingly large number of attackers trying to exploit unsecured Asterisk boxes, configuring Fail2Ban with Asterisk is HIGHLY recommended. I'm updating the regular expressions in that template as I see attacks, and in some cases where I intentionally generate the logs myself.
Config Files
There are a significant number of configuration files created when asterisk is installed, these all reside in "/etc/asterisk". I'll go over the ones that I made modifications too including full source (without the comments that come included, there are a lot of them). I copied the original files to "*.conf.o" and blew away most of the files I edited (including the stock comments).
/etc/asterisk/asterisk.conf
|
|
/etc/asterisk/ccss.conf
/etc/asterisk/cdr_adaptive_odbc.conf
/etc/asterisk/cdr.conf
|
|
/etc/asterisk/cdr_syslog.conf
|
|
/etc/asterisk/extensions.conf
The only thing that I have changed in the below configuration is that where it says 'SPA3000' in the variables I used the MAC address of the actual SPA3000 device as it is defined in sip.conf (this has also been changed there). This will allow it to remain unique even if another is added.
|
|
/etc/asterisk/features.conf
/etc/asterisk/indications.conf
I never got around to configuring this file, I left the section here as the default asterisk install adds this file in. For now you're on your own in configuring indications.
/etc/asterisk/logger.conf
|
|
/etc/asterisk/manager.conf
/etc/asterisk/modules.conf
|
|
/etc/asterisk/musiconhold.conf
/etc/asterisk/res_odbc.conf
|
|
/etc/asterisk/rtp.conf
|
|
/etc/asterisk/sip.conf
|
|
/etc/odbc.ini
Here is the schema for the table that I use:
|
|
Music On Hold
The way that music on hold is configured in the dial plan on this page it will look for files in the directory "/usr/share/asterisk/moh/". Files will be chosen at random from this directory as long as asterisk can read them (that is it has a codec for the audio file loaded). I strongly suggest the music be in "ogg" format.
Text to Speech
Please refer to my notes on Festival for more information on text to speech with asterisk.
linux operations telephony voip
fbd8ca38 @ 2024-07-15