FreeSwitch voip.ms Config


Here is a very basic, step by step FreeSwitch configuration for voip.ms. It is for one inbound DID. This inbound DID is processed by a sofia external profile. In the samples below, replace “[text]” with your values and delete the square brackets [].

  1. Assumptions. You have a FreeSwitch server on your LAN inside your firewall. You are running FreeSwitch version 1.2.14 on CentOS 6.4. You have configured FreeSwitch and it is working correctly.
  2. Configure your firewall. Configure your firewall to allow incoming SIP and RTP traffic from the IP address of your voip.ms “DID POP”. SIP is TCP/UDP port 5060. For RTP voip.ms uses UDP ports 10001:20000. Make sure that the RTP start and end ports in autoload_configs/switch.conf.xml match these values.
  3. Configure NAT. You need to forward the SIP and RTP traffic via NAT to your FreeSwitch server IP. For SIP traffic you will also need to change the destination port from TCP/UDP 5060 to TCP/UDP 5080. FreeSwitch listens for external connections on port 5080.
  4. Add a voip.ms profile. Put the following XML in a file called voipms.xml in the /usr/local/freeswitch/conf/sip_profiles/external directory. Edit for your values.

    <include>
      <gateway name="voipms">
        <param name="username" value="[your voip.ms account number]" />
        <param name="password" value="[your voip.ms password]" />
        <param name="proxy" value="[closest POP].voip.ms" />
        <param name="realm" value="voip.ms" />
        <param name="from-domain" value="voip.ms" />
        <param name="register" value="true" />
        <param name="sip_cid_type" value="rpd" />
      </gateway>
     </include>
  5. Add an inbound (external) dialplan. Put the following in a file called 01_voipms_inbound.xml under the /usr/local/freeswitch/conf/dialplan/public directory. You need to customize it by giving it a name, adding your 10 digit DID, and adding an extension to handle it.

    <include>
      <extension name="[name such as home_did]">
        <condition field="destination_number" expression="^([your 10 digit DID])$">
          <action application="set" data="domain_name=$${domain}"/>
          <action application="transfer" data="[the extension name this will match] XML default"/>
        </condition>
      </extension>
    </include>
  6. Add an outbound (internal) dialplan. Put the following in a file called 01_voipms_outbound.xml under the /usr/local/freeswitch/conf/dialplan/default directory. You need to customize it by adding you local area code in line 9.

    <include>
    
      <extension name="emergency.voipms">
        <condition field="${toll_allow}" expression="local"/>
        <condition field="destination_number" expression="^911$">
          <action application="set" data="hangup_after_bridge=true"/>
          <action application="set" data="effective_caller_id_number=[your 10 digit DID]"/>
          <action application="bridge" data="sofia/gateway/voipms/911"/>
        </condition>
      </extension>
    
      <extension name="information.voipms">
        <condition field="${toll_allow}" expression="local"/>
        <condition field="destination_number" expression="^411$">
          <action application="set" data="hangup_after_bridge=true"/>
          <action application="set" data="effective_caller_id_number=${outbound_caller_id_number}"/>
          <action application="set" data="effective_caller_id_name=${outbound_caller_id_name}"/>
          <action application="bridge" data="sofia/gateway/voipms/411"/>
        </condition>
      </extension>
    
      <extension name="local.voipms">
        <condition field="${toll_allow}" expression="local"/>
        <condition field="destination_number" expression="^(\d{7})$">
          <action application="set" data="hangup_after_bridge=true"/>
          <action application="set" data="effective_caller_id_number=${outbound_caller_id_number}"/>
          <action application="set" data="effective_caller_id_name=${outbound_caller_id_name}"/>
          <action application="bridge" data="sofia/gateway/voipms/1[your area code]$1"/>
        </condition>
      </extension>
    
      <extension name="domestic.voipms">
        <condition field="${toll_allow}" expression="domestic"/>
        <condition field="destination_number" expression="^(1?\d{10})$">
          <action application="set" data="effective_caller_id_number=${outbound_caller_id_number}"/>
          <action application="set" data="effective_caller_id_name=${outbound_caller_id_name}"/>
          <action application="bridge" data="sofia/gateway/voipms/$1"/>
        </condition>
      </extension>
    
        <extension name="international.voipms">
        <condition field="${toll_allow}" expression="international"/>
        <condition field="destination_number" expression="^(011\d+)$">
          <action application="set" data="effective_caller_id_number=${outbound_caller_id_number}"/>
          <action application="set" data="effective_caller_id_name=${outbound_caller_id_name}"/>
          <action application="bridge" data="sofia/gateway/voipms/$1"/>
        </condition>
      </extension>
    
    </include>
  7. Restart FreeSwitch. Run a recursive chown to make sure that the freeswitch user owns these new files. I have found FreeSwitch to be tricky when it comes to reloading configurations. Usually a reloadxml in the CLI will work but sometimes you also have to do a sofia rescan. I recommend you restart FreeSwitch after making these changes.
  8. Test Configuration. Once FreeSwitch has restarted (this takes a few minutes) launch fs_cli and check the SIP connections status with sofia status. If all went well you should see something like this: external::voipms gateway sip:[acct #]@[pop].voip.ms REGED

The external line should show your external IP address. If there is a problem the two most common things to check are: 1) NAT is configured properly and 2) sofia has re-read the config files. reloadxml does not cause sofia to do this.

I highly recommend you get a static IP address from your ISP if you can. It is worth it if you are going to host servers like this. I hope this brief tutorial helps you.

As an aside, manual changes like this are not the Right Way to do this. This should be a Chef or Ansible script rather than a set of manual file changes. Once I complete my DevOps experiment I will do just that for FreeSwitch.



Categories: VOIP

Tags: ,

Share Your Ideas

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: