Wednesday, May 23, 2012

FreeSWITCH Installation on Citrix XenServer

This is one of the easiest posts I've ever made. I'll show how to install FreeSWITCH which is only 5~7 lines of work but first we need to declare and install the prerequisite OS, UBUNTU 1.04 Server and even before that need to create a new Virtual Machine on my XENSERVER using XENCLIENT.

ADDING NEW VM USING XENCENTER ON XENSERVER

Simple Click on "NEW VM"
Next Step will give lots of predefined templates which come with xenserver and include multiple OSs like windows and linux servers. But I wanted to install an Operating System of my own choice and my own settings so I selected Other Install Media from the templates.
Using Other Install Media as Template
Once we continue from the last step we'll be given option to Install OS from an ISO library or Physical DVD drive of the xen-server. Since we can't have access to physical server's DVD ROM all the time so using an ISO library is the best idea. I had already created an "New ISO Library" which pointed to a CIFS directory ( Uses Windows network shared folder in simple words)

I've Ubuntu Server 11.04 server ISO placed in my windows shared folder

Select which XENSERVER to create this Virtual Machine
 Using XENCENTER we can have multiple xenservers under our control so we may select which xenserver to create this new VM on. Since I've only one experimental xenserver, so I selected that one.
Assign CPUs and Memory to VM
 Easy step, just tell XENSERVER how much memory and how manay CPUs to assign to this new VM.
Create a Disk Storage [HDD} for VM
 Another standard step of assigning HDD capacity to this VM on xenserver.

Select Capacity and Storage Space for VM-HDD
 The important point and good to note here is that XENSERVER/XENCENTER gives us the capability to not only use the internal Harddisk of thexen-server but instead we can use Network Storage systems as well like NAS or SAN or FC(Fiber Channel)
Selecting xenserver's storage as storage space of new VM
Next steps are easier as well, just create a new NIC for our virtual machine and assign it to default network-0 or any other network created  on the xenserver. This means that we can define multiple switches and create separate networks within the xen-server. Managing traffic is easier if we use Virtual Routers like vyatta. See my previous post on how I control internet traffic between VMs using vyatta.


 Finally everything is setup just press the finish button and ta-da, another server is ready and now time to install Operating System on this new server.



INSTALL UBUNTU ON NEW Vitual Machine

Follow this post by one of my senior senior friend on step-by-step Ubuntu Server installation guide to install OS on the newly created Virtual Machine.

SETTING UP SSH ACCESS TO NEW VM

Since I assigned this new Virtual machine a private network with Private IP: 192.168.30.4. According to my virtual router's configurations in this post This IP can access internet but I definitely need to add another Destination NAT rule in my router to gain SSH access from outside world to this server.

Now when I SSH on 172.16.31.101 port 22304 it gets translated to internal address 192.168.30.4 port 22.

GW-Vyatta#set nat destination rule 10 inbound-interface eth0
GW-Vyatta#set nat destination rule 10 destination port 22304
GW-Vyatta#set nat destination rule 10 translation address 192.168.30.4
GW-Vyatta#set nat destination rule 10 translation port 22
GW-Vyatta#set nat destination rule 10 protocol tcp
GW-Vyatta#commit


This is How it looks like now


INSTALLING FREESWITCH on UBUNTU SERVER

Now the final phase of this post, installing our favorite VoIP Server FreeSWITCH. SSH into the FS server and on console execute these commands.

Download pre-requisite libraries and packages for FreeSWITCH.

FS-Server:#apt-get update
FS-Server:#apt-get install gcc bison flex make openssl libmysqlclient15-dev libradiusclient-ng-dev mysql-server libxmlrpc-c3-dev subversion subversion-tools automake1.9 gcc-4.1 autoconf make wget libtool g++ debhelper automake1.9 autoconf libtool unixodbc-dev libasound2-dev libssl-dev libogg-dev libvorbis-dev libperl-dev libgdbm-dev libdb-dev libgnutls-dev libspandsp-dev libtiff4-dev libncurses5 libncurses5-dev screen bridge-utils libmysql++-dev libconfuse-dev libpcre3-dev curl libxml2-dev libmemcache-dev build-essential git-core
Download freeswitch source code. This takes a long time downloading almost 80~100 MB of data on slower network.
FS-Server:#cd /usr/local/src
FS-Server:#git clone git://git.freeswitch.org/freeswitch.git
Build configurations file required for compiling FreeSWITCH.
FS-Server:#cd freeswitch
FS-Server:#./bootstrap.sh
./configure sets compilation options
FS-Server:#./configure

At this point you can edit the file "modules.conf" to include any modules you like to be installed with your freeswitch setup.
Now execute make and make install commands to compile and create binary files.


FS-Server:#make && make install
Now Sit back and do something usefull (:P), hopefully if no errors are encountered then it'll take approximately 7~15 minutes.
Once it completes you can follow the printed instructions to install any additional sound files if you like.

At the end just put symoblic Links:

FS-Server:#ln -s /usr/local/src/freeswitch/bin/freeswitch /usr/sbin/
FS-Server:#ln -s /usr/local/src/freeswitch/bin/fs_cli /usr/sbin/
Now, Start FreeSWITCH server for the first time.
FS-Server:#cd /
FS-Server:#freeswitch -nc
FS-Server:#fs_cli -r
Thats it You're now connected to FreeSWITCH console. 

Next thing I'm going to do is setup my virtual topology such that SIP Users registering on OpenSIPS can make calls to FreeSWITCH and they get a two-way audio. I'll be using Media-Proxy (hopefully) and echo application in FreeSWITCH to test this. Till then bye-bye.

3 comments:

  1. Hi,
    im getting error


    E: Package 'gcc-4.1' has no installation candidate

    when installing packages . please suggest

    ReplyDelete
  2. Hi,

    You can search for the installation package name for your OS by using this command

    #apt-cache search gcc

    Then select the version you want to install.

    Try removing the gcc-4.1 from the apt-get command Or use the newer gcc-x.x version you find from the the apt-cache search.

    ReplyDelete
  3. ok thanks for the quick reply. i used gcc-4.7 and the apt get command becomes.

    apt-get install gcc bison flex make openssl libmysqlclient15-dev libradiusclient-ng-dev mysql-server libxmlrpc-c3-dev subversion subversion-tools automake1.9 gcc-4.7 autoconf make wget libtool g++ debhelper automake1.9 autoconf libtool unixodbc-dev libasound2-dev libssl-dev libogg-dev libvorbis-dev libperl-dev libgdbm-dev libdb-dev libgnutls-dev libspandsp-dev libtiff4-dev libncurses5 libncurses5-dev screen bridge-utils libmysql++-dev libconfuse-dev libpcre3-dev curl libxml2-dev libmemcache-dev build-essential git-core

    ReplyDelete