Site map  

Asterisk 8 and later on Debian

IPv6 Configuration

Asterisk supports IPv6 for RTP and SIP.

asterisk.conf

Automatically set systemname to hostname does't always work the way it should.

systemname=my_system_name

iax.conf

More recent versions of Asterisk support IPv6 for IAX as well.
Enable IPv6;

bindaddr=::

sip.conf

Enable IPv6

Make sure that '/proc/sys/net/ipv6/bindv6only' is '0'. Otherwise Asterisk will be IPv6 only! You can set this in '/etc/sysctl.d/bindv6only.conf'.

bindaddr=::

RTP proxy

'directmedia=no' will turn Asterisk into a RTP audio proxy server. It will convert IPv6 RTP audio streams into IPv4 and IPv4 into IPv6 whenever required.

directmedia=no

Call-ID

Asterisk may use IPv6 address based Call-IDs when communicating with IPv4 only systems. This may confuse some software. Using a domain instead solves this problem.

fromdomain=mydomain.tld

TCP

If you want to use TCP enable it;

tcpenable=yes

To use SIP over TCP, just put it in the dial string;

SIP/username[:password[:md5secret[:authname[:transport]]]]@host[:port]

EG;

SIP/john::::tcp@example.org

TLS

If you want to use TLS enable it;

tlsenable=yes

TLS cert and key;

tlscertfile=/etc/asterisk/asterisk.crt
tlsprivatekey=/etc/asterisk/asterisk.key

Allow self signed certs;

tlsdontverifyserver=yes

For a self singed cert, a modified version of the Exim cert generation script can be used. Modify to suit your needs.
A let's encrypt dehydrated setup here. It uses a dns-01 DNS challenge and wildcard.

Example dial string;

SIP/john:tls@example.org

Music on hold

You may want to replace the default music on hold files that come with Asterisk by some other public domain music. You may also want to use SLN instead of GSM files. These sound a lot better then GSM files!
From man soxformat;

 .sln  Asterisk PBX `signed linear' 8khz, 16-bit signed integer, little-endian
       raw format.

Asterisk will convert these files on the fly to alaw, µlaw or whatever is required.

Convert the files

Below two ways to convert MP3 to SLN files. Both limit the bandwidth to 300 - 3400 Hz before limiting the sample rate to 8000 samples per second.

mp3-to-sln.sh;

#!/bin/bash

if ! [ -f "${1}" ]
then
	echo "File ${1} not found"
	exit 1
fi

# Base name
NAME=$( basename "${1}" .mp3 )
echo "Converting ${NAME}.mp3"

# Convert to wav
# Limit bandwidth to 300 - 3400 Hz, Mono
ffmpeg -i "${1}" -filter "highpass=f=300, lowpass=f=3400" -ac 1 "${NAME}.wav"

# Convert to sln
sox "${NAME}.wav" -t raw -r 8000 -e signed-integer -b 16 -c 1 "${NAME}.sln"

Use the script for the conversion;

~$ mp3-to-sln.sh File_Name.mp3

If the above script complains about clipping, use the scripts below instead.
First convert from MP3 to WAV;

mp3-to-wav.sh;

#!/bin/bash

if ! [ -f "${1}" ]
then
	echo "File ${1} not found"
	exit 1
fi

# Base name
NAME=$( basename "${1}" .mp3 )
echo "Converting ${NAME}.mp3"

# Convert to wav
ffmpeg -i "${1}" "${NAME}.wav"

Then use the script below to convert to SLN;

wav2sln.sh;

#!/bin/bash

if ! [ -f "${1}" ]
then
	echo "File ${1} not found"
	exit 1
fi

# Base name
NAME=$( basename "${1}" .wav )
echo "Converting ${NAME}.wav"

# Convert to sln
if [ -n "${2}" ]
then
	# Volume
	sox -v "${2}" "${NAME}.wav" -t raw -r 8000 -e signed-integer -b 16 -c 1 "${NAME}.sln" highpass 300 lowpass 3400
else
	sox "${NAME}.wav" -t raw -r 8000 -e signed-integer -b 16 -c 1 "${NAME}.sln" highpass 300 lowpass 3400
fi

If this script complains about clipping, reduce the volume by half;

~$ wav2sln.sh File_Name.wav 0.5

I put the files in '/usr/local/share/asterisk/moh/'.

Change Asterisk Music on hold configuration

Edit (as root) /etc/asterisk/musiconhold.conf;

directory=/usr/local/share/asterisk/moh

You may want to set the order to random;

sort=random
random=yes

Let Asterisk use the new configuration;

~# asterisk -r
moh reload
quit

Check for errors;

~# tail /var/log/asterisk/messages

More info