# FreeSWITCH:コマンドラインツールfs\_cliと各種設定のポイント

**URL:** https://forum.ficusonline.com/t/topic/410
**Category:** Server
**Created:** [2021 年 3 月 4 日午前 5:23 UTC](https://forum.ficusonline.com/t/topic/410 "2021-03-04T05:23:54Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![tk-fuse](https://forum.ficusonline.com/user_avatar/forum.ficusonline.com/tk-fuse/32/255_2.png) [@tk-fuse](https://forum.ficusonline.com/u/tk-fuse)
#### Post date: [2021 年 3 月 4 日午前 5:23 UTC](https://forum.ficusonline.com/t/topic/410/1 "2021-03-04T05:23:54Z")

</div>

**FreeSWITCH** のコマンドラインインターフェイス **fs\_cli** と拡張モジュール・各種設定などについて、 **BigBlueButton** とは切り離してここで別途纏めます。

> **[Command Line Interface (fs\_cli) | FreeSWITCH Documentation](https://developer.signalwire.com/freeswitch/FreeSWITCH-Explained/Client-and-Developer-Interfaces/1048948/)**
>
> 0\\. About

**Docker** 内部から **FreeSwitch** のコマンドラインツール **`fs_cli`** を利用するため、 **`event_socket.conf.xml`** で各種条件を設定します。

以下 **Socket Client** の設定で、 **FreeSwitch** のコンテナ内で **`fs_cli`** のインターフェイスに入るためには、 **ホスト、ポート、パスワードオプションを付与** します。

```auto
# fs_cli -H 10.7.7.1 -P 8021 -p ClueCon

```

**`event_socket.conf.xml`**

```auto
<configuration name="event_socket.conf" description="Socket Client">
  <settings>
    <param name="nat-map" value="false"/>
    <param name="listen-ip" value="$${local_ip_v4}"/>
    <param name="listen-port" value="8021"/>
    <param name="password" value="ClueCon"/>
    <param name="apply-inbound-acl" value="loopback.custom"/>
    <!--<param name="stop-on-bind-error" value="true"/>-->
  </settings>
</configuration>

```

### FreeSwitch設定ファイル

> **[Default Configuration | FreeSWITCH Documentation](https://developer.signalwire.com/freeswitch/FreeSWITCH-Explained/Configuration/Default-Configuration_6587388/)**
>
> 0\\. About

 ![fs_default_config](https://forum.ficusonline.com/uploads/default/original/1X/95ef198b833866b32e1180da2b79414b2dd0820f.jpeg)

## fs\_cli コマンド

```shell
# fs_cli --help
.=======================================================.
| _________  ________ |
| | ___/___ | / ___| | |_ _| |
| | |_ \___ \ | | | | | | |
| | _| ___) | | |___| |___ | | |
| |_| | ____/ \____ | _____|___ | |
| |
.=======================================================.
| Anthony Minessale II, Ken Rice, |
| Michael Jerris, Travis Cross |
| FreeSWITCH (http://www.freeswitch.org) |
| Paypal Donations Appreciated: paypal@freeswitch.org |
| Brought to you by ClueCon http://www.cluecon.com/ |
.=======================================================.

.=======================================================================================================.
| _ _ _________ |
| / \ _ _____ _ _ ___| | /___ | |_ _ ___/___ | ______ |
| / _ \ | '_ \| '_ \| | | |/ _` | | | | | | | | |/ _ \ | / _ \| '_ \ |
| / ___\| | | | | | | |_| | (_| | | | |___| | |_| | __/ |__ | (_) | | | | |
| /_/ \_\_| |_|_| |_|\ __,_|\__ ,_|_| \ ____|_|\__ ,_|\ ___|\____ \___/|_| |_| |
| |
| _________  ________ __ |
| | _ \_ _/ ___| /___ | ______ / _| ______  ______  ______ |
| | |_) || || | | | / _ \| '_ \| |_ / _ \ ' __/ _ \ '_ \ /__ / _ \ |
| | _ < | || | ___| |__ | (_) | | | | _| __/ | |__ / | | | (_| __/ |
| |_| \_\|_| \ ____| \____ \ ___/|_| |_|_| \___ |_| \ ___|_| |_|\___ \___| |
| |
| _________ |
| / ___| |_ ____ / ___|___ _ _____  ______ ___ |
| | | | | | | |/ _ \ | / _ \| '_ \ / __/ _ \| '_ ` _ \ |
| | | ___| | |_| |__ / |__| (_) | | | | _ | (_| (_) | | | | | | |
| \ ____|_|\__ ,_|\ ___|\____ \___/|_| |_| (_) \___\___/|_| |_| |_| |
| |
.=======================================================================================================.

Type /help <enter> to see a list of commands

Usage: fs_cli [-H <host>] [-P <port>] [-p <secret>] [-d <level>] [-x command] [-t <timeout_ms>] [profile]

  -?,-h --help Usage Information
  -H, --host=hostname Host to connect
  -P, --port=port Port to connect (1 - 65535)
  -u, --user=user@domain user@domain
  -p, --password=password Password
  -i, --interrupt Allow Control-c to interrupt
  -x, --execute=command Execute Command and Exit
  -l, --loglevel=command Log Level
  -U, --log-uuid Include UUID in log output
  -S, --log-uuid-short Include shortened UUID in log output
  -q, --quiet Disable logging
  -r, --retry Retry connection on failure
  -R, --reconnect Reconnect if disconnected
  -d, --debug=level Debug Level (0 - 7)
  -b, --batchmode Batch mode
  -t, --timeout Timeout for API commands (in milliseconds)
  -T, --connect-timeout Timeout for socket connection (in milliseconds)
  -n, --no-color Disable color
  -s, --set-log-uuid Set UUID to filter log events

```

`-x` オプション付与でfreeswitchコマンドを実行可

例）グローバル変数一覧取得

```shell
# fs_cli -x "global_getvar"

```

freeswitchコマンド一覧

```shell
# fs_cli -x "help"

Valid Commands:

...,,Shutdown,mod_commands
acl,<ip> <list_name>,Compare an ip to an acl list,mod_commands
alias,[add|stickyadd] <alias> <command> | del [<alias>|*],Alias,mod_commands
amr_debug,<on|off>,Set AMR Debug,mod_amr
av,debug [on|off] | show <formats | codecs>,AV general commands,mod_av
banner,,Return the system banner,mod_commands
bgapi,<command>[<arg>],Execute an api command in a thread,mod_commands
break,<uuid> [all],uuid_break,mod_commands
callcenter_break,callcenter_break agent <uuid>,Stop watching an uuid and release agent,mod_callcenter
callcenter_config,callcenter_config <target> <args>,
        callcenter_config agent add [name] [type] | 
        callcenter_config agent del [name] | 

```

---

<div class="post-metadata">

### Author: ![tk-fuse](https://forum.ficusonline.com/user_avatar/forum.ficusonline.com/tk-fuse/32/255_2.png) [@tk-fuse](https://forum.ficusonline.com/u/tk-fuse)
#### Post date: [2021 年 3 月 4 日午前 6:26 UTC](https://forum.ficusonline.com/t/topic/410/2 "2021-03-04T06:26:31Z")

</div>

‼

# Access Control List (ACL)-APICommands

[https://freeswitch.org/confluence/pages/viewpage.action?pageId=3965687#AccessControlList(ACL)-APICommands](https://freeswitch.org/confluence/pages/viewpage.action?pageId=3965687#AccessControlList(ACL)-APICommands)

### reloadacl

```auto
reloadacl [<reloadxml>]

freeswitch@internal> reloadacl reloadxml

```

### acl

```auto
acl <ip> <list|net>

This command will allow you to test an IP address against one of your ACLs. Will return true or false. Use it to validate that your ACL behaves as expected. This test can also be a part of a dialplan <condition> test.

freeswitch@mybox> acl 192.168.42.42 192.168.42.0/24 
freeswitch@mybox> acl 192.168.42.42 list_foo

```

### Pre-defined ACLs

There are some ACLs automatically created on startup:

| ACL name | Description |
| --- | --- |
| `rfc1918.auto` | [RFC 1918](https://tools.ietf.org/html/rfc1918) Space |
| `nat.auto` | [RFC 1918](https://tools.ietf.org/html/rfc1918), excluding your local LAN |
| `localnet.auto` | ACL for your local LAN |
| `loopback.auto` | ACL for your local LAN |

---

<div class="post-metadata">

### Author: ![tk-fuse](https://forum.ficusonline.com/user_avatar/forum.ficusonline.com/tk-fuse/32/255_2.png) [@tk-fuse](https://forum.ficusonline.com/u/tk-fuse)
#### Post date: [2021 年 3 月 4 日午前 7:32 UTC](https://forum.ficusonline.com/t/topic/410/3 "2021-03-04T07:32:23Z")

</div>

> **[Reloading | FreeSWITCH Documentation](https://developer.signalwire.com/freeswitch/FreeSWITCH-Explained/Configuration/Reloading_13173616/)**
>
> Introduction

**`fs_cli`** による設定ファイルのリロードコマンド

```auto
# fs_cli -H xx.xx.xx.xx -P 8021 -p password
freeswitch> reloadxml

```

# Reload Command List

| Item | Reload Command | Notes |
| --- | --- | --- |
| Item | Reload Command | Notes |
| XML Dialplan | reloadxml | Run each time you edit XML dial file(s) |
| ACLs | reloadacl | Edit acl.conf.xml first |
| Voicemail | reload mod\_voicemail | Edit voicemail.conf.xml first |
| Conference | reload mod\_conference | Edit conference.conf.xml first |
| Add Sofia Gateway | sofia profile `<name>` rescan | Less intrusive - no calls dropped |
| Remove Sofia Gateway | sofia profile `<name>` killgw `<gateway_name>` | Less intrusive - no calls dropped |
| Restart Sofia Gateway | sofia profile `<name>` killgw `<gateway_name>` | |
| sofia profile rescan | Less intrusive - no calls dropped | |
| Add/remove Sofia Gateway | sofia profile `<name>` restart | More intrusive - all profile calls dropped |
| Local Stream | see [Mod\_local\_stream](https://freeswitch.org/confluence/display/FREESWITCH/mod_local_stream#mod_local_stream-API) | Edit localstream.conf.xml first |
| Update a lua file | nothing necessary | file is loaded from disk each time it is run |
| Update LCR SQL table | nothing necessary | SQL query is run for each new call |
| Update LCR options | reload mod\_lcr | Edit lcr.conf.xml first |
| Update CID Lookup Options | reload mod\_cidlookup | Edit cidlookup.conf.xml first |
| Update JSON CDR Options | reload mod\_json\_cdr | Edit json\_cdr.conf.xml first |
| Update XML CDR Options | reload mod\_xml\_cdr | Edit xml\_cdr.conf.xml first |
| Update XML CURL Server Response | nothing, unless using [cache](https://freeswitch.org/confluence/display/FREESWITCH/mod_xml_curl#mod_xml_curl-Caching) | |

**Ex) `external-ipv6.xml`** を編集後再読込

```auto
freeswitch > sofia profile exxternal-ipv6 rescan

```

**`sofia help`**

```auto
freeswitch > sofia help
USAGE:
--------------------------------------------------------------------------------
sofia global siptrace <on|off>
sofia capture <on|off>
             watchdog <on|off>

sofia profile <name> [start | stop | restart | rescan] [wait]
                     flush_inbound_reg [<call_id> | <[user]@domain>] [reboot]
                     check_sync [<call_id> | <[user]@domain>]
                     [register | unregister] [<gateway name> | all]
                     killgw <gateway name>
                     [stun-auto-disable | stun-enabled] [true | false]]
                     siptrace <on|off>
                     capture <on|off>
                     watchdog <on|off>

sofia <status|xmlstatus> profile <name> [reg [<contact str>]] | [pres <pres str>] | [user <user@domain>]
sofia <status|xmlstatus> gateway <name>

sofia loglevel <all|default|tport|iptsec|nea|nta|nth_client|nth_server|nua|soa|sresolv|stun> [0-9]
sofia tracelevel <console|alert|crit|err|warning|notice|info|debug>

sofia help
--------------------------------------------------------------------------------

```

> **[Sofia Configuration Files | FreeSWITCH Documentation](https://developer.signalwire.com/freeswitch/FreeSWITCH-Explained/Configuration/Sofia-SIP-Stack/Sofia-Configuration-Files_7144453/)**
>
> About

---

<div class="post-metadata">

### Author: ![tk-fuse](https://forum.ficusonline.com/user_avatar/forum.ficusonline.com/tk-fuse/32/255_2.png) [@tk-fuse](https://forum.ficusonline.com/u/tk-fuse)
#### Post date: [2021 年 3 月 4 日午前 7:50 UTC](https://forum.ficusonline.com/t/topic/410/4 "2021-03-04T07:50:14Z")

</div>

### モジュールによるコマンド一覧

> **[mod\_commands | FreeSWITCH Documentation](https://developer.signalwire.com/freeswitch/FreeSWITCH-Explained/Modules/mod_commands_1966741/)**
>
> 0\\. About

**fs\_cli** によるコンソールで実行

## [Command Line Interface (fs\_cli)](https://developer.signalwire.com/freeswitch/FreeSWITCH-Explained/Client-and-Developer-Interfaces/1048948)

* * *

### ロードモジュール設定ファイル

以下のファイルで読み込むモジュールを指定

**`freeswitch/conf/autoload_configs/modules.conf.xml`**

```auto
<configuration name="modules.conf" description="Modules">
  <modules>
    <!-- Loggers (I'd load these first) -->
    <load module="mod_console"/>

    <!-- Event Handlers -->
    <load module="mod_event_socket"/>

    <!-- Endpoints -->
    <load module="mod_sofia"/>

    <!-- Applications -->
    <load module="mod_commands"/>
    <load module="mod_conference"/>
    <load module="mod_dptools"/>

    <!-- Dialplan Interfaces -->
    <load module="mod_dialplan_xml"/>

    <!-- Codec Interfaces -->
    <load module="mod_spandsp"/>
    <load module="mod_opus"/>
    <load module="mod_opusfile"/>

    <!-- File Format Interfaces -->
    <load module="mod_sndfile"/>
    <load module="mod_native_file"/>

  </modules>
</configuration>

```

---

<div class="post-metadata">

### Author: ![tk-fuse](https://forum.ficusonline.com/user_avatar/forum.ficusonline.com/tk-fuse/32/255_2.png) [@tk-fuse](https://forum.ficusonline.com/u/tk-fuse)
#### Post date: [2021 年 3 月 4 日午後 2:07 UTC](https://forum.ficusonline.com/t/topic/410/5 "2021-03-04T14:07:09Z")

</div>

‼

# WebRTC (secure web socket wss settings)

> **[WebRTC | FreeSWITCH Documentation](https://developer.signalwire.com/freeswitch/FreeSWITCH-Explained/Configuration/WebRTC_3375381/)**
>
> About

`edit` **/usr/local/freeswitch/conf/sip\_profiles/internal.xml**

```auto
# Set these params and save the file:

<param name="tls-cert-dir" value="/usr/local/freeswitch/certs" />

<param name="wss-binding" value=":7443" />

```

If behind N.A.T. make sure to set the ext-sip-ip and ext-rtp-ip in vars.xml to the public IP address of your FreeSWITCH.

If talking to clients both inside and outside the N.A.T. you must set the local-network-acl rfc1918.auto, and prefix the ext-sip-ip and ext-rtp-ip to autonat:X.X.X.X

## Install Certificates

Layout of /usr/local/freeswitch/certs/wss.pem:

**/usr/local/freeswitch/certs/wss.pem**

`Cert, Key and Chain(s) are all contained in a single file in this order:`

```auto
-----BEGIN CERTIFICATE-----
< cert >

-----END CERTIFICATE-----

-----BEGIN RSA PRIVATE KEY-----

< key >

-----END RSA PRIVATE KEY-----

-----BEGIN CERTIFICATE-----

< chain >

-----END CERTIFICATE-----

```

**Letsencryptによる認証ファイルから作成する場合**

```auto
$ sudo cat cert.pem privkey.pem fullchain.pem > wss.pem

```

**OpenSSLによるポート7443のTLS認証確認**

```auto
$ openssl s_client -host www.example.com -port 7443

```

コマンドオプションについてはヘルプ参照のこと。

```auto
$ openssl s_client -help

```

**Let’sEncryptの認証ファイル** から作成した **wss.pem** は、 **SIPのTLS認証にも必要** となりますがファイル名が異なります。 **`wss.pem`** から内容をコピーして **`agent.pem, tls.pem, dtls-srtp.pem`** を作成します。

> **[Import SSL Certificate](https://www.pbxforums.com/threads/import-ssl-certificate.4312/)**
>
> I want to import an SSL certificate instead of using Let's Encrypt but having a hard time finding documentation on steps. I think I can alter the SSL config in sites enabled for the web interface but what about Freeswitch? Any help would be greatly...

```auto
#!/bin/bash

# make sure we have the correct permissions
chown root:ssl-cert my.certificate-privkey.pem
chown root:root my.certificate-cert.pem
chown root:root my.certificate-chain.pem
chown root:root my.certificate-fullchain.pem
chmod 640 my.certificate-privkey.pem
chmod 644 my.certificate-cert.pem
chmod 644 my.certificate-chain.pem
chmod 644 my.certificate-fullchain.pem

# copy file for webserver
cp my.certificate-fullchain.pem /etc/ssl/certs/my.certificate-fullchain.pem
cp my.certificate-privkey.pem /etc/ssl/private/my.certificate-privkey.pem

systemctl restart nginx

#setup freeswitch tls

#make sure the freeswitch directory exists
mkdir -p /etc/freeswitch/tls

#make sure the freeswitch certificate directory is empty
rm /etc/freeswitch/tls/*

#combine the certs into all.pem
cat my.certificate-fullchain.pem > /etc/freeswitch/tls/all.pem
cat my.certificate-privkey.pem >> /etc/freeswitch/tls/all.pem

#copy the certificates - not required, but useful to know what is in all.pem
cp my.certificate-cert.pem /etc/freeswitch/tls/cert.pem
cp my.certificate-chain.pem /etc/freeswitch/tls/chain.pem
cp my.certificate-fullchain.pem /etc/freeswitch/tls/fullchain.pem
cp my.certificate-privkey.pem /etc/freeswitch/tls/privkey.pem

#add symbolic links
ln -s /etc/freeswitch/tls/all.pem /etc/freeswitch/tls/agent.pem
ln -s /etc/freeswitch/tls/all.pem /etc/freeswitch/tls/tls.pem
ln -s /etc/freeswitch/tls/all.pem /etc/freeswitch/tls/wss.pem
ln -s /etc/freeswitch/tls/all.pem /etc/freeswitch/tls/dtls-srtp.pem

#set the permissions
chown -R www-data:www-data /etc/freeswitch/tls

fs_cli -x "reload mod_sofia"

```

---

<div class="post-metadata">

### Author: ![tk-fuse](https://forum.ficusonline.com/user_avatar/forum.ficusonline.com/tk-fuse/32/255_2.png) [@tk-fuse](https://forum.ficusonline.com/u/tk-fuse)
#### Post date: [2021 年 3 月 5 日午前 5:53 UTC](https://forum.ficusonline.com/t/topic/410/6 "2021-03-05T05:53:28Z")

</div>

‼

# General NAT example scenarios

> **[General NAT example scenarios | FreeSWITCH Documentation](https://developer.signalwire.com/freeswitch/FreeSWITCH-Explained/Networking/General-NAT-example-scenarios_13173280/)**
>
> Scenario 1

## Scenario 1

`FS (192.168.0.4) -> NAT (Public IP 1.2.3.4) -> INTERNET -> NAT (Public IP 5.6.7.8) -> FS (192.168.0.5)`

In this scenario you have to do two things.

1. Setup a profile with ext-sip-ip and ext-rtp-ip set.
2. If you setup ext-sip-ip and ext-rtp-ip on a profile then that profile **CAN NOT BE USED BY ANYTHING BEHIND THE SAME NAT PERIOD.**
3. Port forward the ports for that profile.

## Scenario 2

`FS (192.168.0.4) -> NAT (Public IP 1.2.3.4) -> INTERNET -> NAT (Public IP 5.6.7.8) -> PHONE (192.168.1.100)`

Prior to setting up your plan you must decide which domain you are going to use for your phone registration and which port the profile will listen to. The general SIP structure being.

`Phone {port} -> NAT 1 -> INTERNET -> NAT 2 -> {port}FS sip_profile {sip_profile domain} -> REGISTER {sip_profile domain} or Dialplan {sip_profile domain}`

The easiest would be to use the default domain. Keeping in mind you still have to create a new sip\_profile (for example, we’ll call it doublenat.xml) to handle the double NAT. The steps look like this.

1. copy the external.xml and rename it doublenat.xml
2. in doublenat.xml, change the profile name: 
3. add the 
4. add the 
5. add the 
6. add the 
7. change port to 5090 ( make sure to change it on the phone as well )
8. add the 
9. add the 
10. register the phone
11. check to see if your phone is registered with the doublenat profile.

`sofia status profile doublenat`

If your phone is not registered to doublenat then add :5090 to the domain/proxy on the phone configuration.

Example External IP:

`216.109.112.135:5090`

Example Domain:

`example.com:5090`

Keep in mind this profile will only be suitable for the double NAT scenario. Also keep in mind that this is the toughest scenario to conquer so you still may have adjustments on your phone or router.

## Scenario 3

`FS (192.168.0.4) -> NAT (Public IP 1.2.3.4) -> INTERNET -> Softphone Registering to FS`

In this scenario you also need a dedicated profile. Getting devices to register to your FS instance sitting behind NAT.

1. dedicated profile with ext-sip-ip and ext-rtp-ip set. **Again NOTHING BEHIND THE SAME NAT WILL BE ABLE TO USE THIS PROFILE PERIOD.**

## Scenario 4

`PHONE -> FS -> NAT -> Public Internet`

In this case you setup a profile for the phones to register without the ext-sip-ip and ext-rtp-ip options set. This profile would be used for all devices registering to the

FS instance that are behind the same NAT.

Then your outbound call would traverse another profile setup to bust through the NAT with the proper ext-sip-ip and ext-rtp-ip options set.

## Scenario 5

`FS (1.2.3.4) -> INTERNET -> NAT (Public IP 5.6.7.8) -> Client (192.168.0.5)`

More in depth article at [Nat](https://freeswitch.org/confluence/display/FREESWITCH/NAT)

---

<div class="post-metadata">

### Author: ![tk-fuse](https://forum.ficusonline.com/user_avatar/forum.ficusonline.com/tk-fuse/32/255_2.png) [@tk-fuse](https://forum.ficusonline.com/u/tk-fuse)
#### Post date: [2021 年 3 月 7 日午前 4:25 UTC](https://forum.ficusonline.com/t/topic/410/7 "2021-03-07T04:25:49Z")

</div>

### Certicifates

> **[Certificates | FreeSWITCH Documentation](https://developer.signalwire.com/freeswitch/FreeSWITCH-Explained/Security/Certificates_3966216/)**
>
> Certificate requirements are found in several areas of Freeswitch, and it's optional in a lot of other places. It's not always obvious how to manage your certificate files, for instance where to put them, what the format should be and how to...

### SIP TLS

> **[SIP TLS | FreeSWITCH Documentation](https://developer.signalwire.com/freeswitch/FreeSWITCH-Explained/Security/SIP-TLS_9634135/)**
>
> SIP Encryption Primer

 ![Anatomy-SIPS-and_SRTP-encrypted](https://forum.ficusonline.com/uploads/default/original/1X/7b4af84b392084fcf30988e5bb350bb787aa8fd6.gif)

**`vars.xml`**

```auto
<!--
     SIP and TLS settings. http://wiki.freeswitch.org/wiki/Tls
     valid options: sslv2,sslv3,sslv23,tlsv1,tlsv1.1,tlsv1.2
     default: tlsv1,tlsv1.1,tlsv1.2
  -->
  <X-PRE-PROCESS cmd="set" data="sip_tls_version=tlsv1,tlsv1.1,tlsv1.2"/>

```

⚠ **nginx** の **`ssl_protocols TLSv1 TLSv1.1 TLSv1.2;`** との整合性をチェックすること。

### ZRTP

[https://freeswitch.org/confluence/display/FREESWITCH/ZRTP](https://freeswitch.org/confluence/display/FREESWITCH/ZRTP)

---

<div class="post-metadata">

### Author: ![tk-fuse](https://forum.ficusonline.com/user_avatar/forum.ficusonline.com/tk-fuse/32/255_2.png) [@tk-fuse](https://forum.ficusonline.com/u/tk-fuse)
#### Post date: [2021 年 3 月 9 日午前 7:45 UTC](https://forum.ficusonline.com/t/topic/410/8 "2021-03-09T07:45:54Z")

</div>

### fs\_cli:sofiaコマンドによるSIPステータス確認

**外部** —\>`external`  
**内部** —\>`internal`

```auto
freeswitch@xxxxx> sofia status profile external
=================================================================================================
Name external
Domain Name N/A
Auto-NAT true
DBName sofia_reg_external
Pres Hosts       	
Dialplan XML
Context public
Challenge Realm auto_to
RTP-IP 10.x.x.x
Ext-RTP-IP       	
SIP-IP 10.x.x.x
Ext-SIP-IP xx.xx.xx.xx
URL sip:mod_sofia@10.x.x.x:5060
BIND-URL sip:mod_sofia@10.x.x.x:5060;transport=udp,tcp
TLS-URL sip:mod_sofia@10.x.x.x:5061
TLS-BIND-URL sips:mod_sofia@10.x.x.x:5061;transport=tls
HOLD-MUSIC local_stream://moh
OUTBOUND-PROXY N/A
CODECS IN OPUS,G722,PCMU,PCMA,H264,VP8
CODECS OUT OPUS,G722,PCMU,PCMA,H264,VP8
TEL-EVENT 101
DTMF-MODE rfc2833
CNG 13
SESSION-TO 0
MAX-DIALOG 0
NOMEDIA false
LATE-NEG true
PROXY-MEDIA false
ZRTP-PASSTHRU true
AGGRESSIVENAT false
CALLS-IN 0
FAILED-CALLS-IN 0
CALLS-OUT 0
FAILED-CALLS-OUT 0
REGISTRATIONS 0

```

---

<div class="post-metadata">

### Author: ![tk-fuse](https://forum.ficusonline.com/user_avatar/forum.ficusonline.com/tk-fuse/32/255_2.png) [@tk-fuse](https://forum.ficusonline.com/u/tk-fuse)
#### Post date: [2021 年 3 月 10 日午前 9:33 UTC](https://forum.ficusonline.com/t/topic/410/9 "2021-03-10T09:33:39Z")

</div>

### 保留音の設定 テストダイヤル 9664

**mod\_local\_stream**

> **[mod\_local\_stream | FreeSWITCH Documentation](https://developer.signalwire.com/freeswitch/FreeSWITCH-Explained/Modules/mod_local_stream_6587466/)**
>
> About

`/usr/local/freeswitch/conf/autoload_configs/local_stream.conf.xml`

```auto
<configuration name="local_stream.conf" description="stream files from local dir">
  <!-- fallback to default if requested moh class isn't found -->
  <directory name="default" path="$${sounds_dir}/music/8000">
    <param name="rate" value="8000"/>
    <param name="shuffle" value="true"/>
    <param name="channels" value="1"/>
    <param name="interval" value="20"/>
    <param name="timer-name" value="soft"/>
    <!-- list of short files to break in with every so often -->
    <!--<param name="chime-list" value="file1.wav,file2.wav"/>-->
    <!-- frequency of break-in (seconds)-->
    <!--<param name="chime-freq" value="30"/>-->
    <!-- limit to how many seconds the file will play -->
    <!--<param name="chime-max" value="500"/>-->
  </directory>

  <directory name="moh/8000" path="$${sounds_dir}/music/8000">
    <param name="rate" value="8000"/>
    <param name="shuffle" value="true"/>
    <param name="channels" value="1"/>
    <param name="interval" value="20"/>
    <param name="timer-name" value="soft"/>
  </directory>

  <directory name="moh/16000" path="$${sounds_dir}/music/16000">
    <param name="rate" value="16000"/>
    <param name="shuffle" value="true"/>
    <param name="channels" value="1"/>
    <param name="interval" value="20"/>
    <param name="timer-name" value="soft"/>
  </directory>

  <directory name="moh/32000" path="$${sounds_dir}/music/32000">
    <param name="rate" value="32000"/>
    <param name="shuffle" value="true"/>
    <param name="channels" value="1"/>
    <param name="interval" value="20"/>
    <param name="timer-name" value="soft"/>
  </directory>

  <directory name="moh/48000" path="$${sounds_dir}/music/48000">
    <param name="rate" value="48000"/>
    <param name="shuffle" value="true"/>
    <param name="channels" value="1"/>
    <param name="interval" value="10"/>
    <param name="timer-name" value="soft"/>
  </directory>

</configuration>

```

`/usr/local/freeswitch/conf/vars.xml`

```auto
.....
  <X-PRE-PROCESS cmd="set" data="hold_music=local_stream://moh/8000"/>
.....

```

**サウンドファイル**  
[https://files.freeswitch.org/releases/music/](https://files.freeswitch.org/releases/music/)

> **[Index of /releases/sounds](https://files.freeswitch.org/releases/sounds/)**

**makeコマンドによるサウンドファイルインストール（FreeSwitchをソースからビルド・インストールする場合）**

```auto
# make sounds-install moh-install

```

サウンドファイルインストールオプションについては、以下 **Makefile** 参照のこと。

> <https://github.com/signalwire/freeswitch/blob/master/Makefile.am>

# Test Calls

> **[Configuring FreeSWITCH | FreeSWITCH Documentation](https://developer.signalwire.com/freeswitch/FreeSWITCH-Explained/Configuration/Configuring-FreeSWITCH/)**
>
> About

Test your new FreeSWITCH™ installation by configuring a pair of SIP phones and to place test calls and try out features in the default dialplan. If you’re already familiar with Asterisk, you could also start out by [Connecting Freeswitch And Asterisk](https://confluence.freeswitch.org/display/FREESWITCH/Asterisk#Asterisk-ConnectingFreeSWITCHandAsteriskUsingSIP)

Register two phones to FreeSWITCH with two different extension numbers.

Let’s assume for this example that you have your SIP phones registered as extensions 1000 and 1001.

The default config provides user directory files for extension numbers 1000 through 1019 with a registration password of 1234; the default voice-mail password is the same number as the extension, e.g. Extension 1000 has its voice-mail password set to 1000

Sample softphone configurations can be seen on the [Softphones](https://freeswitch.org/confluence/display/FREESWITCH/Softphones) page.

Once you’ve done that, you can try out a bunch of features already setup in the test dialplan.

## Basic Calling

- Call between 1000 and 1001 by dialing the respective extension.
- Call 4000 to login to your voicemail box.
- 870 - Redial last called # from this extension.
- \*69 - Call back the last person to call this extension.
- 8+[ext] - Place an intercom call to extension [ext]. If no answer, it does not go to voicemail but just keeps ringing. Some phones have additional functionality for intercom calls.

## Other Tests

- 9192 - Info test (prints information to the command line interface).fs\_cliによるコンソール画面上にデバック情報が表示される。
- 9193 - Video record test (records video to /tmp/testrecord.fsv)
- 9194 - Video playback test (plays video from /tmp/testrecord.fsv)
- 9195 - Echo test (5-second delay before returning echo).
- 9196 - Echo test (real-time).
- 9197 - Play milliwatt test tone.
- 9198 - Tetris, synthesized via tone streaming.
- 9664 - Test Music On Hold out (if you installed sound files).

## Interactive Voice Response

- 5000 - IVR demo (if you installed sound files).

---

<div class="post-metadata">

### Author: ![tk-fuse](https://forum.ficusonline.com/user_avatar/forum.ficusonline.com/tk-fuse/32/255_2.png) [@tk-fuse](https://forum.ficusonline.com/u/tk-fuse)
#### Post date: [2021 年 3 月 11 日午前 7:58 UTC](https://forum.ficusonline.com/t/topic/410/10 "2021-03-11T07:58:39Z")

</div>

## Dialplanクイックリファレンス

**内線番号と機能**  
設定ファイル：`conf/dialplan/default.xml`

| EXTENSION | FUNCTION |
| --- | --- |
| 1000 - 1019 | Local extensions |
| \*\* + extension number | Intercepts a ringing phone (that is, call pickup) |
| 2000 | Samples call group: Sales |
| 2001 | Samples call group: Support |
| 2002 | Samples call group: Billing |
| 3000 - 3399 | Samples conference rooms |
| 4000 or \*98 | Retrieves voicemail |
| 5000 | Demo IVR |
| 5900 | FIFO queue park |
| 5901 | FIFO queue retrieve |
| 6000 | Valet park/retrieval, manual |
| 6001-6099 | Valet park/retrieval, automatic |
| 7243 | RTP multicast page |
| 0911 | Group intercom example #1 |
| 0912 | Group intercom example #2 |
| 0913 | Emergency outbound conference example |
| 9178 | Example fax receive |
| 9179 | Example fax transmit |
| 9180 | Ring test, far end generates ring tone |
| 9181 | Ring test, send U.K. ring tone |
| 9182 | Ring test, send music as ring tone |
| 9183 | Answer, then send U.K. ring tone |
| 9184 | Answer, then send music as ring tone |
| 9191 | ClueCon registration |
| 9192 | Information dump |
| 9195 | Delayed echo test |
| 9196 | Echo test |
| 9197 | Milliwatt tone (test signal quality) |
| 9198 | Tetris |
| 9664 | Music on hold |

**Dialplan**

> **[Dialplan | FreeSWITCH Documentation](https://developer.signalwire.com/freeswitch/FreeSWITCH-Explained/Dialplan/)**
>
> About

---

<div class="post-metadata">

### Author: ![tk-fuse](https://forum.ficusonline.com/user_avatar/forum.ficusonline.com/tk-fuse/32/255_2.png) [@tk-fuse](https://forum.ficusonline.com/u/tk-fuse)
#### Post date: [2021 年 3 月 11 日午前 11:11 UTC](https://forum.ficusonline.com/t/topic/410/11 "2021-03-11T11:11:21Z")

</div>

## モジュールビルドオプション

ビルド前に必要な追加オプションはコメントアウトすること。

> <https://github.com/signalwire/freeswitch/blob/v1.10.5/build/modules.conf.in>

---

<div class="post-metadata">

### Author: ![tk-fuse](https://forum.ficusonline.com/user_avatar/forum.ficusonline.com/tk-fuse/32/255_2.png) [@tk-fuse](https://forum.ficusonline.com/u/tk-fuse)
#### Post date: [2021 年 3 月 12 日午後 3:11 UTC](https://forum.ficusonline.com/t/topic/410/12 "2021-03-12T15:11:06Z")

</div>

## FreeSWITCH GUI

> **[Freeswitch GUI | FreeSWITCH Documentation](https://developer.signalwire.com/freeswitch/FreeSWITCH-Explained/Client-and-Developer-Interfaces/Freeswitch-GUI/)**
>
> About

**FusionPBX**

> **[GitHub - fusionpbx/fusionpbx: Official FusionPBX - A full-featured domain based...](https://github.com/fusionpbx/fusionpbx)**
>
> Official FusionPBX - A full-featured domain based multi-tenant PBX and voice switch for FreeSwitch.

> **[3 easy steps to enable WebRTC capabilities in FusionPBX!](https://www.linkedin.com/pulse/3-easy-steps-enable-webrtc-capabilities-fusionpbx-azhar-nawaz/)**
>
> WebRTC (Web Real-Time Communication) is a technology which enables Web applications and sites to capture and optionally stream audio and/or video media, as well as to exchange arbitrary data between browsers without requiring an intermediary. #webrtc...

---

<div class="post-metadata">

### Author: ![tk-fuse](https://forum.ficusonline.com/user_avatar/forum.ficusonline.com/tk-fuse/32/255_2.png) [@tk-fuse](https://forum.ficusonline.com/u/tk-fuse)
#### Post date: [2021 年 3 月 13 日午前 4:49 UTC](https://forum.ficusonline.com/t/topic/410/13 "2021-03-13T04:49:48Z")

</div>

### ユーザ追加

デフォルトユーザ **1000** から新規ユーザ **Gwen** 、内線番号： **1100** を作成

```bash
# cd /usr/local/freeswitch/conf/directory/default
# cp 1000.xml 1100.xml

```

`1100.xml`を編集。

```auto
<include>
<user id="1100">
<params>
<param name="password" value="$${default_password}"/>
<param name="vm-password" value="1100"/>
</params>
<variables>
<variable name="toll_allow"
value="domestic,international,local"/>
<variable name="accountcode" value="1100"/>
<variable name="user_context" value="default"/>
<variable name="effective_caller_id_name" value="Gwen"/>
<variable name="effective_caller_id_number"
value="1100"/>
<variable name="outbound_caller_id_name"
value="$${outbound_caller_name}"/>
<variable name="outbound_caller_id_number"
value="$${outbound_caller_id}"/>
<variable name="callgroup" value="techsupport"/>
</variables>
</user>
</include>

```

`conf/dialplan/default.xml` の **Local\_Extension** に番号 **1100** を反映

```auto
<extension name="Local_Extension">
<condition field="destination_number"
expression="^(10[01][0-9]|1100)$">

```

**fs\_cli** コンソールで **xml** ファイルのリロード

```auto
freeswitch> reloadxml

```

---

<div class="post-metadata">

### Author: ![tk-fuse](https://forum.ficusonline.com/user_avatar/forum.ficusonline.com/tk-fuse/32/255_2.png) [@tk-fuse](https://forum.ficusonline.com/u/tk-fuse)
#### Post date: [2021 年 3 月 13 日午前 5:02 UTC](https://forum.ficusonline.com/t/topic/410/14 "2021-03-13T05:02:51Z")

</div>

### ボイスメール

**1001から1000へのコールの場合**

**1001** ：発信側には、設定時間の30秒を超えるとボイスメッセージの案内が再生されます。メッセージを残し電話を切ります。

**1000** ：受け手は、 **番号4000または\*98** と自身のID: **1000#** とパスワード: **1000#** の入力で、ボイスメールを聞くことが出来ます。

```
Main menu:
1—Listen to new messages
2—Listen to saved messages
5—Options menu (recorded name, greeting, and so on)
#—Exit voicemail
While listening to a message:
1—Replay message from the beginning
2—Save message
4—Rewind
6—Fast-forward
After listening to a message:
1—Replay message from the beginning
2—Save message
4—Send to e-mail (requires configuration)
7—Delete message

```

**設定ファイル**  
`conf/autoload_configs/voicemail.conf.xml`

---

<div class="post-metadata">

### Author: ![tk-fuse](https://forum.ficusonline.com/user_avatar/forum.ficusonline.com/tk-fuse/32/255_2.png) [@tk-fuse](https://forum.ficusonline.com/u/tk-fuse)
#### Post date: [2021 年 3 月 13 日午前 5:51 UTC](https://forum.ficusonline.com/t/topic/410/15 "2021-03-13T05:51:24Z")

</div>

### グループ追加・発信

ユーザをグループごとに振分けることで、グループ所属ユーザへ一斉に発信することが出来ます。

**デフォルトグループへカスタムグループcustomを追加**  
`conf/directory/default.xml`

```xml
<groups>
<group name="default">
<users>
<X-PRE-PROCESS cmd="include" data="default/*.xml"/>
</users>
</group>
<group name="sales">
<users>
<!-- 
	      type="pointer" is a pointer so you can have the
	      same user in multiple groups. It basically means
	      to keep searching for the user in the directory.
	   -->
<user id="1000" type="pointer"/>
<user id="1001" type="pointer"/>
<user id="1002" type="pointer"/>
<user id="1003" type="pointer"/>
<user id="1004" type="pointer"/>
</users>
</group>
<group name="billing">
<users>
<user id="1005" type="pointer"/>
<user id="1006" type="pointer"/>
<user id="1007" type="pointer"/>
<user id="1008" type="pointer"/>
<user id="1009" type="pointer"/>
</users>
</group>
<group name="support">
<users>
<user id="1010" type="pointer"/>
<user id="1011" type="pointer"/>
<user id="1012" type="pointer"/>
<user id="1013" type="pointer"/>
<user id="1014" type="pointer"/>
</users>
</group>

<group name="custom">
<users>
<user id="1000" type="pointer"/>
<user id="1100" type="pointer"/>
</users>
</group>
</groups>

```

**group\_dial\_custom** セクションを追加  
`conf/dialplan/default.xml`

```auto
<extension name="group_dial_sales">
<condition field="destination_number" expression="^2000$">
<action application="bridge" data="${group_call(sales@${domain_name})}"/>
</condition>
</extension>
<extension name="group_dial_support">
<condition field="destination_number" expression="^2001$">
<action application="bridge" data="group/support@${domain_name}"/>
</condition>
</extension>
<extension name="group_dial_billing">
<condition field="destination_number" expression="^2002$">
<action application="bridge" data="group/billing@${domain_name}"/>
</condition>
</extension>
<extension name="group_dial_custom">
<condition field="destination_number" expression="^2003$">
<action application="bridge"
data="group/custom@${domain_name}"/>
</condition>
</extension>

```

**fs\_cli** コンソールで設定のリロードとグループ所属ユーザの確認

```auto
freeswitch@internal> reloadxml
freeswitch@internal> group_call custom
[sip_invite_domain=10.15.64.229,presence_
id=1000@10.15.64.229]error/user_not_registered,[sip_invite_
domain=10.15.64.229,presence_id=1100@10.15.64.229]sofia/internal/
sip:1100@10.15.129.38:5060;rinstance=8eecf059256b51f1;fs_
nat=yes;fs_path=sip%3A1100%4010.15.129.38%3A5060%3Brinstance%3D8ee
cf059256b51f1

```

**2003** へのダイヤルでグループ所属ユーザへ一斉呼び出し。グループ内で一番速く応答したユーザと繋がり、他のユーザの呼出音が鳴り止みます。

---

<div class="post-metadata">

### Author: ![tk-fuse](https://forum.ficusonline.com/user_avatar/forum.ficusonline.com/tk-fuse/32/255_2.png) [@tk-fuse](https://forum.ficusonline.com/u/tk-fuse)
#### Post date: [2021 年 3 月 14 日午後 3:01 UTC](https://forum.ficusonline.com/t/topic/410/16 "2021-03-14T15:01:23Z")

</div>

‼

# Auto Nat

## autonat and external ip

> **[Auto Nat | FreeSWITCH Documentation](https://developer.signalwire.com/freeswitch/FreeSWITCH-Explained/Networking/Auto-Nat_6587487/)**
>
> About

If you know your external ip, you can set it on your sofia profile and also instruct FreeSWITCH™ to set it when building the SDP:

```auto
< param name = "ext-sip-ip" value = "autonat:${external_sip_ip}" />

```

If you want to use the same profile to talk with things inside and outside your network you need to instruct FreeSWITCH™ when it should use the local IP and the external IP. The autonat: prefix toggles on the usage of the local-network-acl, if you prefix the IP like that it will activate the dynamic ability to tell when it should use ext-rtp-ip vs rtp-ip based on the acl match.

‼

# Sofia Configuration Files

## ext-rtp-ip

> **[Sofia Configuration Files | FreeSWITCH Documentation](https://developer.signalwire.com/freeswitch/FreeSWITCH-Explained/Configuration/Sofia-SIP-Stack/Sofia-Configuration-Files_7144453/)**
>
> About

This is the IP behind which FreeSWITCH is seen from the Internet, so if FreeSWITCH is behind NAT, this is basically the public IP that should be used for RTP.

| ext-rtp-ip value | Description | Example |
| --- | --- | --- |
| $${variable} | Any variable from vars.xml | `<param name="ext-rtp-ip" value="$${external_rtp_ip}"/>` |
| w.x.y.z | Specific numeric IP address | `<param name="ext-rtp-ip" value="1.2.3.4"/>` |
| autonat:w.x.y.z | Used for LAN and WAN to avoid errors in the SIP CONTACT sent to LAN devices | `<param name="ext-rtp-ip" value="autonat:1.2.3.4"/>` |
| auto | Guessed IP (guessed by looking in the IP routing table which interface is the default route) | `<param name="ext-rtp-ip" value="auto"/>` |
| auto-nat | FS uses uPNP or NAT-PMP to discover the public IP address it should use | `<param name="ext-rtp-ip" value="auto-nat"/>` |
| stun:DNS name or IP address of STUN server | FS uses the STUN server of your choice to discover the public IP address | `<param name="ext-rtp-ip" value="stun:stun.freeswitch.org"/>` |
| host:DNS name | FS resolves the DNS name as the public IP address, so you can use a dynamic DNS host | `<param name="ext-rtp-ip" value="host:mypublicIP.dyndns.org"/>` |

params with the **‘ext–’** prefix cited above when populated with yet-to-be-resolved DNS strings (e.g. `name="ext–sip–ip" value="stun:stun.freeswitch.org"` or `name="ext‑rtp–ip" value="host:mypublicIP.dyndns.org"` ) are resolved to IP addresses **once only at FreeSWITCH load time** and remain constant thereafter. FS is blind to (unaware of) any subsequent changes in your environment’s IP address. Thus, these ext– vars may become functionally incompatible with the environment’s current IP addresses with _unspecified results_ in call flow at the network layer. FS restart is _ **required** _ for FS to capture the now-current, working IP address(es).

## NATing

##### apply-nat-acl

When receiving a REGISTER or INVITE, enable [NAT mode](https://freeswitch.org/confluence/display/FREESWITCH/NAT) automatically if IP address in Contact header matches an entry defined in the [RFC 1918](https://tools.ietf.org/html/rfc1918) [access list](https://freeswitch.org/confluence/pages/viewpage.action?pageId=3965687). “acl” is a misnomer in this case because access will not be denied if the user’s contact IP doesn’t match.

**`<param name="apply-nat-acl" value="rfc1918"/>`**

## Auth

These settings deal with authentication: requirements for identifying SIP endpoints to FreeSWITCH.

#### auth-calls

Users in the directory can have “auth-acl” parameters applied to them so as to restrict users access to a predefined ACL or a CIDR.

**`<param name="auth-calls" value="$${internal_auth_calls}"/>`**

Value can be “false” to disable authentication on this profile, meaning that when calls come in the profile will _not_ send an auth challenge to the caller.

* * *

## TLS

Please make sure to read [SIP TLS](https://freeswitch.org/confluence/display/FREESWITCH/SIP+TLS) before enabling certain features below as they may not behave as expected.

##### tls

TLS: disabled by default, set to “true” to enable

`<param name="tls" value="$${internal_ssl_enable}"/>`

##### tls-only

disabled by default, when enabled prevents sofia from listening on the unencrypted port for this connection. This can stop many generic brute force scripts and if all your clients connect over TLS then can help decrease the exposure of your FreeSWITCH server to the world.

`<param name="tls-only" value="false"/>`

##### tls-bind-params

additional bind parameters for TLS

`<param name="tls-bind-params" value="transport=tls"/>`

##### tls-sip-port

Port to listen on for TLS requests. (5061 will be used if unspecified)

`<param name="tls-sip-port" value="$${internal_tls_port}"/>`

##### tls-cert-dir

Location of the agent.pem and cafile.pem ssl certificates (needed for TLS server)

`<param name="tls-cert-dir" value="$${internal_ssl_dir}"/>`

##### tls-version

**TLS version (“sslv2”, “sslv3”, “sslv23”, “tlsv1”, “tlsv1.1”, “tlsv1.2”). NOTE: Phones may not work with TLSv1**

`<param name="tls-version" value="$${sip_tls_version}"/>`

When not set defaults to: **“tlsv1,tlsv1.1,tlsv1.2”**

##### tls-passphrase

If your agent.pem is protected by a passphrase stick the passphrase here to enable FreeSWITCH to decrypt the key.

`<param name="tls-passphrase" value=""/>`

##### tls-verify-date

If the client/server certificate should have the date on it validated to ensure it is not expired and is currently active.

`<param name="tls-verify-date" value="true"/>`

##### tls-verify-policy

This controls what, if any security checks are done against server/client certificates. Verification is generally checking certificates are valid against the cafile.pem. Set to ‘in’ to only verify incoming connections, ‘out’ to only verify outgoing connections, ‘all’ to verify all connections, also ‘subjects\_in’, ‘subjects\_out’ and ‘subjects\_all’ for subject validation (subject validation for outgoing connections is against the hostname/ip connecting to). Multiple policies can be split with a ‘|’ pipe, for example ‘subjects\_in|subjects\_out’. Defaults to none.

`<param name="tls-verify-policy" value="none"/>`

##### tls-verify-depth

When certificate validation is enabled (tls-verify-policy) how deep should we try to verify a certificate up the chain again the cafile.pem file. By default only depth of 2.

`<param name="tls-verify-depth" value="2"/>`

##### tls-verify-in-subjects

If subject validation is enabled for incoming connections (tls-verify-policy set to ‘subjects\_in’ or ‘subjects\_all’) this is the list of subjects that are allowed (delimit with a ‘|’ pipe), note this only effects incoming connections for outgoing connections subjects are always checked against hostnames/ips.

`<param name="tls-verify-in-subjects" value=""/>`

---

<div class="post-metadata">

### Author: ![tk-fuse](https://forum.ficusonline.com/user_avatar/forum.ficusonline.com/tk-fuse/32/255_2.png) [@tk-fuse](https://forum.ficusonline.com/u/tk-fuse)
#### Post date: [2021 年 3 月 15 日午前 9:15 UTC](https://forum.ficusonline.com/t/topic/410/17 "2021-03-15T09:15:43Z")

</div>

‼

# External Profile

> **[External Profile | FreeSWITCH Documentation](https://developer.signalwire.com/freeswitch/FreeSWITCH-Explained/Configuration/Sofia-SIP-Stack/External-Profile_13173235/)**
>
> About

**PSTN** (public switched telephone network)既存電話網への接続サービスを提供している外部SIPプロバイダに登録することで、安価に外線通話・内線へのダイレクト通話が可能になります。  
**注）** 通話料は安くなりますが、ほぼ全てのプロバイダが有料で、法人向けのサービス内容です。  
動作確認にはVoIP電話機が必要です。

**設定例：[freelycall.com](http://freelycall.com) port:5080**

[https://www.freelycall.com/software/freeswitch/](https://www.freelycall.com/software/freeswitch/)

`conf/sip_profiles/external/freelycall.com.xml`

```auto
<include>
<gateway name=”freelycall.com“>
<param name=”username” value=”(YOUR-FREELYCALL-ACCOUNT-NUMBER)”/>
<param name=”realm” value=”[freelycall.com](http://freelycall.com/)“/>
<param name=”from-domain” value=”[freelycall.com](http://freelycall.com/)“/>
<param name=”password” value=”+++++++++++”/>
<param name=”register” value=”true”/>
<param name=”retry-seconds” value=”30″/>
</gateway>
</include>

```

fs\_cliコンソールで、sofia sipの再起動と設定ファイルのリロードを実行します。

```auto
freeswitch> sofia profile external restart reloadxml

```

登録されているかどうかステータスを確認します。  
REGEDが表示されていればOKです。  
`external::freelycall	gateway sip:xxxxxxx@freelycall.org.com	REGED`

```auto
freeswitch> sofia status
                     Name Type Data	State
=================================================================================================
            external-ipv6	profile sip:mod_sofia@[::1]:5080	RUNNING (0)
            external-ipv6	profile sip:mod_sofia@[::1]:5081	RUNNING (0) (TLS)
            192.168.1.205 alias internal	ALIASED
                 external	profile sip:mod_sofia@192.168.x.xx:5080	RUNNING (0)
                 external	profile sip:mod_sofia@192.168.x.xx:5081	RUNNING (0) (TLS)
    external::example.com	gateway sip:xxxxxx@example.com	NOREG
     external::freelycall	gateway sip:xxxxxxx@freelycall.org.com	REGED
            internal-ipv6	profile sip:mod_sofia@[::1]:5060	RUNNING (0)
                 internal	profile sip:mod_sofia@192.168.x.xx:5060	RUNNING (0)
=================================================================================================

```

**内線から外線をかける場合**

ダイヤルプランのデフォルトディレクトリに新規ダイヤルプランを作成します。  
`conf/dialplan/default/01custom.xml`

```auto
<include>
<extension name=" freelycall-outbound">
<condition field="destination_number"
expression="^9(1\d{10})$">
<action application="bridge"
data="sofia/gateway/freelycall.com/$1"/>
</condition>
</extension>
</include>

```

VoIP電話機で9を押した後、USのフリーダイヤルに電話をかけてみて下さい。  
`1-800-555-1212`

**外線から内線1000への接続例**  
ダイヤルプランのパブリックディレクトリに新規ダイヤルプランを作成します。  
`conf/dialplan/public/01freelycall.com.xml`

```auto
<include>
<extension name="freelycall-inbound">
<condition field="destination_number"
expression="^(MY_FREELYCALL_USERNAME)$">)$">
<action application="set"
data="domain_name=${domain}"/>
<action application="bridge" data="1000 XML default"/>
</condition>
</extension>
</include>

```

**fs\_cli** コンソールで設定をリロードします。

```auto
freeswitch> reloadxml

```

これでFreelicall.comへ登録したアカウント宛の呼出は、内線1000番に繋がります。

---

<div class="post-metadata">

### Author: ![tk-fuse](https://forum.ficusonline.com/user_avatar/forum.ficusonline.com/tk-fuse/32/255_2.png) [@tk-fuse](https://forum.ficusonline.com/u/tk-fuse)
#### Post date: [2021 年 3 月 17 日午前 2:45 UTC](https://forum.ficusonline.com/t/topic/410/18 "2021-03-17T02:45:57Z")

</div>

‼

# Sofia SIPコマンド

> **[Sofia SIP Stack | FreeSWITCH Documentation](https://developer.signalwire.com/freeswitch/FreeSWITCH-Explained/Configuration/Sofia-SIP-Stack/)**
>
> About

### Reloading profiles and gateways

You can reload a specific SIP profile by issuing a rescan/restart command from the console

`freeswitch> sofia profile <profile_name> [<rescan>|<restart>] reloadxml`

```auto
freeswitch> sofia profile internal restart reloadxml
freeswitch> sofia profile external rescan reloadxml

```

### View SIP Registrations

You can view all the devices that have registered by running the following from the console.

`freeswitch> sofia status profile <profile name> reg`

```auto
freeswitch> sofia status profile internal reg 
freeswitch> sofia status profile external reg

```

---

<div class="post-metadata">

### Author: ![tk-fuse](https://forum.ficusonline.com/user_avatar/forum.ficusonline.com/tk-fuse/32/255_2.png) [@tk-fuse](https://forum.ficusonline.com/u/tk-fuse)
#### Post date: [2021 年 3 月 17 日午前 9:49 UTC](https://forum.ficusonline.com/t/topic/410/19 "2021-03-17T09:49:58Z")

</div>

## Configuring FreeSWITCH to use databases

> **[FreeSWITCH Databases | FreeSWITCH Documentation](https://developer.signalwire.com/freeswitch/FreeSWITCH-Explained/Databases/FreeSWITCH-Databases_13173016/)**
>
> About

デフォルトのデータベースである **SQLite** 以外のデータベースを使用する場合、コア設定ファイル内で、使用するデータベースをアンコメントして有効にします( **MariaDB** を有効化した場合)。

`conf/autoload_configs/switch.conf.xml`

```auto
<!-- <param name="core-db-dsn" value="pgsql://hostaddr=127.0.0.1 dbname=freeswitch user=freeswitch password='' options='-c client_min_messages=NOTICE'" /> -->
<!-- <param name="core-db-dsn" value="postgresql://freeswitch:@127.0.0.1/freeswitch?options=-c%20client_min_messages%3DNOTICE" /> -->
<param name="core-db-dsn" value="mariadb://Server=localhost;Database=freeswitch;Uid=freeswitch;Pwd=pass;" /> 
<!-- <param name="core-db-dsn" value="dsn:username:password" /> -->

```

**SIPモジュール** で新規データベースを使用する場合、以下 **xmlファイル** の`<settings>`セクションにデータベースパラメータを追加して下さい。

`sip_profiles/external.xml`  
`sip_profiles/internal.xml`  
`sip_profiles/internal-ipv6.xml`

```auto
<param name="odbc-dsn" value="odbc://your_dsn_name:your_db_user:your_db_password"/>

```

---

<div class="post-metadata">

### Author: ![tk-fuse](https://forum.ficusonline.com/user_avatar/forum.ficusonline.com/tk-fuse/32/255_2.png) [@tk-fuse](https://forum.ficusonline.com/u/tk-fuse)
#### Post date: [2021 年 3 月 17 日午前 11:44 UTC](https://forum.ficusonline.com/t/topic/410/20 "2021-03-17T11:44:28Z")

</div>

### Perl互換正規表現

**Perl-compatible regular expressions (PCRE)**

| Pattern | Meaning |
| --- | --- |
| 123 | Match any string containing the sequence “123” |
| ^123 | Match any string beginning with the sequence “123” |
| 123$ | Match any string ending with the sequence “123” |
| ^123$ | Match any string that is exactly the sequence “123” |
| \d | Match any single digit (0-9) |
| \d\d | Match two consecutive digits |
| ^\d\d\d$ | Match any string that is exactly three digits long |
| ^\d{7}$ | Match any string that is exactly seven digits long |
| ^(\d{7})$ | Match any string that is exactly seven digits long, and store the matched value in a special variable named $1 |
| ^1?(\d{10})$ | Matching any string that optionally begins with the digit “1” and contains an additional ten digits; store the ten digits in $1 |
| ^(3\d\d\d)$ | Match any four-digit string that begins with the digit “3”, and store the matched value in $1 |

**Regular Expression**

> **[Regular Expression | FreeSWITCH Documentation](https://developer.signalwire.com/freeswitch/FreeSWITCH-Explained/Examples/Regular-Expression/)**
>
> About

**mod\_commads-regex**

> **[mod\_commands | FreeSWITCH Documentation](https://developer.signalwire.com/freeswitch/FreeSWITCH-Explained/Modules/mod_commands_1966741/)**
>
> 0\\. About

[次のページ](https://forum.ficusonline.com/t/topic/410.md?page=2)
