To start, I setup a clean, minimal Fedora 15 installation.
Install requirements
After installation, we install a few more tools that we need:
 yum install asterisk asterisk-fax #base
 yum install perl-Email-MIME libtiff-tools #for mailer script
 yum install telnet mc vim ntp rsync #for convenience and backup
Synchronize your time:
 sntp -s pool.ntp.org
Configuration
On a clean asterisk installation, we only edit a few files.
sip.conf
 Edit /etc/asterisk/sip.conf and make the following changes:
- Look for ;faxdetect=yes and uncomment it by removing the ;
 - Somewhere under [global] put your register string. For example:
register => myUsername:myPassword@12.34.56.78/31331234567
In this example 12.34.56.78 is the ip of my SIP provider and 31331234567 my internationalized fax number. - At the bottom, add the following lines:
[trunk-geeklab-9]
username=myUsername
type=peer
secret=myPassword
qualify=yes
host=12.34.56.78
canreinvite=yes
context=geeklab-fax
insecure=invite
 
extensions.conf
 To /etc/asterisk/extensions.conf add the following lines:
 [geeklab-fax]
 exten => 331234567,1,Goto(inboundfax,s,1)
 ;This is the DID number my provider rings. I would
 ;prefer 3133123... or 033123... but that's just the
 ;way it is. Your provider may use another format.
[inboundfax]
 ;I could have merged this with [geeklab-fax] but i decided not to.
 exten => s,1,NoOp(**** FAX RECEIVED from ${CALLERID(num)} ${STRFTIME(${EPOCH},,%c)} ****)
 exten => s,n,Set(FAXOPT(ecm)=yes)
 exten => s,n,Set(FILENAME=fax-${STRFTIME(${EPOCH},,%Y%m%d-%H%M%S)}-${CALLERID(num)})
 exten => s,n,Set(FAXFILE=${FILENAME}.tif)
 exten => s,n,Set(FAXOPT(ecm)=yes)
 exten => s,n,Set(FAXOPT(headerinfo)=Received by MYCOMPANY ${STRFTIME(${EPOCH},,%Y-%m-%d %H:%M)})
 exten => s,n,Set(FAXOPT(localstationid)=0331234567)
 exten => s,n,Set(FAXOPT(maxrate)=14400)
 exten => s,n,Set(FAXOPT(minrate)=2400)
 exten => s,n,NoOp(FAXOPT(ecm) : ${FAXOPT(ecm)})
 exten => s,n,NoOp(FAXOPT(headerinfo) : ${FAXOPT(headerinfo)})
 exten => s,n,NoOp(FAXOPT(localstationid) : ${FAXOPT(localstationid)})
 exten => s,n,NoOp(FAXOPT(maxrate) : ${FAXOPT(maxrate)})
 exten => s,n,NoOp(FAXOPT(minrate) : ${FAXOPT(minrate)})
 exten => s,n,NoOp(**** RECEIVING FAX : ${FAXFILE} ****)
 exten => s,n,ReceiveFAX(/var/spool/asterisk/fax/${FAXFILE})
 exten => s,n,Hangup()
 exten => h,1,NoOp(FAXOPT(ecm) : ${FAXOPT(ecm)})
 exten => h,n,system(/usr/local/bin/fax-process.pl --to yourname@geeklab.info --from fax@geeklab.info --subject "Fax from ${URIENCODE(${CALLERID(number)})} ${URIENCODE(${CALLERID(name)})}" --attachment ${FILENAME}.pdf --type application/pdf --file ${FAXFILE});
 
Inbound fax notification
When you get a fax, you'll probably want it in you mailbox. Download fax-process.txt and move it to /usr/local/bin/fax-process.pl. Make it executable using chmod 755 /usr/local/bin/fax-process.pl. If you haven't disabled SELinux, change the files security context by running: chcon system_u:system_r:asterisk_t:s0 fax-process.pl
Firewall
You won't get any calls if the firewall drops them. You may want a complex firewall. But since I'm using this virtual machine as a dedicated fax, I allow all from my SIP host and nothing from other hosts. Edit /etc/sysconfig/iptables to reflect your preferences. Mine are:
 *filter
 :INPUT ACCEPT [0:0]
 :FORWARD ACCEPT [0:0]
 :OUTPUT ACCEPT [59:6844]
 -A INPUT -s 12.34.56.78 -p tcp -m tcp ! --dport 22 -j ACCEPT
 -A INPUT -s 12.34.56.78 -p udp -m udp -j ACCEPT
 -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
 -A INPUT -p icmp -j ACCEPT
 -A INPUT -i lo -j ACCEPT
 -A INPUT -p tcp -m state --state NEW -m tcp -s my.ho.me.ip --dport 22 -j ACCEPT
 -A INPUT -j REJECT --reject-with icmp-host-prohibited
 -A FORWARD -j REJECT --reject-with icmp-host-prohibited
 COMMIT
You're done
Start asterisk by running service asterisk start and you're good to go.
© GeekLabInfo An Asterisk 1.8 fax server is a post from GeekLab.info. You are free to copy materials from GeekLab.info, but you are required to link back to http://www.geeklab.info

