Asterisk How-To

Asterisk is an Open Source software VoIP PBX that is designed for home and small office use. It will run on most of the common operating systems out there.  Asterisk works great and there are now a lot of commercial companies using it as there telephone system.  While Asterisk works well it can be difficult to configure and setup, epecialy if you are new to the telephone world in general. 

trixbox_small.jpgtrixbox is a complete OS, asterisk PBX, web front end, and a number of goodies all rolled up in an single ISO. If you are new to asterisk, then trixbox will help get you off the ground running.  There is nothing really new in trixbox but they have packaged a number of open source projects together on top of Linux CentOS, sprinkled in some glue, and come out with a full featured and easy to use asterisk PBX.



Configure VLAN's in Trixbox

My network in my house has a few VLAN's to help devide the traffic up into logical segments.  I have a Voice VLAN that is used for VoIP so I can apply QoS to the VoIP traffic. This makes sure that regular traffic doesn't affect the telephone traffic.  The VLAN ID I use for Voice is 20.  You can pick any number for a VLAN ID from 2 to 4095 (Check your switch to see how many VLANs are supported).

Trixbox is build on CentOS (Red Hat based) so this howto will also apply to any Red Hat based Linux. Plase also not the following:

  • Not all network drivers support VLANs but most do.
  • Do not use VLAN 1 as this is usually refered to as the "default" VLAN and is most likly already used.

Your existing ethernet card configuration is stored in /etc/sysconfig/network-scripts/cfg-eth0.  The easiest way to create a VLAN is just to copy that file (adding the VLAN ID onto the end of the name) and then edit it.

# cp /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth0.20

Now edit the file your just created.

  1. Find the DEVICE=eth0 variable and change it to DEVICE=eth0.20
  2. Append the variable VLAN=yes to the end of the file.
  3. Change the IPADDR, NETMASK, and BROADCAST variables to what your require on the new VLAN.

 This is what my finished file looks like:


When you are done then restart the networking with the following command (or just reboot)

# /etc/init.d/network restart

Change sshd port in Trixbox

Recently there has been a number of attacks against the ssh port (TCP port 22). My version of ssh is currently patched up but it is still a pain to see hackers trying to run scripts against your ssh port over and over again. I have setup alerts that will warn me when some one tries to (or does) log into my systems. On some days I could get more than 1000 alerts that someone tried. Most of the attempts are from scripts that just try looking for the secure shell port and once they do, then they will try multiple attempts to get in.

The solution? Change the port. It's not a fool proof method because some one just needs to scan your system looking for the ssh port, but does help to reduce the attempts by stopping some one just looking for port 22. If they have to search for your ssh port, then they may just move on to another system instead.

How to do it!

Trixbox is running on CentOS Linux. The config file for sshd is /etc/ssh/sshd_config. It is possable to set the default startup port here but I don't like that solution. I prefer to change the port as a command line option when sshd starts up that way you can see the port that it is listening on when your view the processes. ( ps -aef ) The way to change the startup port for sshd is in the /etc/sysconfig/sshd file. This file is not there by default in Trixbox and will need to be created. It only needs one like in it setting the OPTIONS variable as follows:

# cat /etc/sysconfig/sshd

OPTIONS="-p 222"

Once the file is created, then restart the sshd daemon with the following command:

# service sshd restart

Once it is restarted, your sshd service will now be answering on the new port ( port 222 in this example ).

Remember to modify your clients to connect up using the new port.

Music on Hold not working

I installed trixbox CE 2.6.0 and noticed that the misic on hold was not working. If you go into the webGUI and click on the Music on Hold module it displays a number of file errors that is is not able to open the directory /var/lib/asterisk/mohmp3.  The directory is missing in the distribution. 

Here is what I did to fix it:

Secure shell into the trixbox and run the following two commands.
# cd /var/lib/asterisk
# ln -s moh mohmp3

Log into the webGUI and click on the Music on Hold module and there shouldn't be any errors. Then select System => System Maint. Click on the Reset Now button.

Test an extension.  The Music on Hold should now work.

NOTE: I understand this is now fixed in the latest version of trixbox (v


Multiple Extensions with a Common Mailbox

Create all the extensions on the trixbox as your normally would and create mailboxes for each of them.  It doesn't care what you set for each mailbox as we will be pointing them all at the common box.  For this example we will use mailboxes 300, 301, 302, and 303.  Decide on what mailbox will be the common one.  I am going to use mailbox 300 for the common one.

Now log into the trixbox and change to the /var/spool/asterisk/voicemail directory.  You will see two subdirectories, default and device.  Change to the default directory. Here you should see one directory for each mailbox that was created.  The mailboxes do not get created until they get used. If you do not yet see one for 300 then this is because it has not been used yet.  If it is not there, then just phone that extension and leave a voicemail message.  If the other boxes 301, 302, and 303 are there, then you can remove them with the following commands:

rm -rf 301
rm -rf 302
rm -rf 303

The next thing to do is create a symlink so that the extensions 301,302, and 303 all point to the master mailbox of 300.

ln -s 300 301
ln -s 300 302
ln -s 300 303

Make sure the owners on the symlinked mailbox are the same as the master mailbox. They should be owned by asterisk.

chown asterisk:asterisk 301
chown asterisk:asterisk 302
chown asterisk:asterisk 303

next change to the /var/spool/asterisk/voicemail/device and make sure that the symlinks are created.  If they are not, then manually create them as follows.

ln -s 300 301
ln -s 300 302
ln -s 300 303

You should now be able to have any of the extensions go into the common mailbox.

Enable Video Support

I downloaded the X-Ten softphone and was suprised to find out that the video call did not work.  When trying to enable the video it would turn on the "Sending video" message and then turn off again.  Searching through the docs and some google searches revealed the problem.  Video support is not turned on by default in the asterisk setup on trixbox. 

Here is the steps to enable video aupport. (I am running trixbox CE 2.6 and asterisk 1.4):

Edit the following file /etc/asterisk/sip_general_custom.conf and add the following lines


Then restart asterisk so that it reloads the config files.  You should now have working video support.

NOTE: X-Ten seems to have a bug in their code (or asterisk I'm not sure). When you start sending video, only the person that received the call will see both cemeras.  The fix is to put the call on hold for a second and then back off hold, you should now be able to see the video on both sides.