Digital Privacy (Part 2)

Well, I finally have my own email server.  It hasn’t happened quite the way I was expecting, but in the end I believe this will be better.  I am paying for a VPS (Virtual Private Server) from DigitalOcean (A referral link, you get a $10 credit if you use it).  I’m using their smallest server.  I found a great setup called mail-in-a-box and installed it.  The hardest part for me was getting the DNS figured out, and then waiting for it to propagate.  It also includes built in support for Lets Encrypt so it is very easy to get SSL certificates setup.  I’ve been very impressed.  I started with my least used email/domain and once I have the kinks worked out I’ll move over my michel2010.name email/domain.  If that also goes well I will slowly transition to using a michel2010.name email address instead of my gmail address.

My email is still on a server not physically controlled by me, but DigitalOcean is  not (at least according to their privacy policy) going through it unless required to by the government.  This means if I am still paranoid about my emails being read I will need to encrypt them.  From what I understand it is best to encrypt the emails on the client side as apposed to the server, that way the encryption/decryption keys are not stored on the server.

Some quick follow up on my last privacy post: I am still using duckduckgo and startpage and really haven’t missed Google all that much.  I also am no longer on Facebook.

I just want to give one more shout out to the mail-in-a-box guys.  It really makes the whole setup of an email server almost painless.  If you are even remotely interested in running your own email server it is well worth a look.

 

Digital Privacy (Part 1)

For the past few months I have been thinking a lot about my online privacy.  I think what started this thought process was Windows 10 and the tracking that Microsoft enables by default.  I am well aware that Google, Amazon, and Facebook have been doing this sort of thing for years, but for whatever reason adding Microsoft in the mix bothered me.  The more I thought about it the more not just Microsoft but also Google started to bother me.

I have, to the best of my ability disabled/turned off the tracking and advertising features in Windows 10.  I have now started the journey of weening myself off of Google.  I’m using Firefox and Vivaldi for  my web browsers as apposed to Google Chrome.  Instead of Google searches I’ve started using duckduckgo and startpage (I know startpage uses Google, but in theory the searches are tied to their servers, not my computer).  Eventually I would like to stop using Gmail and Google drive.  I have also been contemplating leaving Facebook.

In the mean time I’ve setup email encryption for Ashley and I.  Mostly it is for fun, but more and more it annoys me that Google goes through my email to target adds at me.  I followed the instructions from this website, and used mailvelope to get it all setup.  In all fairness to Google, when I signed up I gave them permission to go through my emails.

The eventual part 2 of this post will hopefully be me building my own email server.  I suspect that could be a ways off, given time, money, and knowledge constraints.  I would also like to figure out a home brew public calendar.  I don’t suspect I will ever get rid of my Google account, but I would like to rely on it less.

Feel free to insert tin foil hat jokes here.

In case you are wondering (and I don’t suspect you are) here is my public key:

Edit (6/7/2016)– I had to redo my keys because I forgot my password.  I’ve updated the key below, but if for some strange reason you have a copy of the old one feel free to discard it.

—–BEGIN PGP PUBLIC KEY BLOCK—–
Version: Mailvelope v1.4.0
Comment: https://www.mailvelope.com

xsFNBFdXcRcBEACuMELdqVYHb1WC/flFIlyejZ1jovYLaYDaFWald8VCRRHF
pD9xEk0mlbpeN18xjfVpw79RTn00nWYh/K5FvXUkEUQVd2s9wFkq5C8p1tFf
HK4R4qLfPTUASc8bvsaSiKMbZjqjByVRdY95oC4WL9tx+iIpyxTNsN8r3uoX
6/IXDia+O6Ph7hu+MDKBfKuW/URDP/XD6+eT1F9R68VDrF1CKT7BkGYblQGe
Yt7zkDNZIZNc1wte160nQ0o4isPvIkPXylCbcUKmil7poL/NQv0ixpzZDJz+
v0dKosIz9wehfrb9TTpCwxDiSSAF5XAn5JqhTs90wEt99muBmdowNqYpgh2B
k+UIe9Kl5yzV6xQqqe8qHAbqvtP/V5/A3rzRmmIsrfg7WslUMK5Xhm9S8/PW
fHhko/8LDUW+dZsH4K1GTRWVXARp064t4TQdP2aed33cfG0W7riXgDc4apYY
QJuMuX3+q1m2PyzlJS31z6u3emuJLTAlx60oEofyenV+ZqLG3MOSrnnU8Hjb
arB7F2OlynZSN0doda+aMkLNSto/Z3CkEHPQia6Hfv3AcERVfSUz6HrS1nyC
oygJqzPMTUz2lt6Po3kyiflkwhwfiEHX6XmHLwwuyCfJVzz+8nqebik0ipDM
XUup9rIMjk3SRE6hnndS3wbqViGMSvup2nuPjwARAQABzSBFcmljIE1pY2hl
bCA8ZW0ua2FwdXRAZ21haWwuY29tPsLBdQQQAQgAKQUCV1dxHgYLCQgHAwIJ
EMj4OBsebHcnBBUIAgoDFgIBAhkBAhsDAh4BAABd7A//R+5Bfj7a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C KEY BLOCK—–

 

Our Projector Screen

So this post is unabashed bragging.  Ashley and I have been talking about purchasing a video projector for watching movies and playing our Xbox 360.  Thanks to a gift from her grandparents we were able to purchase said projector (we got it refurbished off of ebay).  We needed a screen.  An inexpensive screen.  After doing a bit of research we decided to make one ourselves.  We bought some white blackout cloth and some 1×3’s.  We put it all together and behold, our screen:  Picture Removed

We over sized it so we can take it outside and play movies.  It’s 94″ diagonal.  My bragging comes with how smooth it is.  I never expected us to be able to make it so large without having wrinkles in it.  Ashley gets most of the credit for that, but I think it’s really cool.  We built the whole thing in about 2 hours for around $25.  End of bragging.

Windows 10 Start Menu Issue

The problem is irritating.  After logging into Windows 10, left clicking on the Start Menu, and Search Bar on the left, or the Action Center, Volume control, and Network icon on the right does nothing.  You can right click these items, but a left click does nothing.  Also Windows Store does not work.  Note, this only happened with domain users.  Local users were unaffected.

We were running Windows server 2003 domain controllers, and the domain was set as a 2003 domain.  We upgraded our DC to Windows server 2012 R2, and adjust the domain level accordingly, but had the same problem.

I spent many hours fighting this issue.  I scoured the Internet trying to find a solution.  They all boiled down to basically this page here, and none of them worked.  By now you are going, “It is your group policy you idiot.”  That is what we thought.  We made a temporary OU, moved our test computers and users into it and turned off all the group policies.  Still no dice.

I did some more desperate Googling and found out that people were mentioning Windows firewall.  I went to change my Windows firewall settings and was unable to.  Upon further investigation the Windows firewall service was disabled (obviously we missed something in our GP removal).  I set the service to start automatically, rebooted and voila working start menu.  I mean obviously who wouldn’t make their start menu dependent upon their firewall service.  Duh.

I just thought I would post this in case some one else was having the same problem.

Just a side note:  Windows firewall does not need to be turned on in Control Panel, the service just has to be running.

EDIT:  Windows Firewall service needs to be started.  Simply setting the service to start automatically is not enough.

gmail Clone

Something I need to make absolutely clear from the start.  This post is NOT about setting up an actual email server.  This server sits on our local network, behind our router/firewall.  It does not have direct access to the Internet.  As such I was not focusing on security and will not vouch for it (this setup) being secure.

Ok, now that that is done, I need to give a little background.  Here at BMCR we have satellite Internet.  This means we have very limited bandwidth.  In order to stay under our cap, I limit bandwidth per day by IP address.  Once you hit your daily limit you can’t get to the Internet till the next day.  That is all well and good, but if you hit your limit you can’t check your email.  This was starting to be a problem.

Enter in these three programs postfix, dovecot, and offlineimap.  With this setup, our server syncs itself with our Google Apps email accounts, and then we check and send our email on/from the local server.  This way, even if you hit your bandwidth limit for the day, you can still do email (it also means that if for some strange reason all of Google’s servers die you have a local backup copy of all your emails).  I installed this on Ubuntu server 10.04 (the 32bit version).

I offer no guarantees that any of this will work for you, nor do I guarantee that it wont completely destroy your system if you try it.

Sources:

Postfix install and configuration: Techienote.com

Postfix setup for multiple smtp servers: Cyberciti.biz (I don’t actually talk about this in this post, but I did set it up.)

Dovecot install and configuration: Webmonkey.com

Offlineimap: Offlineimap.org

 

Postfix

Install

sudo apt-get install postfix -y

The “-y” matters, but I’m not sure why.  At the configuration screen select “No Configuration”

sudo cp /usr/share/postfix/main.cf.debian /etc/postfix/main.cf

Configuration

sudo vi /etc/postfix/main.cf

This is my main.cf:

# See /usr/share/postfix/main.cf.dist for a commented, more complete version

# Debian specific:  Specifying a file name will cause the first
# line of that file to be used as the name.  The Debian default
# is /etc/mailname.
#myorigin = /etc/mailname

smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
biff = no

# appending .domain is the MUA's job.
append_dot_mydomain = no

# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h

readme_directory = no

# TLS parameters
smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file=/etc/sll/private/ssl-cert-snakeoil.key
smtpd_use_tls=no
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache

# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
# information on enabling SSL in the smtp client

myhostname = repository.bmcr
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination =
relayhost = [smtp.gmail.com]:submission
mynetworks = 192.168.1.0/24, 127.0.0.0/8
mailbox_size_limit = 0
recipient_delimiter = +
default_transport = smtp
relay_transport = smtp
inet_protocols = all
home_mailbox = email/
mailbox_command = 

# SASL Settings
smtp_use_tls=yes
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_sasl_tls_security_options = noanonymous
smtp_tls_CAfile = /etc/postfix/cacert.pem
smtp_sender_dependent_authentication = yes
sender_dependent_relayhost_maps = hash:/etc/postfix/relayhost_map
smtp_generic_maps = hash:/etc/postfix/generic

Just a note, the “home_mailbox” parameter.  On our server every ones email is in a folder called “email” in their home directory.  You can call that folder whatever you want.

sudo echo "myfully.qualifieddomain.name" > /etc/mailname

sudo vi /etc/postfix/sasl_passwd

This opens the postfix password file.  One username and password per line.

For example:

#Per-sender authentication
username@Repository.BMCR username@bmcrministries.org:password
#Default login
[smtp.gmail.com]:587 username@bmcrministries.org:password

I’ll try and explain the following commands, but the sources links will have better explanations (owing to the fact they know what they are doing).

This secures the password file (the passwords are stored in it plain text):

sudo chmod 400 /etc/postfix/sasl_passwd

Postfix keeps some kind of a database hash of the postfix password file and the mailname file.  These update the databases after a change (these must be run whenever you modify there respective files):

sudo postmap /etc/postfix/sasl_passwd
sudo newaliases (this is for the /etc/mailname file… I think)

Setup the CA certificate.  This is a self-signed certificate, so most email clients/browsers will throw up a warning.  Remember this is running on our local network and isn’t accessible from outside.

sudo touch /etc/postfix/cacert.pem

sudo cat /etc/ssl/certs/Thawte_Premium_Server_CA.pem >> /etc/postfix/cacert.pem

Now restart postfix.

sudo /etc/init.d/postfix restart

To test postfix:

sudo apt-get install mailutils This will let you send an email from the command line.
echo “We rolling, yo” | mail -s “Sent from Repository” someone@somewhere.com

If you’ve got everything configured properly this should send an email.  The subject line will be the text following the “-s” and the body will be the text following “echo”.  The address is that of the recipient.

A couple of notes:

I had ‘inet_interfaces’ explicitly stated in my main.cf. For some reason that didn’t work. I removed the line and it defaulted properly. Once that was done I started getting alias.db errors, which were fixed by ‘sudo newaliases’. That was some how tied to ‘mynetworks’. That should default to the local subnet and local host, however I had to explicitly put that in. Once these things were figured out I could send email using Thunderbird.

Dovecot (IMAP server)

 Install

sudo apt-get install dovecot-imapd

Configuration

sudo nano /etc/dovecot/dovecot.conf

Find “protocols” and set it to “protocols = imap imaps”

Find “mail_location” and set that to “mail_location = maildir:/home/%u/email:LAYOUT=fs” (if you are using a different folder name make sure to use that instead)

Offlineimap

Install

For whatever reason I couldn’t get the Offlineimap in the Ubuntu repositories to work, so I installed from a different repository.

In order to add a ppa run this command:

sudo apt-get install python-software-properties

Then add the ppa:

sudo add-apt-repository ppa:pomeo/offlineimap

Then of course:

sudo apt-get update
sudo apt-get install offlineimap

Offlineimap is configured on a per user basis.  Each user will have an .offlineimaprc file in their home directory. OfflineIMAP is very picky about the configuration file. If you are getting errors open the file up again and double check your settings. For example if you have a space before “ui = TTY.TTYUI” it will error out.

My offlineimaprc:

[general]
accounts = BMCR

ui = TTY.TTYUI

[Account BMCR]
#Profile for local mail
localrepository = localrep
#Profile for remote mail
remoterepository = remoterep

[Repository localrep]
type = Maildir
localfolders = ~/email/

[Repository remoterep]
type = IMAP
remotehost = imap.gmail.com
ssl = yes
remoteuser = someone@somewhere.com
remotepass = password
nametrans = lambda folder: re.sub('.*Drafts$', 'Drafts', re.sub('.*Sent Mail$', 'Sent_Mail', re.sub('.*Trash$', 'Trash', folder)))
folderfilter = lambda foldername: foldername not in ['[Gmail]/All Mail','[Gmail]/Spam','[Gmail]/Starred','[Gmail]/Important']
maxconnections = 2

I would also chmod this to 400 when your done as it also contains a plain text password.  The documentation at offlineimap.org should walk you through all the options I’ve used.

I hope this was useful.  If something is un-clear, or simply wrong please let me know and I’ll try and fix it.

Freeswitch Howto: Configuration

In this section I’m going to focus exclusively on calling in and out over the POTS lines.  I’m doing this for two reasons.  One, this was the part I had the most trouble with, and two, the other dialplan options are (or seem to me to be) better documented.  I would suggest buying the Freeswitch book.  It’s been very helpful to me, though some if the information is outdated.

When setting up in-bound and out-bound analog calling (using the freetdm mod which was enabled on install) we deal with these files(these are all in the default install locations, if you installed some where else you’ll have to adjust accordingly):

/usr/local/freeswitch/conf/freetdm.conf
/usr/local/freeswitch/conf/autoload_configs/freetdm.conf.xml
/usr/local/freeswitch/conf/dialplan/default.xml
/usr/local/freeswitch/conf/dialplan/public/00_inbound_did.xml

I’ll post these, and go through the ones I know.

/usr/local/freeswitch/conf/freetdm.conf

[span wanpipe FXS]
name => freetdm
trunk_type => fxs
group => grp1
fxs-channel => 1:7

trunk_type => fxs
group => grp1
fxs-channel => 1:8

[span wanpipe FXO]

name => freetdm
trunk_type => fxo
group => grp2
fxo-channel => 1:1

trunk_type => fxo
group => grp2
fxo-channel => 1:2

trunk_type => fxo
group => grp2
fxo-channel => 1:3

trunk_type => fxo
group => grp2
fxo-channel => 1:4

trunk_type => fxo
group => grp2
fxo-channel => 1:5

trunk_type => fxo
group => grp2
fxo-channel => 1:6

Now to be honest I didn’t actually configure this file, or freetdm.conf.xml.  When /usr/sbin/wancfg_fs was run it automatically set both of these files up.  I didn’t have to change either of them.

/usr/local/freeswitch/conf/autoload_configs/freetdm.conf.xml

<analog_spans>
<span name=”FXO”>
<!–<param name=”hold-music” value=”$${moh_uri}”/>–>
<param name=”dialplan” value=”XML”/>
<param name=”context” value=”public”/>
<!– regex to stop dialing when it matches –>
<!–<param name=”dial-regex” value=”5555″/>–>
<!– regex to stop dialing when it does not match –>
<!–<param name=”fail-dial-regex” value=”^5″/>–>
</span>

<span name=”FXS”>
<!–<param name=”hold-music” value=”$${moh_uri}”/>–>
<param name=”dialplan” value=”XML”/>
<param name=”context” value=”default”/>
<!– regex to stop dialing when it matches –>
<!–<param name=”dial-regex” value=”5555″/>–>
<!– regex to stop dialing when it does not match –>
<!–<param name=”fail-dial-regex” value=”^5″/>–>
</span>
</analog_spans>

 

Now we get to the good stuff.  I took this from my default dial plan.  It only shows one of our five lines, but it should be enough to get you headed in the right direction.

/usr/local/freeswitch/conf/dialplan/default.xml

<extension name=”Call out business hours(Staff)” continue=”true”>
<condition field=”ani” expression=”^(1014|1015)” break=”on-true”/>
<condition wday=”2-6″ hour=”9-18″/>
<!– The call out prefix is 7 –>
<condition field=”destination_number” expression=”^7(.+)$”>
<action application=”set” data=”hangup_after_bridge=true”/>
<action application=”set” data=”continue_on_fail=true”/>
<action application=”bridge” data=”freetdm/FXO/2/$1″/>
<action application=”bridge” data=”freetdm/FXO/3/$1″/>
<action application=”bridge” data=”freetdm/FXO/4/$1″/>
<action application=”bridge” data=”freetdm/FXO/5/$1″/>
<action application=”bridge” data=”freetdm/FXO/1/$1″/>
<action application=”playback” data=”phrase:oh_gee”/>
</condition>
</extension>

The break down:

<extension name=”Call out business hours(Staff)” continue=”true”>

This is simply the extension name. I have continue set to true. I didn’t think I needed it but it wouldn’t work without it.

 

<condition field=”ani” expression=”^(1014|1015)” break=”on-true”/>

I have two phones that I don’t want dialing out on this extension. If phones 1014 or 1015 are dialing the number they won’t go out through this extension.

 

<condition wday=”2-6″ hour=”9-18″/>

This extension only works Monday through Friday between nine in the morning and six at night.

 

<condition field=”destination_number” expression=”^7(.+)$”>

Our “call out” number is seven. If seven is dialed before the number it is an external call and will be run through this extension.

 

<action application=”set” data=”hangup_after_bridge=true”/>

I’m not sure why this is important but I needed it.

 

<action application=”set” data=”continue_on_fail=true”/>

If you remember we have five outgoing phone lines (POTS). If one of them is busy (it fails to connect) I want to try the next phone line.

 

<action application=”bridge” data=”freetdm/FXO/2/$1″/>

This is the good part. This actually does the calling. The “freetdm/FXO/2” references freetdm.conf.xml. Span FXO, line 2. The “$1” is the number the person is calling. If line 2 is busy it “continue_on_fail=true” so it tries the next one (and so on and so forth).

 

<action application=”playback” data=”phrase:oh_gee”/>

This last line is simply a message, I recorded. If all the phone lines are in use this message gets played and the call ends.

 

Incoming Calls

This was by far the hardest part for me. Thanks to Steve on the Freeswitch mailing list for explaining it to me.

First let me explain what I was trying to do. Like I said earlier, we have five POTS lines. I needed to direct incoming calls from each line individually to different phones (and or groups) on campus. Where the calls get directed depends on the time of day and the particular phone line in question (I hope that isn’t to confusing).

/usr/local/freeswitch/conf/dialplan/public/00_inbound_did.xml

<!– LINE1 328-6825–>
<!– during work hours will ring the “Administration” phones –>
<extension name=”Line 1(6825) work” continue=”true”>
<condition field=”source” expression=”mod_freetdm”/>
<condition wday=”2-6″ hour=”9-18″/>
<condition field=”${channel_name}” expression=”^(FreeTDM/2:1/)$”>
<action application=”set” data=”domain_name=$${domain}”/>
<action application=”set” data=”transfer_ringback=$${us-ring}”/>
<action application=”transfer” data=”2020 XML default”/>
</condition>
</extension>

<!– During off hours goes to everyone except Kitchen and Guests –>
<extension name=”Line 1(6825) not work” continue=”true”>
<condition field=”source” expression=”mod_freetdm”/>
<condition field=”${channel_name}” expression=”^(FreeTDM/2:1/)$”>
<action application=”set” data=”domain_name=$${domain}”/>
<action application=”set” data=”transfer_ringback=$${us-ring}”/>
<action application=”transfer” data=”2035 XML default”/>
</condition> </extension>
<!– LINE1 DONE–>

Again, line by line:

<extension name=”Line 1(6825) work” continue=”true”>

This is simply the extension name. I have continue set to true. I’m pretty sure I need it, and it works with it enabled.

 

<condition field=”source” expression=”mod_freetdm”/>

This tells Freeswitch the source of the inbound call (pretty self explanatory).

 

<condition wday=”2-6″ hour=”9-18″/>

This extension only works Monday through Friday between nine in the morning and six at night.

 

<condition field=”${channel_name}” expression=”^(FreeTDM/2:1/)$”>

This tests to see what line is calling from the “mod_freetdm” source. My FXO ports are in the second span of my freetdm.conf,  so “FreeTDM/2:1/” is span two line 1. This is the part I got from Steve, and I couldn’t find this information any where.

 

<action application=”set” data=”domain_name=$${domain}”/>

I have no idea what this does but I know I need it.

 

<action application=”set” data=”transfer_ringback=$${us-ring}”/>

I’m assuming this changes depending on the country you live in.

 

<action application=”transfer” data=”2020 XML default”/>

This transfers the incoming call to (in my case) group 2020 in the default dial plan. It can be replaced with any valid extension number.

The second extension (again this is just for one of our phone lines.  Each line will need an extension) is for off hours and weekends.

 

Faxing

We have an analog fax machine, which is why I needed the FXS modules on my Sagnoma card.  Here are the relevant dialplan parts I used to send and receive faxes.

 

Receiving a Fax

This gets set up in the public dialplan.  On our install /usr/local/freeswitch/dialplan/public/00_inbound_did.xml.

<!– LINE3 328-6982–>
<!– Always directed to the fax machine –>
<extension name=”Line 3(6982)” continue=”true”>
<condition field=”source” expression=”mod_freetdm”/>
<condition field=”${channel_name}” expression=”^(FreeTDM/2:3/)$”>
<action application=”set” data=”domain_name=$${domain}”/>
<action application=”set” data=”transfer_ringback=$${us-ring}”/>
<action application=”bridge” data=”freetdm/2/3|freetdm/1/1″/>
</condition>
</extension>
<!– LINE3 DONE–>

<action application=”bridge” data=”freetdm/2/3|freetdm/1/1″/>

This is the important one.  It takes the incoming call from span 2 line 3 and transfers it to span 1 line 1.

 

Sending a Fax

This gets set up in the default dialplan.  On our install /usr/local/freeswitch/conf/dialplan/default.xml.

<extension name=”bridge-FXS-to-FXO” continue=”true”>
<condition field=”destination_number” expression=”^7(.+)$”/>
<condition field=”channel_name” expression=”FreeTDM/1:1/”>
<action application=”bridge” data=”freetdm/1/1/${destination_number}|freetdm/2/3/${destination_number}”/>   </condition>
</extension>

<condition field=”channel_name” expression=”FreeTDM/1:1/”>
<action application=”bridge” data=”freetdm/1/1/${destination_number}|freetdm/2/3/${destination_number}”/>   </condition>

These are the two lines that work the magic.  I got this off the Freeswitch wiki.  Direct span 1 line 1 to span 2 line 3 and dial the number.  Presto the fax goes out.

Freeswitch Howto: Installation

I’m not going to cover the installation of CentOS 5.5, nor will I cover how to setup a software RAID.  There are plenty of other tutorials already done that explain those things.  Here is what I did, though, step by step to get Freeswitch and the wanpipe drivers installed on our system (I’m assuming a basic working knowledge of the Linux command line).

Note: All of the following commands should be run as root.

yum list updates

yum update

yum install unixODBC-devel gnutls-devel libtiff-devel autoconf automake awk* bison core-devel curl-devel expat-devel flex gcc* gettext-devel gnutls gnutls-devel kernel-devel-$(uname -r) libjpeg-devel libtiff libtiff-devel libtool libX11-devel libzrtpmake ncurses-devel openssl patch python-devel unixODBC-devel zlib zlib-devel

The above commands should install all the dependencies needed for git, the Sangoma drivers, and freeswitch.

Install Git

Make sure /usr/local/lib is in your ld.so.conf, this is required for git-http-push to correctly link up to the Curl version you are installing.

vi /etc/ld.so.conf

Insert the following:
/usr/local/lib

Save the file, then run:
ldconfig

Now download and install Git:
cd /usr/local/src
wget http://www.codemonkey.org.uk/projects/git-snapshots/git/git-latest.tar.gz
tar xzvf git-latest.tar.gz
cd git-{date}
autoconf
./configure –with-curl=/usr/local
make
make install

Install Sangoma Drivers

cd /usr/local/src
wget ftp://ftp.sangoma.com/linux/current_wanpipe/wanpipe-latest.tgz
tar xfz wanpipe-latest.tgz
cd wanpipe-.tgz
make freetdm
make install

Install Freeswitch

cd /usr/local/src
git clone git://git.freeswitch.org/freeswitch.git
cd freeswitch
./bootstrap.sh

Edit modules.conf remove the “#” from the freetdm and flite modules:
vi /usr/local/src/freeswitch/modules.conf

When your done editing save and continue with the installation:
./configure
make
make install
make all cd-sounds-install cd-moh-install
The last command will download about 300Mb of sound files.  These are for the voice mail/IVR system and the music on hold.

Run this command to configure the Sangoma hardware. When I set this up I had to turn off hardware DTMF. When it was on using calling cards was almost impossible. Calling cards work just fine with the software DTMF.

/usr/sbin/wancfg_fs

This will start freeswitch. To start it as a daemon freeswitch -nc.
cd /usr/local/freeswitch/bin
./freeswitch

This will start the freeswitch command line when the command “fs_cli” is run.
ln -s /usr/local/freeswitch/bin/fs_cli /usr/local/bin/fs_cli

That’s it.  I would suggest starting Freeswitch with the -nc option, unless your having problems and need to trouble shoot.

Freeswitch Howto

As promised here is my Freeswitch howto.  A few things first.  The reason I’m doing this is to get more documentation out there.  I have to admit I have never been so disappointed with Google.  I had one heck of a time trying to find the information I needed, so I’m writing this in hopes that the next poor sap wont have such a hard time.  I offer no guarantees that any of this will work for you, nor do I guarantee that it wont completely destroy your system if you try it.  A lot of this information can be found on the Internet, some of it I got through the Freeswitch mailing list, the Freeswitch wiki, and the Sangoma wiki.  That being said here goes.

 

Background

I work at Beartooth Mountain Christian Ranch.  We run 10 weeks of camp in the summer, and a one year Bible college during the off season.  We have buildings spread across our campus, and wanted a phone system that worked in all of them.  Up until now we’ve had a system in the main office, but no way of transferring calls to the other buildings.  When our office phone system broke they told me to look into an actual campus wide PBX, and Freeswitch was what I came up with.  We’ve got five POTS lines that come into camp, 17 phones, one fax, and two soft phones to share them with.   We needed to be able to (obviously) send and receive phone calls and faxes, but we also wanted to be able to transfer phone calls and get every one a voice mail box.

 

The Hardware

Mother board: Asus M2N68-AM Plus

CPU: AMD Athlon X2 Black Edition 2.8GHz

RAM: 2Gb PC6400 Crucial

HDD: 2 500Gb WD in a software RAID 1 setup

Telephony Card: Sangoma A200 PCI-e with hardware echo cancelation – 1 Remora addon with 3 FXO modules, 1 FXS module, and a back pane connector.

Wired IP Phones: 15 Grandstream GXP280

Wireless IP Phones: 2 Cisco WIP310

The Software

I’m using CentOS as the operating system.  Freeswitch git version c7abfa7 (I downloaded it March 6, 2011).  Wanpipe driver version 3.5.18.

 

Installation

 

Configuration