- FreeSWITCH 1.6 Cookbook
- Anthony Minessale II Michael S Collins Giovanni Maruzzelli
- 880字
- 2021-07-16 13:45:13
Configuring an SIP phone to register with FreeSWITCH
SIP phones, or any SIP devices with the ability to register, are essential in most FreeSWITCH installations for allowing users to communicate with each other. A registration is when a phone or other device informs FreeSWITCH that it is active, and provides information (such as an IP address and port) on how to reach the phone across the network or Internet. FreeSWITCH stores this information for later use to contact that phone.
In this recipe, you will be registering a phone to FreeSWITCH. You will need to enter your credentials into your phone as well as into FreeSWITCH itself (both sides must match).
Getting ready
Ensure that the mod_sofia
module is already compiled and loaded (Sofia is the SIP stack). You may also want to know on which IP address your registrations are being accepted.
Follow these steps:
- Launch the FreeSWITCH command line interface.
- To view the current ports and IPs that you are listening on, type
sofia status.
- Review the output, specifically the lines listed as
internal
andexternal
, as follows:
external is the profile that is generally used to receive incoming calls, and to send outgoing traffic to our provider (from which we'll go to the destinations), and internal is the profile to which your internal phones and the phones of your users are registered to. Profiles are associated with a specific port and IP address. In this example, internal is associated with the 192.168.1.124 IP, implicitly port 5060. In essence, this means that the registrations that go to and fro from FreeSWITCH, for the internal profile, should occur on that address and port.
How to do it...
From an SIP standpoint, a real hardware phone or a software that runs on your desktop (or your cellphone) is exactly the same.
So, first of all, if you don't own a hardware SIP phone, install an SIP softphone. In this recipe we'll use X-Lite from CounterPath (http://www.counterpath.com/x-lite), but you can use whatever other SIP softphone suits your operating environment. For a list of softphones, check the FreeSWITCH documentation at https://freeswitch.org/confluence/display/FREESWITCH/Softphones.
If you own a hardware SIP phone, you'll find that configuring it will require the same information.
The following steps will show you how to configure an SIP phone:
- Decide on a new username and password that you wish to register with.
- Create and edit the new file called
directory/default/USERNAME.xml
in the FreeSWITCH configuration directory (usually/usr/local/freeswitch/conf
or/etc/freeswitch
). ReplaceUSERNAME
with a name or an extension number that is not yet there (such as2000
). - Add the following content to the file and save it:
<include> <user id="2000"> <params> <param name="password" value="PASS"/> </params> </user> </include>
Replace
2000
andPASS
in the code with a username and password of your choosing. - Load the FreeSWITCH CLI being used.
- Reload the in-memory configuration in FreeSWITCH's CLI by typing:
reloadxml
You will now be able to configure your softphone or device to register with FreeSWITCH. To do this, set the username as 2000
as shown, and keep the password as PASS
within your softphone or device. Set to register to the IP address (and port, if not the standard 5060) that you identified earlier.
For example, if you created the username 2000
and password PASS
, you would enter the following into your softphone:
How it works...
Let's see what you've done.
You've defined an SIP Username in the <user id="">
field. This username is used for the authentication of the SIP packets.
You've added this option in a file within the directory/default/
folder, which includes it as part of the default directory domain. This domain, by default, is your server's domain name (probably an IP address on your system).
There's more...
The SIP registration shown earlier was extremely basic. It doesn't specify a context for their calls to be placed in, it doesn't set the Caller ID for the device/user, and it doesn't add any extra variables to the account. Let's talk about these options, as they are common additions to any registration and directory entry. Also, if you don't specify the context, FreeSWITCH will put the incoming call in the "public" context by default, and that context will just drop the call if not otherwise customized.
Context
Calls received by FreeSWITCH will be directed, by default, to the context that is associated with the port and IP that a call comes in on. For example, calls received on port 5060 that are authenticated are assumed to be from an "in-house phone", and get to use the default
context. If, for some reason, you want to override the default for a particular device with a special context selection, you can do so by adding an additional variable.
Customizing caller ID
You want user 2000
to have a specific caller ID using the previous example. You can make this happen by defining a variable within the user's definition.
The example sets the Caller ID Name to Mary Sue
and the Caller ID Number to 2000
. Note that, if you choose to, you can further override this setting within the dialplan:
In the user definition, adding the user_context
variable will route all the calls from this device to the context named as "default" NB:
actually, "default" is a name (of an interesting context: try calling 5000). The default context is named "public").
See also
- Chapter 4, External Control
- R語言數據分析從入門到精通
- Web交互界面設計與制作(微課版)
- Ext JS Data-driven Application Design
- Mastering JavaScript Design Patterns(Second Edition)
- 編程與類型系統
- 微服務架構深度解析:原理、實踐與進階
- C/C++程序員面試指南
- Java Fundamentals
- Extreme C
- Kotlin Programming By Example
- Redmine Cookbook
- SQL Server實例教程(2008版)
- Learning Rust
- ASP.NET 3.5系統開發精髓
- WordPress 3.7 Complete(Third Edition)