Connect to The Demo VM Using SSH

localhost:~$ ssh user@example.com 
            

Configure Flowroute as the Default Provider

Once connected, drop the root for the remainder of the commands, as shown in the following example:

user@example.com:~$ su -root@example.com:~#

            
  1. Using your preferred text editor, edit the FreeSWITCH config file /etc/freeswitch/vars.xml by changing the default values to the SIP credentials from your Flowroute account:
  2. <X-PRE-PROCESS cmd="set" data="default_provider=flowroute.com"/><X-PRE-PROCESS cmd="set" data="default_provider_username=[SIP_USERNAME]"/>
    <X-PRE-PROCESS cmd="set" data="default_provider_password=[SIP_PASSWORD]"/>
    <X-PRE-PROCESS cmd="set" data="default_provider_from_domain=sip.flowroute.com"/>
    <X-PRE-PROCESS cmd="set" data="default_provider_register=true"/>
    
                
  3. Save the changes.

Disable IPV6 Support

IPv6 support must be disabled in FreeSWITCH.

  • 1. Run the following to delete /etc/freeswitch/sip_profiles/external-ipv6.xml:
  • root@example.com:~# rm -f /etc/freeswitch/sip_profiles/external-ipv6.xml
                
  • Restart FreeSWITCH by running the following:
  • root@example.com:~# service freeswitch restart
                

    Check the registration status in FreeSWITCH CLI

    At this point the FreeSWITCH instance should be registered with the Flowroute servers.

    1. Run the following to connect to the FreeSWITCH CLI:
    2. fs_cli
                  
    3. Within fs_cli run the following:
    4. sofia status
                  

    This returns your account information and system IP addresses:

    freeswitch@internal> sofia status                     Name    Type                                       Data  State
    =================================================================================================
                  example.com   alias                                   internal  ALIASED
                     external profile          sip:mod_sofia@example.com:5080     RUNNING (0)
    external::sip.flowroute.com gateway       sip:[SIP_USERNAME]@sip.flowroute.com  REGED
                internal-ipv6 profile          sip:mod_sofia@example.com:5060     RUNNING (0)
                     internal profile          sip:mod_sofia@example.com:5060     RUNNING (0)
    =================================================================================================
    3 profiles 1 alias
    
    freeswitch@internal>
    
                

    If the sip.flowroute.com gateway line does not display in a REGED state, verify the credentials set in /etc/freeswitch/vars.xml.

    Copy and Edit the Call Anonymizing Script

    With FreeSWITCH now connected to the Flowroute servers, the anonymizer functionality can then be added.

    For the demo environment, a basic two-way call anonymizing script has been added.

    1. First, switch to the 'shareable' FreeSWITCH scripts directory:
    2. cd /usr/share/freeswitch/scripts
      				
    3. Open your preferred text editor and copy and paste the following code block:
    4. --[[
      Two-way call anonymizer - Basic example only remembers the last caller:
      Insert the below xml into your public dialplan to launch script
      --]]
      
      local gateway = "flowroute"
      local my_cell = "+12345551234"; -- Your cellphone number goes here.
      
      api = freeswitch.API();
      
      if session:ready() then
         local destination_number = session:getVariable("destination_number");
         local caller_id_number   = session:getVariable("caller_id_number");
      
         if caller_id_number == my_cell then
            target_number = api:executeString("db select /caller/" .. my_cell );
         else
            api:executeString("db insert /caller/" .. my_cell  .. "/" .. caller_id_number);
            target_number = api:executeString("db select /target/" .. destination_number );
            if target_number == '' then
         api:executeString("db insert /target/" .. destination_number  .. "/" .. my_cell);
         target_number = my_cell;
            end
         end
      
         session:execute("bridge", "{origination_caller_id_number=" .. destination_number .. "}sofia/gateway/" .. gateway .. "/" .. target_number);
      end
      
                  
    5. Assign your mobile number to the my_cell variable for masking with the anonymized service. Please note that +1 is necessary if you are using a US/NANP number.
    6. Save the file as pstn_nat.lua. Lua is the preferred scripting language for custom applications based on FreeSWITCH.

    Configure the FreeSWITCH Dialplan to Trigger the Script on Receiving a Call

    Each Flowroute demo account has already been assigned an inbound Direct Inward Dialing (DID). Configure the FreeSWITCH dialplan to trigger the call anonymizing script when an inbound call is received.

    1. Open /etc/freeswitch/dialplan/public.xml in a text editor, and add the following lines within the <context name="public"> XML block:
    2. /etc/freeswitch/dialplan/public.xml
      <extension name="pstn_nat_check">    
      <condition field="destination_number" expression="^(.*)$">
          <action application="lua" data="pstn_nat.lua"/>
          </condition>
      <extension>>
      
                  

      This triggers the pstn_nat.lua script on any incoming calls.

    3. Run fs_cli again to connect to FreeSWITCH CLI and run reloadxml.

    Test the Setup

    Log on to the Manage your DIDs page on Flowroute Manage to get your account's assigned phone number, and then call the number from any number other than your mobile phone. You should receive the call from the Flowroute phone number. Calling that number back from your mobile phone number automatically connects the call back to the original calling number, also showing the Flowroute number as the calling number. Boom. Call anonymized.