Você está na página 1de 7

From a few month ago, my company decided to start VOIP service using open-sourced VOIP softswitch/IP PBX.

I had a bit of experice on Asterisk (http://www.asterisk.org) from my previous work (calling card company) but I had lots of outages and wasn't so reliable at the time I used Asterisk (But I'm very sure these issues been resolved - Also customised codes must made these outages & it was years ago I was implement Asterisk). While I was searching alternative options for Open-Sources Softswitch/IP PBX, I came across with FreeSWITCH. Although Asterisk is the most popular open-sourced IP PBX system, we were looking for something 'Carrier Grade' type of product, some of FreeSWITCH users were telling its performing about 8 to 10 time more capacity compare to Asterisk. So we've planned to start with FreeSWITCH and for a few weeks I was searching on the web for the configuration and looked around any proper tutorials step by step - But unfortunately could not find any websites / tutorials that tells step by steps for newbies - That's the main reason I'm starting FreeSWITCH tutorials. Please remind that these tutorials might not be 100% correct, so please DO NOT ARGUE even if I'm wrong. But please tell me anything is not correct. -----------------------------------------------------------------------------------FreeSWITCH Tutorial 1 - Installation ** Please note I'm using Ubuntu distributions for all of the tutorials. 1. Download FreeSWITCH You can download FreeSWITCH source codes from: http://files.freeswitch.org/ If you installed non-x-desktop distribution, you can alternative download files using :: wgethttp://files.freeswitch.org/FILENAME command line. 2. Copy file to /usr/src directory Run cp FILENAME /usr/src from command line. 3. Uncompress source code - tar.gz files in my case Goto /usr/src using cd /usr/src command and run tar -xzf FILENAME - It will generate freeswitchVERSION folder (1.0.3 in my case). 4. Install prerequisites Run apt-get install build-essential subversion subversion-tools automake1.9 gcc-4.1 autoconf make wget libtool g++ libncurses5 libncurses5-dev for all-in-one installation or prerequisites for FreeSWITCH. 5. Configure source code Goto /usr/src/freeswitch-1.0.3 directory and run ./configure. It will configure make files according to your linux specs. 6. Make binaries Run make command to make bianaries 7. Install FreeSWITCH If you did not have any problem with make binaries, now its time to install your FreeSWITCH.

Run make install command and it will install your FreeSWITCH under /usr/local/freeswitch directory. 8. Install sound files Run make sounds-install moh-install to install FreeSWITCH's default sound files and music-on-hold (moh) files. 9. Run FreeSWITCH for the very first time Goto /usr/local/freeswitch/bin and run ./freeswitch command. It will run a command-line version of freeswitch! You're now ready to enter FreeSWITCH's world! -----------------------------------------------------------------------------------In this tutorial assumes you've installed FreeSWITCH on your computer/server. -----------------------------------------------------------------------Now, its time to set your internal profiles (extensions) for your FreeSWITCH. FreeSWITCH calls extension/login accounts as Directories, these configurations can be found under/ $PREFIX/conf/directory There are several configuration files under /$PREFIX/conf/directory directory. Now we open 1000.xml file to set a extension: - Open 1000.xml under directories directory - Your 1000.xml file should look something like:
Code:

<include> <user id="1000" mailbox="1000"> <params> <param name="password" value="1234"/> <param name="vm-password" value="1000"/> </params> <variables> <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"/> </variables> </user> </include> - For <user id="1000" mailbox="1000"> defines your user name (extension number) - For <param name="password" value="1234"/> defines your password. - For <variable name="effective_caller_id_name" value="Extension 1000"/> defines your caller name. - For <variable name="effective_caller_id_number" value="1000"/> defines your caller id number. - Here, change your password for extension 1000, and save your file. - Restart your FreeSWITCH - If you completed above steps, now its time to download a softphone onto another computer. This is due to you cannot run softphone and IP PBX/softswitch on the same machine. I would recommend xlite client fromhttp://www.counterpath.com - Free but it does all of the functions

- Connect your client to internal IP address of your FreeSWITCH (Use port 5060 if you have specify port number), place your username & password. - If you get connected (authenticated), you are now connected to FreeSWITCH. - Repeat the process for 1001.xml file, and get another machine to make internal calls between the internal extensions! ------------------------------------------------------------------------------In FreeSWITCH Tutorial 2, you've learnt how set internal extensions. Now you'll need to get a SIP number from SIP Providers. SIP providers enables you to send and receive calls to PSTN numbers (normal landline & mobile nubers). A SIP provider will provide a number to get receive calls over the Internet. After you get a SIP number, SIP provider will give you Login ID & Password to connect with. You can configure these SIP numbers in [FreeSWITH Path]/conf/sip_profiles/external/ directory. There is a example.xml file to show you example options. SIP profiles are slightly different along each SIP providers, but here is very basic sample (Save as NameofSIPTrunk.xml):
Code:

<include> <gateway name="[Name of SIP Trunk]"> <param name="username" value="[SIP Trunk Username]"/> <param name="password" value="[SIP Trunk Password]"/> <param name="realm" value="[SIP Provider Domain]"/> <param name="proxy" value="[SIP Provider Domain]"/> <param name="register" value="true"/> </gateway> </include>

SIP Trunk Username is usually your inbound number provided from your SIP provider but could be different. In this tutorial I'll assume its same as your SIP number. Please refer to http://wiki.freeswitch.org/wiki/SIP_Provider_Examples for your SIP provider configurations. You can reload these Profiles by restarting your FreeSWITCH or type "reloadxml" then "reload mod_sofia" from your FreeSWITCH console. Now its time to check your connection status by typing sofia status from your FreeSWITCH console. If you're successfully connected, you'll see [Name of SIP Trunk] REGED, if not, it will show you NOREG for your status.

After successufully connected to a SIP provider, now its time to create a dialplan under [FreeSWITCH Path]/conf/dialplan/public directory to set an inbound rule. Lets create a simple dialplan XML file which will forward all of your calls to extension 1000 (Save as [SIP Username].xml):
Code:

<extension name="Inbound-[SIP Username]"> <condition field='destination_number' expression='[SIP Number]'> <action application="transfer" data="1000 XML default"/> </condition> </extension>

The above XML file will tell FreeSWITCH to forward all inbound calls to extension 1000. -----------------------------------------------------------------------------------1. FreeSWITCH Configuration

Most of you may required to setup public IP address to send and receive calls over public network (Internet). Its always good to use STUN (Simple Traversal of UDP through NATs - http://www.voipinfo.org/wiki/view/STUN), which configured by default to use stun.freeswitch.org. But some of you may want to set public IP address if they have fixed IP address for their own. To setup public IP address for FreeSWITCH, follow the steps below: 1. Open /usr/local/freeswitch/vars.xml 2. Change <param name="manage-presence" value="false"/> to <param name="manage-presence" value="true"/> 3. Uncomment out <!--<param name="aggressive-nat-detection" value="true"/>-> (remove <!-- and -->) 4. Change <X-PRE-PROCESS cmd="set" data="external_rtp_ip=stun:stun.freeswitch.org"/> to <X-PRE-PROCESS cmd="set" data="external_rtp_ip=[YOUR PUBLIC IP ADDRESS]"/> 5. Change <X-PRE-PROCESS cmd="set" data="external_sip_ip=stun:stun.freeswitch.org"/> to <X-PRE-PROCESS cmd="set" data="external_sip_ip=[YOUR PUBLIC IP ADDRESS]"/> 6. Open /usr/local/freeswitch/sip_profiles/external.xml 7. Change <param name="ext-rtp-ip" value="auto-nat"/> to <param name="extrtp-ip" value="$${external_rtp_ip}"/> 8. Change <param name="ext-sip-ip" value="auto-nat"/> to <param name="extsip-ip" value="$${external_sip_id}"/> 9. Restart FreeSWITCH or type "reload mod_sofia" from your FreeSWITCH console.

2. Port forwarding If you want to set external rtp ip & external sip ip, you might have to setup port forwarding from your router to FreeSWITCH.

You will probably need to forward the specified ports:

Port 5060 UDP & TCP - SIP UAS Used for SIP signalling (Standard SIP Port, for default Internal Profile) Port 5080 UDP & TCP - SIP UAS Used for SIP signalling (For default "External" Profile) Port 16384-32768 UDP - RTP/ RTCP multimedia streaming Used for audio/video data in SIP and other protocols -----------------------------------------------------------------------------------fs_cli is is a program which allows users to connect to a running FreeSWITCH instance at background (running as a service), this is because once you run FreeSWITCH at background, you won't able to see / monitor what is going on your FreeSWITCH unless looking at logs. fs_cli uses FreeSWITCH's socket module, so you will have make sure event_socket module is up & running. These are the steps of checking you're running event_socket module with your FreeSWITCH: 1. Goto /usr/local/freeswitch/conf/autoload_configs 2. Open modules.conf.xml 3. Make sure <load module="mod_event_socket"/> is not commented out & close document. 4. Open event_socket.conf.xml 5. Change listen-port and/or password section if required then save & close document. Restart FreeSWITCH if you changed any of configuration. Now, its time to run fs_cli: 1. Goto /usr/local/freeswitch/bin directory 2. Run ./fs_cli -H 127.0.0.1 -P 8021 -p ClueCon, where -H is host/server, -P is port number and -p is the password 3. if you see freeswitch@127.0.0.1@internal>, you're now using fs_cli. 4. Type /quit if you want to terminate/exit program Some useful command line commands: show calls - display number of calls sofia status profile internal - display number of devices/softphone connected to local sofia status profile external - display external connection to public

reload mod_sofia - reload mod_sofia (SIP agent) help - display available commands -----------------------------------------------------------------------------------In FreeSWITCH Tutorial 2, you've learnt how set internal extensions, its time to learn how to handle inbound calls. In order to setup inbound dialplan XML files, firstly you'll need to set SIP Trunks to your SIP provider. If you successfully registered to your SIP provider, its time to setup dialplans for inbound calls. Firstly, lets start with very basic inbound dialplan, bridge call to extension 1000 when a call comes in. Goto [FreeSWITH Path]/conf/dialplan/public and create a new XML file (Default_Inbound.xml in my case).
Code:

<extension name="Default_Inbound"> <condition field='destination_number' expression='[SIP Number]'> <action application="bridge" data="sofia/internal/1000%${local_ip_v4}"/> </condition> </extension> The above dialplan will bridge any inbound calls to extension 1000. Secondly, lets try stepping extensions, try extension 1000, 1001 then 1002 when a call comes in. Goto [FreeSWITH Path]/conf/dialplan/public and create a new XML file (Default_Stepping.xml in my case).
Code:

<extension name="Default_Stepping"> <condition field='destination_number' expression='[SIP Number]'> <action application="set" data="call_timeout=20"/> <action application="set" data="continue_on_fail=true"/> <action application="set" data="hangup_after_bridge=true"/> <action application="bridge" data="sofia/internal/1000%${local_ip_v4}"/> <action application="set" data="call_timeout=20"/> <action application="set" data="continue_on_fail=true"/> <action application="set" data="hangup_after_bridge=true"/> <action application="bridge" data="sofia/internal/1001%${local_ip_v4}"/> <action application="set" data="call_timeout=20"/> <action application="set" data="continue_on_fail=false"/> <action application="set" data="hangup_after_bridge=true"/> <action application="bridge" data="sofia/internal/1001%${local_ip_v4}"/> </condition> </extension> <action application="set" data="call_timeout=20"/> tells FreeSWITCH to try 20 seconds to ring,

<action application="set" data="continue_on_fail=true"/> tells FreeSWITCH to continue even if it cannot bridge to specified extension, <action application="set" data="hangup_after_bridge=true"/> tells FreeSWITCH to hangup the call after bridge so it cannot try next steps. Thirdly, lets try to ring multiple extensions, try all extension 1000, 1001 and 1002 when a call comes in.
Code:

<extension name="Default_Ring_All"> <condition field='destination_number' expression='[SIP Number]'> <action application="bridge" data="sofia/internal/1000%${local_ip_v4},sofia/internal/1001%$ {local_ip_v4},sofia/internal/1002%${local_ip_v4}"/> </condition> </extension> As you can see above, you're able to ring multiple extensions at a time by using commas between the extensions. Lastly, lets try to stepping to each extensions then ring all numbers.
Code:

<extension name="Default_Stepping_Then_Ring_All"> <condition field='destination_number' expression='[SIP Number]'> <action application="set" data="call_timeout=20"/> <action application="set" data="continue_on_fail=true"/> <action application="set" data="hangup_after_bridge=true"/> <action application="bridge" data="sofia/internal/1000%${local_ip_v4}"/> <action application="set" data="call_timeout=20"/> <action application="set" data="continue_on_fail=true"/> <action application="set" data="hangup_after_bridge=true"/> <action application="bridge" data="sofia/internal/1001%${local_ip_v4}"/> <action application="set" data="call_timeout=20"/> <action application="set" data="continue_on_fail=false"/> <action application="set" data="hangup_after_bridge=true"/> <action application="bridge" data="sofia/internal/1001%${local_ip_v4}"/> <action application="bridge" data="sofia/internal/1000%${local_ip_v4},sofia/internal/1001%$ {local_ip_v4},sofia/internal/1002%${local_ip_v4}"/> </condition> </extension>

Optionally you can forward it voicemail or call park after all of the steppers. ------------------------------------------------------------------------------------

Você também pode gostar