FreeSWITCH for Ubuntu 14.04 Freeswitch is an open-source alternative to Asterisk to build a voip telephony server. It was launched by a member of the Asterisk development team who wanted to rewrite the whole thing from scratch to cleanly separate the switching part from the PBX part. 1. Add repository Add freeswitch repository. curl http://files.freeswitch.org/repo/deb/debian/freeswitch_archive_g0.pub sudo apt-key add echo "deb http://files.freeswitch.org/repo/deb/freeswitch-1.6/ jessie main" sudo tee /etc/apt/sources.list.d/freeswitch.list sudo apt-get update 2. Install dependencies Install all the dependencies needed by freeswitch. sudo apt-get install -y libyuv-dev libvpx2-dev liblua5.2-dev libvpx2-dev libvpx2 zlib1g-dev libspeex1 libopus-dev libsndfile-dev autoconf automake devscripts gawk g++ git-core 'libjpeg-dev libjpeg62turbo-dev' libncurses5-dev 'libtool-bin libtool' make python-dev gawk pkg-config libtiff5-dev libperl-dev libgdbm-dev libdb-dev gettext libssl-dev libcurl4-openssl-dev libpcre3-dev libspeex-dev libspeexdspdev libsqlite3-dev libedit-dev libldns-dev libpq-dev yasm 3. Download freeswitch Create the source folder of your choice and download freeswitch in this location mkdir /root/sources && mkdir /usr/local/switch && cd /root/sources git clone -b v1.6 https://freeswitch.org/stash/scm/fs/freeswitch.git
4. Compile/Install freeswitch To compile freeswitch, navigate to the freeswitch source directory. Now invoke bootstrap script followed by configure script. We will enable with-java option and the installation directory will be /usr/local/switch cd /root/sources/freeswitch./bootstrap.sh -j./configure --enable-core-pgsql-support -prefix="/usr/local/switch/" --with-java=/usr/lib/jvm/java-8oracle/include/ Once the configuration is complete, you will see the information about freeswitch configuration.
Now install freeswitch using following command. make && make install Once installation is complete, you will see the following screen. Lastly install few sound files. These will be installed in /usr/local/switch/share/freeswitch/sounds/ make cd-sounds-install cd-moh-install Freeswitch is now installed in /usr/local/switch. Start freeswitch with following command. cd /usr/local/switch/bin./freeswitch Once freeswitch has started, you will get a confirmation message.
Edit PATH information in /etc/profile to include path of Freeswitch binaries. nano /etc/profile Now add the following line export PATH=$PATH:/usr/local/switch/bin Reload updated profile source /etc/profile 5. Freeswitch startup script Add freeswitch user to your system, and change the required permissions for the directory. adduser --disabled-password --quiet --system --home /usr/local/switch --gecos "FreeSWITCH Voice Platform" --ingroup daemon freeswitch chown -R freeswitch:daemon /usr/local/switch/ chmod -R o-rwx /usr/local/switch/ Create the file /etc/init.d/freeswitch with the following code written by Matthew Williams but before that create the location for PID file and grant permission for freeswitch. mkdir /usr/local/switch/run chown -R freeswitch:daemon /usr/local/switch/run nano /etc/init.d/freeswitch Using your favorite editor add the following in /etc/init.d/freeswitch and save the file.!/bin/bash BEGIN INIT INFO Provides: Required-Start: Required-Stop: Default-Start: Default-Stop: Description: Author: END INIT INFO Do NOT "set -e" freeswitch $local_fs $remote_fs $local_fs $remote_fs 2 3 4 5 0 1 6 Freeswitch debian init script. Matthew Williams
PATH should only include /usr/* if it runs after the mountnfs.sh script PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin DESC="Freeswitch" NAME=freeswitch DAEMON=/usr/local/switch/bin/$NAME DAEMON_ARGS="-nc" PIDFILE=/usr/local/switch/var/run/freeswitch/$NAME.pid SCRIPTNAME=/etc/init.d/$NAME FS_USER=freeswitch FS_GROUP=daemon Exit if the package is not installed [ -x "$DAEMON" ] exit 0 Read configuration variable file if it is present [ -r /etc/default/$name ] &&. /etc/default/$name Load the VERBOSE setting and other rcs variables. /lib/init/vars.sh Define LSB log_* functions. Depend on lsb-base (>= 3.0-6) to ensure that this file is present.. /lib/lsb/init-functions Function that sets ulimit values for the daemon do_setlimits() { ulimit -c unlimited ulimit -d unlimited ulimit -f unlimited ulimit -i unlimited ulimit -n 999999 ulimit -q unlimited ulimit -u unlimited ulimit -v unlimited ulimit -x unlimited ulimit -s 240 ulimit -l unlimited return 0 }
Function that starts the daemon/service do_start() { Set user to run as if [ $FS_USER ] ; then DAEMON_ARGS="`echo $DAEMON_ARGS` -u $FS_USER" fi Set group to run as if [ $FS_GROUP ] ; then DAEMON_ARGS="`echo $DAEMON_ARGS` -g $FS_GROUP" fi Return 0 if daemon has been started 1 if daemon was already running 2 if daemon could not be started start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null -- \ return 1 do_setlimits start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --background -- \ return 2 Add code here, if necessary, that waits for the process to be ready to handle requests from services started subsequently which depend on this one. As a last resort, sleep for some time. } Function that stops the daemon/service do_stop() { Return 0 if daemon has been stopped 1 if daemon was already stopped 2 if daemon could not be stopped other if a failure occurred start-stop-daemon --stop --quiet --retry=term/30/kill/5 -pidfile $PIDFILE --name $NAME
RETVAL="$?" [ "$RETVAL" = 2 ] && return 2 Wait for children to finish too if this is a daemon that forks and if the daemon is only ever run from this initscript. If the above conditions are not satisfied then add some other code that waits for the process to drop all resources that could be needed by services started subsequently. A last resort is to sleep for some time. start-stop-daemon --stop --quiet --oknodo --retry=0/30/kill/5 --exec $DAEMON [ "$?" = 2 ] && return 2 Many daemons don't delete their pidfiles when they exit. rm -f $PIDFILE return "$RETVAL" } Function that sends a SIGHUP to the daemon/service do_reload() { If the daemon can reload its configuration without restarting (for example, when it is sent a SIGHUP), then implement that here. start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME return 0 } case "$1" in start) [ "$VERBOSE"!= no ] && log_daemon_msg "Starting $DESC" "$NAME" do_start case "$?" in 0 1) [ "$VERBOSE"!= no ] && log_end_msg 0 ;; 2) [ "$VERBOSE"!= no ] && log_end_msg 1 ;; esac ;;
stop) [ "$VERBOSE"!= no ] && log_daemon_msg "Stopping $DESC" "$NAME" do_stop case "$?" in 0 1) [ "$VERBOSE"!= no ] && log_end_msg 0 ;; 2) [ "$VERBOSE"!= no ] && log_end_msg 1 ;; esac ;; status) status_of_proc -p $PIDFILE $DAEMON $NAME && exit 0 exit $? ;; reload force-reload) If do_reload() is not implemented then leave this commented out and leave 'force-reload' as an alias for 'restart'. log_daemon_msg "Reloading $DESC" "$NAME" do_reload log_end_msg $? ;; restart force-reload) If the "reload" option is implemented then remove the 'force-reload' alias log_daemon_msg "Restarting $DESC" "$NAME" do_stop case "$?" in 0 1) do_start case "$?" in 0) log_end_msg 0 ;; 1) log_end_msg 1 ;; Old process is still running *) log_end_msg 1 ;; Failed to start esac ;; *) Failed to stop log_end_msg 1 ;; esac
;; *) echo "Usage: $SCRIPTNAME {start stop restart reload forcereload}" >&2 echo "Usage: $SCRIPTNAME {start stop restart force-reload}" >&2 exit 3 ;; esac exit 0 Make the script executable and make it auto start on system boot: chmod +x /etc/init.d/freeswitch update-rc.d freeswitch defaults Freeswitch is now installed in your system. 6. Add Freeswitch users To add a freeswitch user, navigate to /usr/local/switch/etc/freeswitch/directory/default directory and create a file by the name 1000.xml and add the following. cd /etc/freeswitch/directory/default vi 1000.xml <include> <user id= 1000 > <params> <param name= password value= default.123 /> <param name= vm-password value= 1000 /> </params> <variables> <variable name= toll_allow value= domestic,international,local /> <variable name= accountcode value= 1000 /> <variable name= user_context value= default /> <variable name= effective_caller_id_name value= Extension 1000 /> <variable name= effective_caller_id_number value= 1000 /> <variable name= outbound_caller_id_name value= $${outbound_caller_name} /> <variable name= outbound_caller_id_number
value= $${outbound_caller_id} /> <variable name= callgroup value= techsupport /> </variables> </user> </include> Change the ownership. chown freeswitch:daemon 1000.xml Similarly, create another user in 1001.xml. Replace all occurrences of 1000 with 1001 in the above file and change the password for user 1001. <include> <user id= 1001 > <params> <param name= password value= edmund1001 /> <param name= vm-password value= 1001 /> </params> <variables> <variable name= toll_allow value= domestic,international,local /> <variable name= accountcode value= 1001 /> <variable name= user_context value= default /> <variable name= effective_caller_id_name value= Extension 1001 /> <variable name= effective_caller_id_number value= 1001 /> <variable name= outbound_caller_id_name value= $${outbound_caller_name} /> <variable name= outbound_caller_id_number value= $${outbound_caller_id} />
<variable name= callgroup value= techsupport /> </variables> </user> </include> Change the ownership. chown freeswitch:daemon 1001.xml Now open the file /usr/local/switch/etc/freeswitch/dialplan/default.xml using any editor and modify the destination_number and application= bridge part under extension section Local Extension around line 266. If you have already configured the domain name then you don t have to add IP address part in bridge parameter. Just Keep it like below. <action application= bridge data= user/${dialed_extension}@${your_domain_name} /> Since we have a domain name, our action tags bridge s data will be user/${dialed_extension}@demohost.hostingwikipedia.com...... <extension name= Local_Extension > <condition field= destination_number expression= ^(1[0-9]{3})$ >...... <action application= bridge data= user/${dialed_extension}@demohost.hostingwikipedia.com />
<action application= answer /> <action application= sleep data= 1000 />...... Reload new configuration for freeswitch. freeswitch@your-host> reloadxml 7. Install Zoiper VOIP client We have created two freeswitch users in the last step. Download and install zoiper in two separate client system from https://www.zoiper.com/en/voip-softphone/download/zoiper3. Extract the downloaded zoiper directory and run the installer according to your client s architecture../zoiper_3.3_linux_free_32bit.run OR./Zoiper_3.3_Linux_Free_64Bit.run
Click Forward Accept the license. Select Components
Choose installation directory
Click Forward Click Finish
Choose Yes or No 8. Configure Zoiper Run the zoiper and click settings-> Audio wizard and configure speaker and microphone.
Once you have finished testing microphone and speakers, click settings ->create a new account. Choose SIP and click next.
Enter freeswitch user/password that we have created earlier along with domain. If you have already configured the domain then you don t have to put IP address.
Click Next
Give a name of the account. Click Next, your account will be added to the list.
If you now click Settings -> Preferences and then General and advance tab, it will look like below.
Repeat the same process for user 1001 in another system. Now as a user 1000 dial the user 1001 or vice-versa, you will get a screen like below stating its status as ringing. Once the user 1001 accept your call, you will get connected with the user 1001. Now you have a basic PBX which allows the SIP users to register and place and receive VOIP calls.