~ 2 min read

Hylafax + Iaxmodem on pure Asterisk/FreePBX (replacing (rt)fax)

share this story on
More juicy linux-based Asterisk telephony recipes for you

Steps that should be taken to replace (rt)fax which comes with a default asterisk/freepbx install with iaxmodem+hylafax solution.
The whole procedure was done on a debian testing/unstable with asterisk and freepbx (2.1.0) installed.

install hylafax related tools:

apt-get install hylafax-client hylafax-doc hylafax-server  

install iax related libraries (we’re installing libiax and spandsp libraries)

apt-get install libiax-dev libiax0 libiaxclient-dev libspandsp-dev libspandsp1  

install iaxmodem

apt-get install iaxmodem  

Installation complete, let’s move on to configuration procedures…

Configure iaxmodem with the proper extension information:

nano /etc/iaxmodem/ttyIAX0  

Add the following to the file, save and exit:

device /dev/ttyIAX0  
owner uucp:uucp  
mode 660  
port 4570  
refresh 300  
peername 201  
secret 1234  
cidname Fax  
cidnumber 972554211012  
codec alaw  

Important stuff to note is the extension information (peername: 201 and password: 1234) which means that you should add a new iax2 extension to asterisk (can be done through freepbx’s configuration panel) and ofcourse the server IP.
Also note that for each fax extension you’re going to have you’ll need to use a different port number.

Hylafax Configuration:

copy the sample config file from /var/spool/hylafax/config/iaxmodem to /var/spool/hylafax/etc/config.ttyIAX0
and add the following to the end of the file:

"RingsBeforeAnswer: 1"

save the file and you’re done.

To test if this is working or not get on a terminal and run:

/usr/bin/iaxmodem ttyIAX0  

You should see debug output information and in the end registration successful, like this:

[2006-11-23 17:42:13] Modem started  
[2006-11-23 17:42:13] Setting device = '/dev/ttyIAX0'  
[2006-11-23 17:42:13] Setting owner = 'uucp:uucp'  
[2006-11-23 17:42:13] Setting mode = '660'  
[2006-11-23 17:42:13] Setting port = 4570  
[2006-11-23 17:42:13] Setting refresh = 300  
[2006-11-23 17:42:13] Setting server = ''  
[2006-11-23 17:42:13] Setting peername = '201'  
[2006-11-23 17:42:13] Setting secret = '1234'  
[2006-11-23 17:42:13] Setting cidname = 'Fax1'  
[2006-11-23 17:42:13] Setting cidnumber = '0015554731543'  
[2006-11-23 17:42:13] Setting codec = alaw  
[2006-11-23 17:42:13] Opened pty, slave device: /dev/pts/4  
[2006-11-23 17:42:13] Created /dev/ttyIAX0 symbolic link  
Restart 0  
[2006-11-23 17:42:13] Registration completed successfully.  

then run hylafax to intercept the calls:

/usr/sbin/faxgetty /dev/ttyIAX0  

You can monitor the status of the fax by looking at /var/spool/hylafax/status/ttyIAX0

watch cat /var/spool/hylafax/status/ttyIAX0  

This will refresh every 2 seconds, you should see at first “initializing server” and in the end “running and idle”.
Once a call is received you should see it on iaxmodem’s debug output and also on hylafax status file.

In the end if everything was successful you should have the file saved in /var/spool/hylafax/recq/*.tif
Once you’ve made sure it’s working you should add it to inittab for permanent usage:

S0:2345:respawn:/usr/sbin/faxgetty ttyIAX0