官术网_书友最值得收藏!

  • 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:

  1. Launch the FreeSWITCH command line interface.
  2. To view the current ports and IPs that you are listening on, type
    sofia status.
    
  3. Review the output, specifically the lines listed as internal and external, as follows:

    Getting ready

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:

  1. Decide on a new username and password that you wish to register with.
  2. Create and edit the new file called directory/default/USERNAME.xml in the FreeSWITCH configuration directory (usually /usr/local/freeswitch/conf or /etc/freeswitch). Replace USERNAME with a name or an extension number that is not yet there (such as 2000).
  3. 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 and PASS in the code with a username and password of your choosing.

  4. Load the FreeSWITCH CLI being used.
  5. 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 to do it...

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:

Customizing caller ID

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

主站蜘蛛池模板: 香港 | 临武县| 古蔺县| 云阳县| 江川县| 临清市| 乌海市| 高雄县| 松滋市| 平陆县| 齐河县| 东宁县| 九龙县| 杭州市| 青龙| 来凤县| 外汇| 阳信县| 郁南县| 微博| 铜鼓县| 天水市| 莲花县| 堆龙德庆县| 苍南县| 张北县| 云浮市| 内黄县| 镇康县| 昭苏县| 东丽区| 保德县| 公主岭市| 福州市| 长宁区| 梅州市| 潮安县| 双桥区| 济源市| 宜昌市| 仁怀市|