Installation

This guide details setting up FreeSWITCH on CentOS 7 and configuring basic dialplans.

Update: Since 2022 the FreeSWITCH package repositories require a free SignalWire Personal Access Token, so the repo install below no longer works as written. See the FreeSWITCH installation docs for the current steps; the dialplan sections still apply.

  1. Install FreeSWITCH.

console yum install -y https://files.freeswitch.org/repo/yum/centos-release/freeswitch-release-repo-0-1.noarch.rpm epel-release yum install -y freeswitch-config-vanilla freeswitch-lang-en freeswitch-sounds-en-us* systemctl enable freeswitch

  1. Set capabilities to bind to privileged ports.

console setcap 'cap_net_bind_service,cap_sys_nice=+ep' /usr/bin/freeswitch

  1. Remove IPv6 entries from /etc/hosts if not using IPv6.

  2. Edit /etc/freeswitch/autoload_configs/event_socket.conf.xml and set the listen address:

xml <param name="listen-ip" value="127.0.0.1"/>

  1. Configure variables in /etc/freeswitch/vars.xml:

xml <X-PRE-PROCESS cmd="set" data="domain=your.domain.com"/> <X-PRE-PROCESS cmd="set" data="internal_sip_port=5060"/> <X-PRE-PROCESS cmd="set" data="external_sip_port=5080"/>

  1. Set ACL in /etc/freeswitch/autoload_configs/acl.conf.xml:

xml <list name="domains" default="deny"> <node type="allow" cidr="192.168.1.0/24"/> </list>

  1. Start FreeSWITCH.

console systemctl start freeswitch

Basic Dialplan Configuration

Dialplans are located in /etc/freeswitch/dialplan/default.xml or individual XML files in /etc/freeswitch/dialplan/default/.

Example 1: Echo Test

Create /etc/freeswitch/dialplan/default/01_echo.xml:

1
2
3
4
5
6
7
8
<include>
  <extension name="echo">
    <condition field="destination_number" expression="^9196$">
      <action application="answer"/>
      <action application="echo"/>
    </condition>
  </extension>
</include>

Dial 9196 to test audio loopback.

Example 2: Simple IVR Menu

Create /etc/freeswitch/dialplan/default/02_ivr.xml:

1
2
3
4
5
6
7
8
9
<include>
  <extension name="main_ivr">
    <condition field="destination_number" expression="^5000$">
      <action application="answer"/>
      <action application="sleep" data="1000"/>
      <action application="ivr" data="main_menu"/>
    </condition>
  </extension>
</include>

Define the IVR menu in /etc/freeswitch/autoload_configs/ivr.conf.xml:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
<menu name="main_menu"
      greet-long="ivr/ivr-welcome.wav"
      greet-short="ivr/ivr-choose_option.wav"
      invalid-sound="ivr/ivr-that_was_an_invalid_entry.wav"
      exit-sound="voicemail/vm-goodbye.wav"
      timeout="10000"
      max-failures="3">
  <entry action="menu-exec-app" digits="1" param="transfer 1001 XML default"/>
  <entry action="menu-exec-app" digits="2" param="transfer 1002 XML default"/>
  <entry action="menu-top" digits="9"/>
</menu>

Example 3: Call Forwarding

Create /etc/freeswitch/dialplan/default/03_forward.xml:

1
2
3
4
5
6
7
8
<include>
  <extension name="forward_to_external">
    <condition field="destination_number" expression="^(\d{10})$">
      <action application="set" data="effective_caller_id_number=5551234567"/>
      <action application="bridge" data="sofia/gateway/your_gateway/$1"/>
    </condition>
  </extension>
</include>

Example 4: Time-Based Routing

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
<include>
  <extension name="main_number">
    <condition field="destination_number" expression="^1000$"/>
    <condition wday="2-6" hour="9-16">
      <action application="answer"/>
      <action application="playback" data="ivr/ivr-welcome_to_freeswitch.wav"/>
      <action application="transfer" data="5000"/>
      <anti-action application="answer"/>
      <anti-action application="playback" data="ivr/ivr-closed.wav"/>
      <anti-action application="hangup"/>
    </condition>
  </extension>
</include>

Calls to 1000 Monday–Friday (wday 2–6, where 1 is Sunday) between 9:00 and 16:59 go to the IVR. If the time condition fails, the anti-actions run instead and the caller hears the closed message.

Reload Dialplan

After making changes, reload the dialplan without restarting FreeSWITCH:

1
fs_cli -x "reloadxml"

Testing

Connect to FreeSWITCH CLI:

1
fs_cli

Monitor calls:

sofia status
show channels

Enable dialplan debugging:

console loglevel debug