Difference between revisions of "Telephone system:FreeSWITCH tricks"

From Hackerspace ACKspace
Jump to: navigation, search
m (added SRV info)
(Elaborated a bit on the difference between '''sip_req_host''' and '''sip_to_host''')
Line 5: Line 5:
 
= config snippets =
 
= config snippets =
 
== dial by incoming domain ==
 
== dial by incoming domain ==
Typically, FreeSWITCH only looks at the destination number, so <code>1200@ackspace.nl</code> is treated the same as <code>1200@illegaleshow.nl</code>.
+
Typically, FreeSWITCH only looks at the destination number, so <code>1200@ackspace.nl</code> is treated the same as <code>1200@illegaleshow.nl</code> in the public dialplan.
  
 
This snippet routes all calls destined to either the '''illegaleshow.nl''' domain or the '''illegaleshow''' extension to ''1200'' in its own dialplan.
 
This snippet routes all calls destined to either the '''illegaleshow.nl''' domain or the '''illegaleshow''' extension to ''1200'' in its own dialplan.
  
Note that there aren't many ''sip_to_host'' examples on the net (or the alternative ''sip_req_host'' for that matter)
+
Note that there aren't many ''sip_to_host'' examples on the net (or the less predictable alternative ''sip_req_host'' for that matter, also see [https://stackoverflow.com/questions/58947495/what-is-the-difference-between-the-invite-field-and-the-to-field-in-a-sip-invite this stackoverflow thread]):
 +
* req or '''Request Uri''' is where the INVITE goes (he next hop address, a proxy if you will)
 +
* '''To Uri''' is the actual destination to call
 
<pre>
 
<pre>
 
   <extension name="Illegale show">
 
   <extension name="Illegale show">

Revision as of 21:30, 2 June 2021

This page provides a couple of tricks to ease working and debugging with FreeSWITCH

config snippets

dial by incoming domain

Typically, FreeSWITCH only looks at the destination number, so 1200@ackspace.nl is treated the same as 1200@illegaleshow.nl in the public dialplan.

This snippet routes all calls destined to either the illegaleshow.nl domain or the illegaleshow extension to 1200 in its own dialplan.

Note that there aren't many sip_to_host examples on the net (or the less predictable alternative sip_req_host for that matter, also see this stackoverflow thread):

  • req or Request Uri is where the INVITE goes (he next hop address, a proxy if you will)
  • To Uri is the actual destination to call
  <extension name="Illegale show">
    <condition regex="any">
      <!-- sip_req_host -->
      <regex field="${sip_to_host}" expression="illegaleshow.nl"/>
      <regex field="destination_number" expression="^illegaleshow$"/>

      <action application="set" data="domain_name=illegaleshow.nl"/>
      <action application="transfer" data="1200 XML illegaleshow"/>
    </condition>
  </extension>

You only need to set some DNS SRV records and you're off to go:

_sip._tcp.illegaleshow.nl. 384 IN SRV 10 20 5060 sip.ackspace.nl.
_sip._udp.illegaleshow.nl. 384 IN SRV 10 20 5060 sip.ackspace.nl.

Verify that they're active with: dig -t srv _sip._tcp.illegaleshow.nl

dial-string for Skinny and SIP

TODO: SCCP..

command line examples

You can run command line commands either as fs_cli -x "COMMAND" or by running the command line interface fs_cli and typing the COMMAND there

user_exists and user_data

Note that directory users have an id and optionally, a number-alias. Both can be used to register and check if it exists in the directory.

Typical for desk phones:

user_exists id 100 ackspace.nl
true

Typical for soft-phones (SIP client):

user_exists id ackspace ackspace.nl
true

Number from name or number

user_data 100@ackspace.nl attr number-alias and user_data ackspace@ackspace.nl attr number-alias
100

Name from name or number

user_data 100@ackspace.nl attr id and user_data ackspace@ackspace.nl attr id
ackspace

dial-string and sofia_contact

There is a user/ endpoint that uses the user's (or more regularly, the directory domain's) dial-string value to lookup the dial string address of the dialed user. This string usually contains the sofia_contact command:

sofia_contact ackspace@ackspace.nl
sofia/external/sip:ackspace@123.456.789.0:9876;transport=udp;user=phone;fs_nat=yes

Note: the contact URI only works on the registered user (use a number instead of a name if the user registered numerically; it happens, see Fritz!Box)

You can call a user by using: originate user/xopr@ackspace.nl 002 xml ackspace or originate user/196@ackspace.nl 002 xml ackspace.