HOWTO Install HylaFax with iaxmodem on a running CentOS 4.3 + Asterisk 1.2.7.1 system with FreePBX 2.1

This is a different setup from the default fax installation in FreePBX
which uses rxfax and txfax. By using HylaFax instead you will get a
fully featured enterprise class fax server.

- Download the Redhat Enterprise Binary RPM of HylaFax 4.3.0 (hylafax-4.3.0-1rhel4.i386.rpm)

- Install it

- Run /usr/sbin/faxsetup which may complain about missing components (note: mgetty-voice is not required)

- ln -s /usr/share/fonts/ghostscript /usr/share/ghostscript/fonts

(to solve missing fonts problem)

For documentation on HylaFax I prefer the docs at
http://hylafax.sourceforge.net/howto/index.php instead of the docs at
hylafax.org (sf.net is a fork)

Questions in FaxSetup:

Should an entry be added for the FaxMaster to /etc/aliases )yes(? yes

Users to receive fax-related mail )root(? root

HylaFAX configuration parameters are:

1 Init script starts faxq: yes

2 Init script starts hfaxd yes

3 Start old protocol: no

4 Start paging protocol: no

Are these ok yes? yes

Setup scheduler options according to local requirements. Left most of it default except for the area codes and dialling rules.

- Download IAXmodem from http://iaxmodem.sourceforge.net/

- Check the README of IAXmodem for installation. If you already
have a version of spandsp or libiax installed (which you want to keep)
you to build statically, otherwise just build normally (just
./configure && make for libiax2 and spandsp, then ./build for
iaxmodem). After that move the iaxmodem binary you just built to
/usr/local/sbin

This is my example /etc/iaxmodem/ttyIAX0 :

device /dev/ttyIAX0 #each line should have it's own device node!

owner uucp:uucp

mode 660

port 4570 #each line should have it's own port number!

refresh 300

server 127.0.0.1

peername 201 #this is the local extension number in FreePBX (create it!)

secret 12345 #password for the extension

cidname Fax1

cidnumber 0015554731543

codec alaw

Now that iaxmodem is configured we must make sure that HylaFax will
find it as modems. In the tarball of iaxmodem you will find a file
config.ttyIAX Edit this file (if you are in Europe use
etc/dialrule.europe for example instead of default). You only need to
change the first 6 lines. When done copy the file to
/var/spool/hylafax/etc/ similar to the other files, one for each modem,
i.e. onfig.ttyIAX0 onfig.ttyIAX1 etc.

Don't forget you also need to setup basic HylaFax stuff but the HF docs will help you there.

After starting iaxmodem, you then need to run faxgetty on the
ttyIAX device. Then hylafax will start to answer calls. To try it from
the commandline first start "/usr/local/sbin/iaxmodem ttyIAX0" and in
another screen "faxgetty /dev/ttyIAX0"

If it works, put something like this in /etc/inittab :

iax1:2345:respawn:/usr/local/sbin/iaxmodem ttyIAX0

iax2:2345:respawn:/usr/local/sbin/iaxmodem ttyIAX1

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

mo2:2345:respawn:/usr/sbin/faxgetty ttyIAX1

The first two lines start two iaxmodem sessions, the last two enabe fax receive on the 2 modems.

Then run : "/sbin/init q" to reload the inittab settings

This works for me, now I need to get fax routing working based on
DID. As far as I can see now, it will not be possible to do this with a
standard IAX extension from FreePBX, I guess we need to create a custom
one. From the HylaFAX mailinglist :

When you dial the iaxmodem, you need to append the DID that is coming in on the line:

exten => 900,1,Dial(IAX2/iaxmodem0/${EXTEN},10,r)

The ${EXTEN} variable gets set as $CALLID4 in Hylafax, where you can then route in FaxDispatch:

case "$CALLID4" in

8001112222)

SENDTO="joeschmoe@somewhere.com"

;;

8005551111)

SENDTO="foo@bar.com"

;;

*)

SENDTO="baz@failover.com"

;;

esac

I still need to figure out how to create the proper extension
configs in FreePBX. I tried adding the ${EXTEN} to the dial string of
an IAX extension but FreePBX doesn't like that. And if you would try to
use a trunk (which you can customize) then you cannot forward inbound
routes to it.

Taxonomy upgrade extras: