「Asterisk pjsip」の版間の差分

提供: VoIP-Info.jp
移動先: 案内検索
(ACL)
(エンドポイント(電話機))
81行目: 81行目:
 
  outbound_auth = phone1
 
  outbound_auth = phone1
 
  aors = phone1
 
  aors = phone1
内線電話機に名前付ACLを使いたければ以下の例のように記述します。
 
acl = inhouse-phones
 
このACLはtype=aclで定義したセクション名です。
 
  
 
===トランク===
 
===トランク===

2018年10月24日 (水) 14:28時点における版


AsiteriskでチャネルにPjSIPを使用する際の設定方法など

コンパイル

Asterisk 13以前ではpjprojectを別個インストールするか、configureに--with-pjproject-bundledを付けて実行する必要がありましたが、Asterisk 16からはデフォルトでbundledインストールされるようになりました。
各バージョン毎のインストール方法についてはAsteriskのそれぞれのページを参照してください。
Asterisk 13
Asterisk 16

変換ツール

Asterisk 13以降であれば ソースディレクトリ/contrib/scripts/sip_to_pjsip の下にPythonのスクリプトがあります(複数)。sip.confのあるディレクトリでこれを実行するとpjsip.confに変換してくれます。#includeしている場合にはそれらも変換してくれますが、完璧ではないです。

基本設定(電話機:エンドポイント)

  • 間違いやすいところ
sip.confでは1wordだったのがアンダーバーが入る
dtmfmode → dtmf_mode

グローバル設定

pjsip.confに書きます。基本で必要なものは以下です。

[general]
maxexpirey = 3600

[transport-udp]
type = transport
protocol = udp
bind = 0.0.0.0:5070

sip.confに書いていたものと同じですが、トランスポートはセクションで明示指定します。上の例では5070ポートにbindさせていますが、5060を使用する場合にはここを5060にします。
なお、他の設定ファイル同様に#includeは使えます。なので、電話機と回線は別ファイルにした方が見通しは良いかもしれません。例えば

[general]
maxexpirey = 3600

[transport-udp]
type = transport
protocol = udp
bind = 0.0.0.0:507

#include pjsip_phones.conf
#include pjsip_trunk_hikari.conf

のようにファイルを分割し、includeすると管理が楽になります。

ACL

ACLの例は次の通りです。

[acl]
type=acl
deny=0.0.0.0/0.0.0.0
permit=192.168.0.0/255.255.0.0

※deny,permitはこの順でないとpermitしてdenyしてしまう模様で、逆に書くと誰も使えなくなります。 ※挙動によくわからない部分があるので動作確認してから情報追記

エンドポイント(電話機)

エンドポイントを設定する場合にはセクションが3つ必要です。エンドポイントそれ自体とaor,authの3つです。

[phone1]
type = aor
max_contacts = 1
qualify_frequency = 30
authenticate_qualify = no

[phone1]
type = auth
username = phone3
password = mysecretpassword

[phone1]
type = endpoint
context = default
transport=transport-udp
dtmf_mode = rfc4733
disallow = all
allow = ulaw
allow = alaw
rtp_symmetric = yes
force_rport = yes
rewrite_contact = yes
direct_media = no
send_pai = yes
inband_progress = yes
call_group = 1
pickup_group = 1
language = ja
device_state_busy_at = 1
auth = phone1
outbound_auth = phone1
aors = phone1

トランク

回線接続側は Asterisk pjsip trunksのページへ

Wizard

Asteriskにはpjsip_wizardが組み込まれており、PjSIPの設定を簡素化することができます。使う場合の条件は以下の通りです。

  • 基本の設定はpjsip.confに書く
transportなどの情報はpjsip.confに書く必要があります
  • Wizard用のファイル名はpjsip_wizard.conf
  • 共通化したテンプレート内で各セクションを指定するにはスラッシュ(/)で区切る
例: endpoint/dtmf_mode

pjsip_wizard.confの記述例

;電話機用テンプレート(共通設定)
[phone-defaults](!)
type=wizard
transport = transport-udp
accepts_registrations = yes
sends_registrations = no
accepts_auth = yes
sends_auth = no
endpoint/context = default
endpoint/dtmf_mode = rfc4733
endpoint/call_group = 1
endpoint/pickup_group = 1
endpoint/language = ja
endpoint/disallow = all
endpoint/allow = ulaw
endpoint/rtp_symmetric = yes
endpoint/force_rport = yes
endpoint/direct_media = no
endpoint/send_pai = yes
endpoint/send_rpid = yes
endpoint/rewrite_contact = yes
endpoint/inband_progress = yes
endpoint/allow_subscribe = yes
aor/max_contacts = 1
aor/qualify_frequency = 30
aor/authenticate_qualify = no

;各電話機個別設定
[phone1](phone-defaults)
inbound_auth/username = phone1
inbound_auth/password = mypasswordishere

CLIコマンド

  • sip show peersに対応するのはpjsip show endpoints
  • sip show peer phone1などピア情報を表示するのはpjsip show endpoint phone1
  • AORを表示するのは一覧ならpjsip show aorsでピアの情報を表示するのはpjsip show aor phone1のようにする
  • それぞれの設定項目で何が設定されているかを確認するには pjsip show endpoint phone1 のようにすると phone1 の endpoint パラメータ一覧が表示される。aorを見たければ pjsip show aor phone1。これはトランクの場合も同様で pjsip show regstration hikari-hgw のようにするとregister関係のパラメータがみえる。

設定変更の反映

  • モジュール数が多すぎて一発リロードする方法がよくわからない
  • module reload res_pjsip.soを実行すれば"だいたい"はいけそう
wizardのaor/を変更しても反映されない場合がある