The following is the GNU All-permissive License as recommended in https://www.gnu.org/licenses/license-recommendations.en.html
Copyright (C) 2024 Free Software Foundation sysadmin@fsf.org
Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright notice and this notice are preserved. This file is offered as-is, without any warranty.
Contributions are welcome. See https://savannah.gnu.org/maintenance/fsf/.
asterisk
Logging in
Asterisk is on watson.fsf.org server.
ssh root@watson.fsf.org
Debugging
If there is choppiness on the conference bridge (meetme), login to watson.fsf.org and become root, then try the following:
Pull up the asterisk console
asterisk -vr
Look to see if there are ghosts or duplicate users on the bridge:
asterisk> confbridge list 7600
If you do not see anyone, they might be in a different room. You can use the command from Check for users before restarting
to list all participants.
This should show you something like the following:
Channel Flags User Profile Bridge Profile Menu CallerID
============================== ====== ================ ================ ================ ================
SIP/jrasata-00000015 default_user default_bridge default_menu jrasata
Old instructions: Notice that User #: 02 is the same as #08. In this case we can tell that the channel SIP/johns-00000083 has been open for 5 hours and 27 mins, this is obvious a ghost and causing the meetme plugin to generate additional traffic that the client cannot receive (causing choppy sounds over the bridge).
The solution here is to kill the channel, meetme has a clean way of doing this from the plugin itself with the following command:
asterisk> confbridge kick 7600 SIP/jrasata-00000015
This command kicks the User from the bridge and kills its channel cleanly. At this point the conference bridge should be back to normal.
When you are done, keep the asterisk shell up and running in a tmux
session. This displays more useful recent info than the regular file-based logs do.
Check for users before restarting
asterisk> core show channels
fail2ban and firewall
If you restore the firewall, ensure that you restart the fail2ban service, or our host will be unprotected from brute force attempts and this will also reduce the performance of the asterisk server. To verify correctness, look for fail2ban sections in the output of "iptables -L -v"
CLI-help
When you are in the asterisk CLI, you can type ?
or TAB at any point in your
command for suggested command completions
Reloading modules
After editing extensions.conf, run the following in the asterisks CLI:
> dialplan reload
After editing sip.conf:
> sip reload
If that is not enough (this does more than systemctl reload):
> reload
Files you will likely edit
Under /etc/asterisk/
:
extensions.conf
(dialplan)sip.conf
(SIP config, to be replaced bypjsip.conf
when we are ready)voicemail.conf
(voicemail)confbridge.conf
(conference calling)chan_dahdi.conf
(for editing physical phone lines)
Extensions.conf
First of all, read the README-SERIOUSLY.bestpractices.md
file linked
below. We must not allow others to commit toll fraud (dialing arbitrary numbers
from external calls) with our phone system, otherwise we will face a large bill
and/or downtime. There is also a risk of arbitrary code execution if we are
not careful.
Security highlights:
- Use strict pattern matching, avoid using
.
or!
. use FILTER() to avoid injection from arbitrary user input via caller id or dialed strings. - Do not use numbers for SIP device names (can be brute forced).
- Secure passwords.
- Avoid typos by using
same => n,...
syntax. - Avoid use of
EXEC*
to avoid arbitrary code execution. - Keep
live_dangerously
set tono
.
Extension number formatting (from PDF linked below):
_ denotes a pattern matching extension
N matches any number from 2 through 9
X matches any single digit
. matches one or more of any digit
[2-6] matches any of 2,3,4,5,6
Call Andrew according to ANDREW=SIP/andrew/
variable set above:
# extension,rule_number,command
exten => 39,1,NoOp(About to call Andrew's SIP line) # prints to console
exten => 39,2,Dial(${ANDREW},5,t)
Do more tasks based on order of inclusion, rather than explicit numbering
exten => 39,n,NoOp(Done calling Andrew's SIP line)
exten => 39,n,NoOp(Done calling Andrew's SIP line)
same => n,NoOp(Done calling Andrew's SIP line)
(I am not sure if those commands get processed if they reach voicemail, but a hangup event from either party should terminate the rule processing).
The s
extension stands for a special (or start?) extension
exten => 0,1,GoTo(4,7)
exten => 4,7,GoTo(context-name,s,1)
[context-name]
exten => s,1,NoOp(Got to this rule)
Note that parameters in ()
in at least some cases are required / counted from
right to left. So you can leave off the beginning of a parameter list to be
more concise, but you must include parameters through the end.
There is extensive documentation in the extensions.conf file itself, but you will
have to scroll down to the appropriate section to find it. Try searching the
file for Any category other
.
Do not forget to reload the Asterisk configs after making changes.
sip.conf
We use allowguest=yes
in our sip.conf file. This allows other SIP hosts to
connect to our SIP server without a user account password, and without us
allowlisting their IP address. Some companies might not want that, as they want
to be dialed by a phone number via the SIP trunk of their SIP provider, and
none of their customers use SIP to connect directly to other hosts. In our
case, if Free Software Org Foo wants to connect from their SIP server to ours,
disallowing guests would not allow them to connect.
https://kb.smartvox.co.uk/asterisk/secure-asterisk-pbx-part-2/
Custom voicemail name / greeting
For RMS' mailbox 43, the automated voicemail voice replies splices RMS' name in his own voice, rather than saying "extension 43":
/var/spool/asterisk/voicemail/default/43/greet.gsm
file -sL
has this to say about the above file:
greet.WAV: RIFF (little-endian) data, WAVE audio, GSM 6.10, mono 8000 Hz
So if someone wants the voicemail to refer to them by name, ask them to record their name into a microphone, then convert it into a similar format as above.
Call logs
Call logs are found in the /var/log/asterisk/cdr-csv/Master.csv
file where cdr stands for Call Detail Records.
An outgoing call starts with a sip account and is followed by the number that they dialed like so:
"","michael","918657127946",
An incoming call starts with an external number and is followed by the extension they used like so:
"","18657127946","501",
Verbose, recent logs
The best way to see detailed logs is to see them on the console of asterisk
-vvvvr
, because not all messages are logged to files, but they do show at that
command prompt. For this reason, I like to keep a tmux
session open with this
command, so we can look at recent lines if any issue comes up.
More Documentation
Security:
- https://github.com/asterisk/asterisk/blob/master/README-SERIOUSLY.bestpractices.md
- https://www.callcentric.com/support/device/security
- https://kb.smartvox.co.uk/asterisk/secure-asterisk-pbx-part-2/
General:
- https://www.redhat.com/sysadmin/introduction-voip
- https://www.redhat.com/sysadmin/introduction-asterisk
- https://www.redhat.com/sysadmin/sip-endpoint
- https://www.redhat.com/sysadmin/asterisk-dialplan
- https://www.redhat.com/sysadmin/asterisk-public-switched-telephone-network
- https://www.apricot.net/apricot2006/slides/tutorial/tuesday/Jonny_Martin-Asterisk.pdf
- https://www.voip-info.org/asterisk/
Faxing:
- https://wiki.asterisk.org/wiki/display/AST/T.38+Fax+Gateway
- https://www.asteriskguru.com/tutorials/asterisk_fax.html
- http://www.asteriskdocs.org/en/3rd_Edition/asterisk-book-html-chunk/Fax_id265396.html
Random notes
& means to ring multiple phones at the same time.
We have billing limits with callcentric, they will pause our account if we spend too much money, for example if someone figures out how to do fraud through our asterisk.
There are protocols for t.38, which should allow us to send faxes, but not sure if our fax machine supports it.