「Asterisk」の版間の差分
Kusanaginoturugi (トーク | 投稿記録) 細 (→インストール: 記事が古かったので一部削除) |
(同期) |
||
| (6人の利用者による、間の53版が非表示) | |||
| 1行目: | 1行目: | ||
| − | [[Category:電話 |
+ | [[Category:電話]] |
| + | [[Category:Voice over IP]] |
||
[[en:Asterisk]] |
[[en:Asterisk]] |
||
| − | [http://www.asterisk.org Asterisk] は完全な PBX ( |
+ | [http://www.asterisk.org Asterisk] は完全な PBX (構内交換機) ソフトウェアです。Linux, BSD, Windows, macOS などで動作し、PBX が通常備えている機能は全て含まれています。Asterisk は4つのプロトコルで Voice over IP を実現し、比較的安価なハードウェアでほぼ全ての規格の電話装置と一緒に使うことが可能です。 |
Asterisk はボイスメールサービス、電話帳、電話会議、自動音声応答、コールキューイングを実現します。また、三者通話、発信者番号通知サービス、ADSI、IAX、SIP、H.323 (クライアントとゲートウェイの両方)、MGCP (コールマネージャのみ)、SCCP/Skinny をサポートしています。 |
Asterisk はボイスメールサービス、電話帳、電話会議、自動音声応答、コールキューイングを実現します。また、三者通話、発信者番号通知サービス、ADSI、IAX、SIP、H.323 (クライアントとゲートウェイの両方)、MGCP (コールマネージャのみ)、SCCP/Skinny をサポートしています。 |
||
| 7行目: | 8行目: | ||
この記事では家庭ネットワークにおけるシンプルな設定を説明し、SIP [[アプリケーション一覧/インターネット#VoIP / ソフトフォン|ソフトフォン]]を使って LAN 上の他の SIP ソフトフォンと会話できるようにします。 |
この記事では家庭ネットワークにおけるシンプルな設定を説明し、SIP [[アプリケーション一覧/インターネット#VoIP / ソフトフォン|ソフトフォン]]を使って LAN 上の他の SIP ソフトフォンと会話できるようにします。 |
||
| − | ==インストール== |
+ | == インストール == |
| + | {{AUR|asterisk}} パッケージをインストールしてください。Cisco の IP 電話を使用する場合はパッチが適用されている {{AUR|asterisk-cisco}} パッケージを使うことが推奨されます ([https://issues.asterisk.org/jira/browse/ASTERISK-13145 https://issues.asterisk.org/jira/browse/ASTERISK-13145] を参照)。 |
||
| − | [[AUR]] から {{AUR|asterisk}} をインストールして、{{ic|asterisk.service}} を使ってサーバーを[[起動]]してください。 |
||
| + | あるいは、{{AUR|asterisk-lts-20}} パッケージをインストールすると、長期サポートリリースを入手できます(現在の最新 LTS メジャーバージョンは Asterisk 20です)。Asterisk LTS リリースは機能が少ない傾向にありますが、ずっと長い間メンテナンスされます。すべての asterisk バージョンのリリースサイクルに関する完全な詳細については、[https://wiki.asterisk.org/wiki/display/AST/Asterisk+Versions Asterisk Versions] ページを参照してください。 |
||
| − | SIP [[アプリケーション一覧/インターネット#VoIP / ソフトフォン|ソフトフォン]]と最低2つのマシンが必要です。SIP フォンとしては[[公式リポジトリ]]の [http://www.linphone.org/ linphone] ({{Pkg|linphone}}) や [[AUR]] の [http://www.xten.net/index.php?menu=X-Series x-lite] ({{AUR|xlite_bin}}) が推奨されます。 |
||
| + | インストールしたら {{ic|asterisk.service}} systemd サービスを[[有効化]]および[[起動]]してください。 |
||
| − | ilbc コーデックのサポートを有効にするには PKGBUILD の build セクションの最初に以下を追加してください: |
||
| + | |||
| − | {{bc|<nowiki> cd ${srcdir}/${pkgname}-${pkgver}/contrib/scripts |
||
| + | SIP [[アプリケーション一覧/インターネット#VoIP / ソフトフォン|ソフトフォン]]と最低2つのマシンが必要です。SIP フォンとしては [https://icanblink.com/ Blink] ({{AUR|blink}})、 [https://www.linphone.org/ Linphone] ({{AUR|liblinphone-git}}) または [https://www.counterpath.com/x-lite/ X-Lite] ({{AUR|xlite-bin}}) が推奨されます。 |
||
| − | echo | ./get_ilbc_source.sh</nowiki>}} |
||
| + | |||
| + | ilbc コーデックのサポートを有効にするには PKGBUILD の {{ic|build}} セクションの冒頭に以下を追加してください: |
||
| + | {{bc|<nowiki> |
||
| + | cd ${srcdir}/${pkgname}-${pkgver}/contrib/scripts |
||
| + | echo | ./get_ilbc_source.sh |
||
| + | </nowiki>}} |
||
| + | |||
| + | == 設定 == |
||
| + | |||
| + | Asterisk 20 から、従来の {{ic|chan_sip}} モジュールはデフォルトでコンパイルされなくなりました。Asterisk 21 がリリースされると(2023年10月予定)、{{ic|chan_sip}} は完全に削除されます(すでにマスターブランチから削除されています)。もし {{ic|res_pjsip}} よりも {{ic|chan_sip}} を使用したい場合は、{{AUR|asterisk-lts-18}} をインストールしてください。これは、{{ic|chan_sip}} をビルドした最後の LTS リリースでした。 |
||
| + | |||
| + | {{ic|res_pjsip}} は、より新しく、より高性能な Asterisk チャネルモジュールで、標準の SIP(Session Initiation Protocol)プロトコルをサポートしています。これは、多くのキャリア、電話会社、インターネット電話サービスプロバイダ(ITSP)、および企業で使用されている主要な VoIP(Voice over Internet Protocol)プロトコルです。ただし、{{ic|res_pjsip}} は、古い {{ic|chan_sip}} よりも設定がかなり複雑です。 |
||
| + | |||
| + | 広く受け入れられている Asterisk コミュニティの意見では、既存の設定がある場合に限り {{ic|chan_sip}} を使用し、{{ic|res_pjsip}} へのアップグレードも計画することを提案しています。新規インストールの場合は、{{ic|res_pjsip}} が推奨されます。上記で述べたように、{{ic|chan_sip}} はもはやメンテナンスされておらず、セキュリティ修正も(古い LTS リリースを除いて)行われないため、新しい Asterisk PBX 管理者は、サポートされている SIP チャネルドライバー(つまり、{{ic|res_pjsip}})を選択するべきです。 |
||
| + | |||
| + | 既存の {{ic|chan_sip}} 設定がある場合、Asterisk 20 でビルドするには、次の手順を実行します:{{AUR|asterisk}} の PKGBUILD を編集し、{{ic|build()}} 関数内で次の行を変更します: |
||
| + | |||
| + | {{hc|PKGBUILD|2=make MENUSELECT_CFLAGS= OPTIMIZE= DEBUG= ASTVARRUNDIR="/run/$pkgname" NOISY_BUILD=1}} |
||
| + | |||
| + | これを menuselect ツールをビルドする呼び出しでプレフィックスし、{{ic|chan_sip}} を有効にします: |
||
| + | |||
| + | {{hc|PKGBUILD|2= |
||
| + | make menuselect.makeoptions && \ |
||
| + | menuselect/menuselect --enable chan_sip && \ |
||
| + | make MENUSELECT_CFLAGS= OPTIMIZE= DEBUG= ASTVARRUNDIR="/run/$pkgname" NOISY_BUILD=1 |
||
| + | }} |
||
| + | |||
| + | この手順は、{{AUR|asterisk}} パッケージの更新ごとに行う必要がありますが、{{AUR|asterisk}} が Asterisk 21 に移行すると、この手順は機能しなくなることに注意してください。 |
||
| + | |||
| + | === PJSIP === |
||
| + | |||
| + | インストール後、Asterisk は {{ic|res_pjsip}} 設定を {{ic|/etc/asterisk/pjsip.conf}} に持っています。Asterisk に同梱されているサンプルファイルには、いくつかの基本的な例が含まれていますが、すべての pjsip オプションには網羅されていません。続行する前に、[https://wiki.asterisk.org/wiki/x/EwFB Asterisk Wiki Security best practices article] と [https://wiki.asterisk.org/wiki/display/AST/Configuring+res_pjsip Configuring res_pjsip] を読むことをお勧めします。 |
||
| + | |||
| + | この記事には、基本的なシングル SIP 電話と複数の SIP トランクの例が含まれており、[https://store.sipstation.com/ss_index/ SIP Station SIP trunks, from Sangoma] を使用しています。SIP Station の推奨に従って、2つの SIP トランクが冗長性のために SIP Station で設定されています。次の例は、Sangoma/Digium D60 ハードウェア電話を使用してテストされましたが、SIP 2.0 準拠のハードウェア電話またはソフトウェア電話でも十分です。 |
||
| + | |||
| + | この例では、Asterisk PBX サーバーと SIP 電話がプライベートな IPv4 LAN 上にあり、NAT ルーターがサーバー/電話と WAN/インターネットの間にあると仮定しています。IPv6 を使用したい場合は、[https://wiki.asterisk.org/wiki/display/AST/Configuring+res_pjsip+for+IPv6 Configuring res_pjsip for IPv6] の記事をお読みください。 |
||
| + | |||
| + | ==== modules.conf ==== |
||
| + | |||
| + | まず、{{ic|res_pjsip.so}} が {{ic|1=noload =}} でプレフィックスされていないことを確認してください。この例では、{{ic|1=require =}} プレフィックスを使って、{{ic|chan_pjsip.so}} のロードに失敗した場合に Asterisk がロードに失敗するようにしています。これは絶対に必要ではありませんが、{{ic|res_pjsip}} がロードされない場合、Asterisk がロードされる意味がないかもしれません。 |
||
| + | |||
| + | {{hc|/etc/asterisk/modules.conf|2= |
||
| + | ;... |
||
| + | require = chan_pjsip.so |
||
| + | ;... |
||
| + | }} |
||
| + | |||
| + | ==== pjsip.conf ==== |
||
| + | |||
| + | {{ic|pjsip.conf}} の設定に取り掛かる前に、[https://wiki.asterisk.org/wiki/display/AST/PJSIP+Configuration+Wizard PJSIP Configuration Wizard] を確認してください。これは、1つの SIP プロバイダー/ ITSP のみの簡単なユースケースに役立ち、pjsip オブジェクトの多くを自動的に処理します。 |
||
| + | |||
| + | ファイル {{ic|pjsip.conf}} は、ini 形式の設定ファイルで、{{ic|[section-headers-in-square-brackets]}} と、ハッシュ({{ic|#}})またはセミコロン({{ic|;}})をコメント文字として使用します。セクションヘッダーの下の各行は {{ic|1=key=value}} ペアで、セクション固有のキーを指定された値に設定します。セクションヘッダーには、閉じる角括弧の後に {{ic|(!)}} を追加できることに注意してください。これは、セクションがテンプレートであり、後で {{ic|pjsip.conf}} 内で使用することを示しています。以前に定義されたテンプレートを使用してセクションをインスタンス化するには、セクションヘッダーに {{ic|(template-name)}} を追加してください。 |
||
| + | |||
| + | ===== transport セクション ===== |
||
| + | |||
| + | Asterisk で使用する SIP トランクを定義するために、PJSIP にはネットワーク {{ic|transport}} という概念があります。Asterisk Wiki によると、トランスポートセクションは {{ic|res_pjsip}} がトランスポート層でどのように動作するかを設定します。例えば、TCP、UDP、WebSockets などのプロトコルや、TLS/SSL などの暗号化方式の設定オプションをサポートしています。 |
||
| + | |||
| + | トランスポートセクションの名前は自由に設定できますが、その意味が分かりやすい名前にすることを推奨します。以下の例では、SIP に UDP を使用し、NAT デバイスを経由することを示すために、{{ic|[transport-udp-nat]}} という名前を付けています。 |
||
| + | |||
| + | {{hc|/etc/asterisk/pjsip.conf|2= |
||
| + | [transport-udp-nat] |
||
| + | type=transport ; signifies this is a transport definition |
||
| + | protocol=udp ; specifies this uses the UDP transport protocol |
||
| + | ; this transport binds to all configured network interfaces, |
||
| + | ; replace with the IP address of the desired interface. 0.0.0.0 means all interfaces |
||
| + | bind=0.0.0.0 |
||
| + | ; ===== NOTE, the following directives are OPTIONAL |
||
| + | local_net=10.20.30.0/24 ; specify the networks that this Asterisk server should consider as local/LAN networks. Change this to the local LAN subnet (in CIDR notation) |
||
| + | local_net=127.0.0.0/8 ; specify the networks that this Asterisk server should consider as local/LAN networks (this one sets it to the IPv4 loopback network) |
||
| + | external_media_address=96.69.199.60 ; specify the external/WAN IP address for RDP media (audio) |
||
| + | external_signaling_address=96.69.199.60 ; specify the external/WAN IP address for SIP (signaling) |
||
| + | }} |
||
| + | |||
| + | 1 つの IP アドレス/ポート、または IP アドレス/プロトコルの組み合わせにつき、使用できるトランスポートは 1 つだけであることに注意してください。 |
||
| + | |||
| + | 複数のトランスポートプロトコル(例: TCP と UDP の両方)を設定したい場合は、それぞれのプロトコルを異なる IP アドレスにバインドする必要があります。同様に、同じプロトコルで複数のトランスポートを定義したい場合は、それぞれのトランスポート定義で異なるポートを使用する必要があります。 |
||
| + | |||
| + | ===== registration セクション ===== |
||
| + | |||
| + | 次に、SIP トランクが使用する登録を定義します。SIP ステーションの登録は、まずテンプレートを使用して定義されることに注意してください(セクション名の末尾に {{ic|(!)}} を付けます) |
||
| + | |||
| + | 各テンプレートは、そのテンプレートを使用する各セクションに共通の設定を定義し、各セクション自体には、そのセクション専用のオプションのみを設定します。 |
||
| + | |||
| + | {{hc|/etc/asterisk/pjsip.conf|2= |
||
| + | [sipstation-reg](!) |
||
| + | type=registration |
||
| + | transport=transport-udp-nat |
||
| + | contact_user=15055551234 |
||
| + | retry_interval=60 |
||
| + | |||
| + | ; ==== ... several other templates and sections will appear here |
||
| + | ; ==== including the authentication sections, etc., which are also used by the registration |
||
| + | ; ==== .... |
||
| + | |||
| + | [siptsation-reg1](sipstation-reg) |
||
| + | outbound_auth=sipstation-auth1 |
||
| + | <nowiki>server_uri=sip:trunk1.freepbx.com ; trunk1 provided by SIP Station |
||
| + | client_uri=sip:my_username@trunk1.freepbx.com</nowiki> |
||
| + | |||
| + | [siptsation-reg2](sipstation-reg) |
||
| + | outbound_auth=sipstation-auth2 |
||
| + | <nowiki>server_uri=sip:trunk2.freepbx.com ; trunk2 provided by SIP Station |
||
| + | client_uri=sip:my_username@trunk2.freepbx.com</nowiki> |
||
| + | }} |
||
| + | |||
| + | ===== authentication セクション ===== |
||
| + | |||
| + | ここでは、認証テンプレートと、SIP ステーショントランクで使用する特定の認証セクションを定義します。 |
||
| + | |||
| + | {{hc|/etc/asterisk/pjsip.conf|2= |
||
| + | [sipstation-auth](!) |
||
| + | type=auth |
||
| + | password=Super*Secret@Password! |
||
| + | username=my_username |
||
| + | |||
| + | ; ==== ... more templates may appear here |
||
| + | |||
| + | [sipstation-auth1](sipstation-auth) |
||
| + | realm=trunk1.freepbx.com |
||
| + | |||
| + | [sipstation-auth2](sipstation-auth) |
||
| + | realm=trunk2.freepbx.com |
||
| + | }} |
||
| + | |||
| + | ===== endpoint セクション ===== |
||
| + | |||
| + | エンドポイントは、電話機やリモートサーバーなどの SIP デバイスの設定プロファイルのようなものです。 |
||
| + | ここでは、トランスポートの設定、エンドポイントから発信された通話が処理される Asterisk ダイヤルプランのコンテキスト、およびエンドポイントで使用可能なオーディオコーデックを定義します。 |
||
| + | SIP ステーショントランクの場合、次の設定を定義します: |
||
| + | |||
| + | {{hc|/etc/asterisk/pjsip.conf|2= |
||
| + | [sipstation-endpoint](!) |
||
| + | type=endpoint |
||
| + | transport=transport-udp-nat |
||
| + | context=from-external ; Dialplan context, defined in extensions.conf or related file |
||
| + | disallow=all ; disallows all codecs, including default ones, unless explicitly allowed below |
||
| + | allow=ulaw ; standard G.711, uncompressed PCM codec. Uses the most bandwidth |
||
| + | allow=gsm ; another standard, compressed codec. Uses less bandwidth than ulaw |
||
| + | ; other codecs are available, and have different attributes. Some require paid licenses to use. |
||
| + | aors=sipstation-aors ; AOR - Address of Record, to be defined later |
||
| + | ;direct_media=no ; setting this may not allow audio to pass through NAT |
||
| + | direct_media=yes |
||
| + | rtp_symmetric=yes |
||
| + | |||
| + | ; ==== ... more template definitions |
||
| + | |||
| + | [sipstation-endpoint1](sipstation-endpoint) |
||
| + | outbound_auth=sipstation-auth1 |
||
| + | from_domain=trunk1.freepbx.com |
||
| + | |||
| + | [sipstation-endpoint2](sipstation-endpoint) |
||
| + | outbound_auth=sipstation-auth2 |
||
| + | from_domain=trunk2.freepbx.com |
||
| + | }} |
||
| + | |||
| + | ===== identify セクション ===== |
||
| + | |||
| + | res_pjsip_endpoint_identifier_ip モジュールが、受信パケットがどのエンドポイントからのものかを判断する方法を制御します、SIP ステーショントランクの場合、次の設定を定義します: |
||
| + | |||
| + | {{hc|/etc/asterisk/pjsip.conf|2= |
||
| + | [sipstation-identify](!) |
||
| + | type=identify |
||
| + | ; this is the LAN IP address of the NAT router, which calls from the SIP Station |
||
| + | ; trunks may appear to come from (because of NAT). |
||
| + | match=10.20.30.254/32 |
||
| + | |||
| + | [sipstation-id1](sipstation-identify) |
||
| + | endpoint=sipstation-endpoint1 |
||
| + | match=192.159.66.3 ; IP address of trunk1.freepbx.com |
||
| + | |||
| + | [sipstation-id2](sipstation-identify) |
||
| + | endpoint=sipstation-endpoint2 |
||
| + | match=162.253.134.142 ; IP address of trunk2.freepbx.com |
||
| + | }} |
||
| + | |||
| + | ===== AOR (Address Of Record) セクション ===== |
||
| + | |||
| + | AOR オブジェクト (Address of Record) の主な機能は、Asterisk にエンドポイントの連絡先を知らせることです。 |
||
| + | AOR セクションが関連付けられていないと、エンドポイントに接続できません。 |
||
| + | SIP ステーショントランクの場合、次の設定を定義します: |
||
| + | |||
| + | {{hc|/etc/asterisk/pjsip.conf|2= |
||
| + | [sipstation-aors] |
||
| + | type=aor |
||
| + | <nowiki>contact=sip:trunk1.freepbx.com |
||
| + | contact=sip:trunk2.freepbx.com</nowiki> |
||
| + | }} |
||
| + | |||
| + | ===== phone セクション ===== |
||
| + | |||
| + | 最後に、Asterisk に登録する SIP 電話のために必要なセクションを定義します。これは、SIP ステーショントランクと似たような複数のセクションがあります。複数のローカル SIP 電話が Asterisk PBX に登録する予定の場合は、これらをテンプレートで拡張してください。 |
||
| + | リモート電話 (WAN/インターネットからのもの)も設定できますが、それはこの例の範囲外です。 |
||
| + | |||
| + | {{hc|/etc/asterisk/pjsip.conf|2= |
||
| + | [home-phone] |
||
| + | type=endpoint |
||
| + | transport=transport-udp-nat |
||
| + | context=from-internal ; Dialplan context that gets executed when a user dials from this phone |
||
| + | disallow=all |
||
| + | allow=ulaw |
||
| + | allow=gsm |
||
| + | auth=home-phone-auth |
||
| + | aors=home-phone |
||
| + | |||
| + | [home-phone-auth] |
||
| + | type=auth |
||
| + | auth_type=userpass |
||
| + | password=MyPhonePa$$word0 |
||
| + | username=home-phone |
||
| + | |||
| + | [home-phone] |
||
| + | type=aor |
||
| + | max_contacts=1 |
||
| + | }} |
||
| + | |||
| + | ==== PJSIP の管理 ==== |
||
| + | |||
| + | Asterisk CLI では、{{ic|res_pjsip}} に関するいくつかのコマンドが利用可能で、すべて {{ic|pjsip}} コマンドでプレフィックスが付けられています。Asterisk CLI にアクセスするには、以下のコマンドを {{ic|asterisk}} ユーザーとして入力します: |
||
| + | |||
| + | $ asterisk -rvvv |
||
| + | |||
| + | これは、Asterisk がすでに実行中であることを前提としています(例:systemd サービスユニット経由)Asterisk CLI に入ると、プロンプトが {{ic|hostname*CLI> }} と表示されます。利用可能な PJSIP コマンドのリストを表示するには、{{ic|help pjsip}} と入力します。 |
||
| + | |||
| + | PJSIP の登録リストを表示するには、以下のコマンドを入力します: |
||
| + | |||
| + | {{hc|hostname*CLI> pjsip show registrations|<nowiki> |
||
| + | |||
| + | <Registration/ServerURI..............................> <Auth....................> <Status.......> |
||
| + | --------------------------------------------------------------------------------------------- |
||
| + | |||
| + | siptsation-reg1/sip:trunk1.freepbx.com sipstation-auth1 Registered (exp. 2062s) |
||
| + | siptsation-reg2/sip:trunk2.freepbx.com sipstation-auth2 Registered (exp. 2069s) |
||
| + | |||
| + | Objects found: 2 |
||
| + | </nowiki>}} |
||
| + | |||
| + | PJSIP エンドポイントのリストを表示するには、次のように入力します: |
||
| + | |||
| + | {{hc|hostname*CLI> pjsip show endpoints|<nowiki> |
||
| + | |||
| + | Endpoint: <Endpoint/CID.....................................> <State.....> <Channels.> |
||
| + | I/OAuth: <AuthId/UserName...........................................................> |
||
| + | Aor: <Aor............................................> <MaxContact> |
||
| + | Contact: <Aor/ContactUri..........................> <Hash....> <Status> <RTT(ms)..> |
||
| + | Transport: <TransportId........> <Type> <cos> <tos> <BindAddress..................> |
||
| + | Identify: <Identify/Endpoint.........................................................> |
||
| + | Match: <criteria.........................> |
||
| + | Channel: <ChannelId......................................> <State.....> <Time.....> |
||
| + | Exten: <DialedExten...........> CLCID: <ConnectedLineCID.......> |
||
| + | ---------------------------------------------------------------------------------------------- |
||
| + | |||
| + | Endpoint: home-phone Not in use 0 of inf |
||
| + | InAuth: home-phone-auth/home-phone |
||
| + | Aor: home-phone 1 |
||
| + | Contact: home-phone/sip:home-phone@10.20.30.229:506 f91928f561 NonQual nan |
||
| + | Transport: transport-udp-nat udp 0 0 0.0.0.0:5060 |
||
| + | |||
| + | Endpoint: sipstation-endpoint1 Not in use 0 of inf |
||
| + | OutAuth: sipstation-auth1/mw3FSBsPPjQ7 |
||
| + | Aor: sipstation-aors 0 |
||
| + | Contact: sipstation-aors/sip:trunk1.freepbx.com 256c242e36 NonQual nan |
||
| + | Contact: sipstation-aors/sip:trunk2.freepbx.com c07c6c7180 NonQual nan |
||
| + | Transport: transport-udp-nat udp 0 0 0.0.0.0:5060 |
||
| + | Identify: sipstation-id1/sipstation-endpoint1 |
||
| + | Match: 10.20.30.254/32 |
||
| + | Match: 192.159.66.3/32 |
||
| + | |||
| + | Endpoint: sipstation-endpoint2 Not in use 0 of inf |
||
| + | OutAuth: sipstation-auth2/mw3FSBsPPjQ7 |
||
| + | Aor: sipstation-aors 0 |
||
| + | Contact: sipstation-aors/sip:trunk1.freepbx.com 256c242e36 NonQual nan |
||
| + | Contact: sipstation-aors/sip:trunk2.freepbx.com c07c6c7180 NonQual nan |
||
| + | Transport: transport-udp-nat udp 0 0 0.0.0.0:5060 |
||
| + | Identify: sipstation-id2/sipstation-endpoint2 |
||
| + | Match: 10.20.30.254/32 |
||
| + | Match: 162.253.134.142/32 |
||
| + | |||
| + | Objects found: 3 |
||
| + | </nowiki>}} |
||
| + | |||
| + | === chan_sip === |
||
| − | ==設定== |
||
| − | ===SIP=== |
||
asterisk サーバーを動かしたら、後は2つのファイルを編集すれば設定できます: {{ic|sip.conf}} と {{ic|extensions.conf}}。asterisk の設定ディレクトリ ({{ic|/etc/asterisk}}) に移動して、{{ic|sip.conf}} を編集して以下を記述してください: |
asterisk サーバーを動かしたら、後は2つのファイルを編集すれば設定できます: {{ic|sip.conf}} と {{ic|extensions.conf}}。asterisk の設定ディレクトリ ({{ic|/etc/asterisk}}) に移動して、{{ic|sip.conf}} を編集して以下を記述してください: |
||
{{bc|1= |
{{bc|1= |
||
| 47行目: | 327行目: | ||
これでコンテキスト {{Ic|house}} が作成され SIP ユーザー {{Ic|me1}} にエクステンション 100 が、SIP ユーザー {{Ic|me2}} にエクステンション 101 が割り当てられます。後は実際に動作するか確認するだけです。 |
これでコンテキスト {{Ic|house}} が作成され SIP ユーザー {{Ic|me1}} にエクステンション 100 が、SIP ユーザー {{Ic|me2}} にエクステンション 101 が割り当てられます。後は実際に動作するか確認するだけです。 |
||
| + | |||
| − | ===保留音=== |
||
| + | === 保留音 === |
||
| + | |||
保留音はとても楽しい機能です。簡単に設定することができます。{{ic|/etc/asterisk/musiconhold.conf}} を編集して以下を追加してください: |
保留音はとても楽しい機能です。簡単に設定することができます。{{ic|/etc/asterisk/musiconhold.conf}} を編集して以下を追加してください: |
||
{{bc|1= |
{{bc|1= |
||
[default] |
[default] |
||
mode=files |
mode=files |
||
| − | directory= |
+ | directory=mohmp3 |
| − | }} |
||
| − | Now go into your sip.conf |
||
| − | {{bc|1= |
||
| − | musiconhold=default |
||
}} |
}} |
||
| − | 後はお気に入りの MP3 を {{ic|/var/lib/asterisk/mohmp3}} にコピーしてください。 |
+ | 後は合法的に入手したお気に入りの MP3 を {{ic|/var/lib/asterisk/mohmp3}} にコピーしてください。 |
| + | |||
| + | === ボイスメール === |
||
| − | ===ボイスメール=== |
||
Asterisk にはボイスメール機能が存在します。設定する方法は多数ありますが、この記事ではシンプルな設定方法だけを紹介します。 |
Asterisk にはボイスメール機能が存在します。設定する方法は多数ありますが、この記事ではシンプルな設定方法だけを紹介します。 |
||
| 78行目: | 357行目: | ||
</nowiki>}} |
</nowiki>}} |
||
| − | [general] の設定の内容は [http://voip-info.jp/index.php/Asterisk_%E3%82%B5%E3%83%B3%E3%83%97%E3%83%AB%E8%A8%AD%E5%AE%9A%E3%83%95%E3%82%A1%E3%82%A4%E3%83%AB_voicemail.conf こちら] を見て下さい。[[Postfix]] が正しくセットアップされていれば PBX からメールの通知がユーザーに送信され、{{Ic|1=attach=yes}} と定義されている場合、メールに音声ファイルが添付されます。 |
+ | {{Ic|[general]}} の設定の内容は [http://voip-info.jp/index.php/Asterisk_%E3%82%B5%E3%83%B3%E3%83%97%E3%83%AB%E8%A8%AD%E5%AE%9A%E3%83%95%E3%82%A1%E3%82%A4%E3%83%AB_voicemail.conf こちら] を見て下さい。[[Postfix]] が正しくセットアップされていれば PBX からメールの通知がユーザーに送信され、{{Ic|1=attach=yes}} と定義されている場合、メールに音声ファイルが添付されます。 |
次にメールボックスの設定です。フォーマットは: |
次にメールボックスの設定です。フォーマットは: |
||
| 84行目: | 363行目: | ||
上記の場合、'Me' というユーザー名でメールアドレスが me@mydomain.com、パスワードが 1234 のメールボックス 100 が設定されます。 |
上記の場合、'Me' というユーザー名でメールアドレスが me@mydomain.com、パスワードが 1234 のメールボックス 100 が設定されます。 |
||
| + | それから、ボイスメールボックスにメッセージを残す方法と、記録されたメッセージにアクセスする手段を用意する必要があります。 |
||
| − | Now we have to have a way to leave messages to this voice-mail, and a way to access it. |
||
| + | |||
| − | For this, we go back to the {{ic|extensions.conf}} and modify your existing entry as follows: |
||
| + | {{ic|extensions.conf}} に戻り、既存のエントリを次のように変更します: |
||
exten => 100,1,Dial(SIP/me1,20) |
exten => 100,1,Dial(SIP/me1,20) |
||
exten => 100,2,Voicemail(100@default) |
exten => 100,2,Voicemail(100@default) |
||
| + | 最初の 'exten' は 'Dial()' で20秒間電話を呼び出します。応答がない場合、default コンテキストの 100 番のボイスメールボックスに転送します。 |
||
| − | The 20 on the end of the first 'exten' tells 'Dial()' to call for 20 seconds. If no one answers it heads to voice-mail box 100 in the default context. |
||
| + | さらに以下のように設定することで実際にボイスメールにアクセスすることができます: |
||
| − | Next is actually accessing your voicemail. For this we add: |
||
exten => 600,1,VoiceMailMain,s100@default |
exten => 600,1,VoiceMailMain,s100@default |
||
| − | So when we call 600, the application 'VoiceMailMain' goes to 100 in the default context. The {{Ic|s}} allows for automatic login. |
||
| + | 600 番を呼び出すと、'VoiceMailMain' アプリケーションは default コンテキストの 100 番に行きます。{{Ic|s}} で自動ログインが許可されます。 |
||
| − | {{Note|The 'VoiceMail' applications have a significant amount of options, so it is suggested reading over some additional documentation. This is just for a basic, home use setup. Also note that it is generally a good idea to use extensions higher then your users extensions for accessing 'VoiceMail'. This way someone dialing 208 does not hit someone's voice-mail at 205.}} |
||
| + | {{Note|'VoiceMail' アプリケーションには多くのオプションがありますので、追加のドキュメントに目を通すことをお勧めします。これは、基本的な家庭用の設定です。 また、一般的に 'VoiceMail' にアクセスする際には、ユーザーの内線より高い内線を使用することをお勧めします。208 にダイヤルしても、205 のボイスメールにヒットしないようにするためです。}} |
||
| − | ===PSTN に接続=== |
||
| + | |||
| − | Now that you have the previous setup, it is time to actually connect to the outside world. To do this, you will need a provider such as [http://pstn.junctionnetworks.com/ Junction Networks]. Your provider should have instructions on connecting to asterisk, so this section is very general. |
||
| + | === PSTN に接続 === |
||
| + | |||
| + | ここまで設定できたら、次は外線と繋ぎましょう。[https://www.onsip.com/ OnSIP] などのプロバイダが必要です。asterisk に接続する手順がプロバイダによって用意されているかもしれないため、このセクションは共通のことだけ記述します。 |
||
| + | |||
| + | ==== 一般的なセットアップ ==== |
||
| + | |||
| + | ===== sip.conf ===== |
||
| − | ====一般的なセットアップ==== |
||
| − | =====sip.conf===== |
||
{{bc|1= |
{{bc|1= |
||
[general] |
[general] |
||
| 131行目: | 415行目: | ||
}} |
}} |
||
| + | * 発信(outbound)コンテキストでは、ダイアルした番号を全てサービスプロバイダに送信します。2 の 'whatever' は {{ic|sip.conf}} の設定と一致させる必要があります。 |
||
| − | *In the outbound context, any number dialed will be sent out to your service provider. The 'whatever' in the 2 priority should match what you have in your sip.conf. |
||
| + | * もちろん、着信(inbound)番号計画は、あなたが望むように変更することができます。例えば、{{Ic|Dial(SIP/me1)}}とすることで、誰かがあなたの番号に電話をかけると、あなたのコンピュータの SIP 電話に転送されるようにすることができます。それから、ボイスメールなどを追加します。 |
||
| − | *Of course, the inbound dial-plan can be modified to do what you want. For instance, you can have {{Ic|Dial(SIP/me1)}} so when someone calls your number they are routed to your SIP phone on your computer. Then add in voice-mail and so on. |
||
| − | =====iax.conf===== |
+ | ===== iax.conf ===== |
| − | The first step is to log into FWD and enable their side of IAX. It is under extra features, and keep in mind that the authors claim it takes a little while to activate. |
||
| + | まず、FWD にログインして、FWD 側の IAX を有効にします。これは extra features の下にあり、作者は有効化するのに少し時間がかかると主張しているのを覚えておいてください。 |
||
| − | Now edit your iax.conf with the following in the 'general' section: |
||
| + | |||
| + | そして {{ic|iax.conf}} の 'general' セクションを以下のように編集: |
||
{{bc|1= |
{{bc|1= |
||
register => FWDNUMBER:PASSWORD@iax2.fwdnet.net |
register => FWDNUMBER:PASSWORD@iax2.fwdnet.net |
||
| 144行目: | 429行目: | ||
}} |
}} |
||
| + | そして末尾に以下を追加: |
||
| − | And at the bottom add: |
||
{{bc|1= |
{{bc|1= |
||
[iaxfwd] |
[iaxfwd] |
||
| 153行目: | 438行目: | ||
}} |
}} |
||
| + | これにより、FWD からの呼び出しが許可されます。 |
||
| − | This allows calls from FWD. |
||
| − | =====extensions.conf===== |
+ | ===== extensions.conf ===== |
| + | |||
| − | Place this at the top under '[globals]': |
||
| + | '[globals]' の一番上に以下を記述: |
||
{{bc|1= |
{{bc|1= |
||
FWDNUMBER=MYFWDNUMBER ; your calling number |
FWDNUMBER=MYFWDNUMBER ; your calling number |
||
| 165行目: | 451行目: | ||
}} |
}} |
||
| + | 次に、これを発信用のコンテキストに追加します: |
||
| − | Next, add this to a context for outgoing: |
||
{{bc|1= |
{{bc|1= |
||
exten => _393.,1,SetCallerId,${FWDCIDNAME} |
exten => _393.,1,SetCallerId,${FWDCIDNAME} |
||
| 172行目: | 458行目: | ||
}} |
}} |
||
| + | 「393」は好きなように変更できます。これは、「転送」番号をダイヤルする前にダイヤルするものです。例えば、「744561」をダイヤルする場合は、「393744561」をダイヤルします。 |
||
| − | You can change the '393' to whatever you want. This is what you will dial before dialing a 'fwd' number. For instance, to dial '744561' you would dial '393744561'. |
||
| + | そして最後に、着信です。 |
||
| − | And lastly, the incoming calls: |
||
{{bc|1= |
{{bc|1= |
||
[fromiaxfwd] |
[fromiaxfwd] |
||
| 182行目: | 468行目: | ||
}} |
}} |
||
| + | {{Note|もし問題があれば、{{ic|extensions.conf}}から変数を削除してみてください。この手順は FWD のサイトからのもので、この記事の著者によってテストされたわけではありません。}} |
||
| − | {{Note|If you have problems try removing the variables from {{ic|extensions.conf}}. These instructions are from FWD's site and I have not been tested by this article's author.}} |
||
| + | |||
| + | 内線番号の 55555(有志のテスト回線)、514(会議)にかけてみてください。 |
||
| + | |||
| + | === 音声 === |
||
| − | Extensions to try calling are 55555 (a volunteer maned test line) and 514 (conference). |
||
| − | ===音声=== |
||
音声は {{ic|/var/lib/asterisk/xx}} フォルダに保存します。{{ic|xx}} は言語コードです。例えば英語なら "en" になります。新しい音声を追加したいときはこのフォルダにコピーしてください。以下のフォルダ構造を守って下さい: |
音声は {{ic|/var/lib/asterisk/xx}} フォルダに保存します。{{ic|xx}} は言語コードです。例えば英語なら "en" になります。新しい音声を追加したいときはこのフォルダにコピーしてください。以下のフォルダ構造を守って下さい: |
||
{{bc| |
{{bc| |
||
| 208行目: | 496行目: | ||
** ... |
** ... |
||
* [http://www.voip-info.org/wiki/view/Asterisk+sound+files+international voip-info.org] |
* [http://www.voip-info.org/wiki/view/Asterisk+sound+files+international voip-info.org] |
||
| + | |||
| − | ===MeetMe=== |
||
| + | === MeetMe === |
||
| + | |||
MeetMe は電話会議をできるようにするアプリケーションです。設定は簡単です。 |
MeetMe は電話会議をできるようにするアプリケーションです。設定は簡単です。 |
||
| 217行目: | 507行目: | ||
999 にダイアルすることで会議 1000 に入ることができます。{{Ic|<nowiki>|M</nowiki>}} を設定することで誰もいないときは保留音が鳴ります。誰かが会議に参加すると保留音は自動的に消えます。 |
999 にダイアルすることで会議 1000 に入ることができます。{{Ic|<nowiki>|M</nowiki>}} を設定することで誰もいないときは保留音が鳴ります。誰かが会議に参加すると保留音は自動的に消えます。 |
||
| + | {{Note|MeetMe を使うには zaptel パッケージが必要です。asterisk を起動する前にインストールして {{Ic|modprobe ztdummy}} を実行してください。それによって TDM が利用できるようになります。}} |
||
| − | {{Note|You ''must'' have the zaptel package in order for MeetMe to work. Install it and run {{Ic|modprobe ztdummy}} before running asterisk. This provides digium timing for us without cards so we can utilize TDM.}} |
||
| − | ==Asterisk コンソールとソフトフォン== |
+ | == Asterisk コンソールとソフトフォン == |
| + | |||
| − | Now lets get Asterisk going: |
||
| + | Asterisk を立ち上げてください: |
||
# asterisk -vvvvvvc |
# asterisk -vvvvvvc |
||
| + | |||
| − | This will give us the Asterisk CLI with verbose output. If Asterisk is already running you will need to use: |
||
| + | 詳細な出力がされる Asterisk CLI が立ち上がります。 |
||
| + | |||
| + | Asterisk が既に起動している場合、以下のコマンドを実行: |
||
# asterisk -r |
# asterisk -r |
||
| + | |||
| − | Now fire up your SIP clients and set them up with the information in the sip.conf. Switch back to your Asterisk CLI and you should see: |
||
| + | SIP クライアントを起動して {{ic|sip.conf}} の情報にあわせて設定してください。Asterisk CLI に戻って以下のように表示されることを確認: |
||
Registered SIP 'me1' at 192.168.0.142 port 5061 expires 60 |
Registered SIP 'me1' at 192.168.0.142 port 5061 expires 60 |
||
| − | + | これで {{Ic|me1}} から {{Ic|101}} にダイアルして {{Ic|me2}} と会話できるはずです。 |
|
| + | |||
| + | == トラブルシューティング == |
||
| − | ==トラブルシューティング== |
||
404 Not Found エラーが表示される場合は {{ic|extensions.conf}} とダイアルした電話番号を確認してください。 |
404 Not Found エラーが表示される場合は {{ic|extensions.conf}} とダイアルした電話番号を確認してください。 |
||
| + | |||
| + | {{TranslationStatus|Asterisk|2025-3-20|737751}} |
||
2025年3月20日 (木) 15:25時点における最新版
Asterisk は完全な PBX (構内交換機) ソフトウェアです。Linux, BSD, Windows, macOS などで動作し、PBX が通常備えている機能は全て含まれています。Asterisk は4つのプロトコルで Voice over IP を実現し、比較的安価なハードウェアでほぼ全ての規格の電話装置と一緒に使うことが可能です。
Asterisk はボイスメールサービス、電話帳、電話会議、自動音声応答、コールキューイングを実現します。また、三者通話、発信者番号通知サービス、ADSI、IAX、SIP、H.323 (クライアントとゲートウェイの両方)、MGCP (コールマネージャのみ)、SCCP/Skinny をサポートしています。
この記事では家庭ネットワークにおけるシンプルな設定を説明し、SIP ソフトフォンを使って LAN 上の他の SIP ソフトフォンと会話できるようにします。
目次
インストール
asteriskAUR パッケージをインストールしてください。Cisco の IP 電話を使用する場合はパッチが適用されている asterisk-ciscoAUR パッケージを使うことが推奨されます (https://issues.asterisk.org/jira/browse/ASTERISK-13145 を参照)。
あるいは、asterisk-lts-20AUR パッケージをインストールすると、長期サポートリリースを入手できます(現在の最新 LTS メジャーバージョンは Asterisk 20です)。Asterisk LTS リリースは機能が少ない傾向にありますが、ずっと長い間メンテナンスされます。すべての asterisk バージョンのリリースサイクルに関する完全な詳細については、Asterisk Versions ページを参照してください。
インストールしたら asterisk.service systemd サービスを有効化および起動してください。
SIP ソフトフォンと最低2つのマシンが必要です。SIP フォンとしては Blink (blinkAUR)、 Linphone (liblinphone-gitAUR) または X-Lite (xlite-binAUR) が推奨されます。
ilbc コーデックのサポートを有効にするには PKGBUILD の build セクションの冒頭に以下を追加してください:
cd ${srcdir}/${pkgname}-${pkgver}/contrib/scripts
echo | ./get_ilbc_source.sh
設定
Asterisk 20 から、従来の chan_sip モジュールはデフォルトでコンパイルされなくなりました。Asterisk 21 がリリースされると(2023年10月予定)、chan_sip は完全に削除されます(すでにマスターブランチから削除されています)。もし res_pjsip よりも chan_sip を使用したい場合は、asterisk-lts-18AUR をインストールしてください。これは、chan_sip をビルドした最後の LTS リリースでした。
res_pjsip は、より新しく、より高性能な Asterisk チャネルモジュールで、標準の SIP(Session Initiation Protocol)プロトコルをサポートしています。これは、多くのキャリア、電話会社、インターネット電話サービスプロバイダ(ITSP)、および企業で使用されている主要な VoIP(Voice over Internet Protocol)プロトコルです。ただし、res_pjsip は、古い chan_sip よりも設定がかなり複雑です。
広く受け入れられている Asterisk コミュニティの意見では、既存の設定がある場合に限り chan_sip を使用し、res_pjsip へのアップグレードも計画することを提案しています。新規インストールの場合は、res_pjsip が推奨されます。上記で述べたように、chan_sip はもはやメンテナンスされておらず、セキュリティ修正も(古い LTS リリースを除いて)行われないため、新しい Asterisk PBX 管理者は、サポートされている SIP チャネルドライバー(つまり、res_pjsip)を選択するべきです。
既存の chan_sip 設定がある場合、Asterisk 20 でビルドするには、次の手順を実行します:asteriskAUR の PKGBUILD を編集し、build() 関数内で次の行を変更します:
PKGBUILD
make MENUSELECT_CFLAGS= OPTIMIZE= DEBUG= ASTVARRUNDIR="/run/$pkgname" NOISY_BUILD=1
これを menuselect ツールをビルドする呼び出しでプレフィックスし、chan_sip を有効にします:
PKGBUILD
make menuselect.makeoptions && \ menuselect/menuselect --enable chan_sip && \ make MENUSELECT_CFLAGS= OPTIMIZE= DEBUG= ASTVARRUNDIR="/run/$pkgname" NOISY_BUILD=1
この手順は、asteriskAUR パッケージの更新ごとに行う必要がありますが、asteriskAUR が Asterisk 21 に移行すると、この手順は機能しなくなることに注意してください。
PJSIP
インストール後、Asterisk は res_pjsip 設定を /etc/asterisk/pjsip.conf に持っています。Asterisk に同梱されているサンプルファイルには、いくつかの基本的な例が含まれていますが、すべての pjsip オプションには網羅されていません。続行する前に、Asterisk Wiki Security best practices article と Configuring res_pjsip を読むことをお勧めします。
この記事には、基本的なシングル SIP 電話と複数の SIP トランクの例が含まれており、SIP Station SIP trunks, from Sangoma を使用しています。SIP Station の推奨に従って、2つの SIP トランクが冗長性のために SIP Station で設定されています。次の例は、Sangoma/Digium D60 ハードウェア電話を使用してテストされましたが、SIP 2.0 準拠のハードウェア電話またはソフトウェア電話でも十分です。
この例では、Asterisk PBX サーバーと SIP 電話がプライベートな IPv4 LAN 上にあり、NAT ルーターがサーバー/電話と WAN/インターネットの間にあると仮定しています。IPv6 を使用したい場合は、Configuring res_pjsip for IPv6 の記事をお読みください。
modules.conf
まず、res_pjsip.so が noload = でプレフィックスされていないことを確認してください。この例では、require = プレフィックスを使って、chan_pjsip.so のロードに失敗した場合に Asterisk がロードに失敗するようにしています。これは絶対に必要ではありませんが、res_pjsip がロードされない場合、Asterisk がロードされる意味がないかもしれません。
/etc/asterisk/modules.conf
;... require = chan_pjsip.so ;...
pjsip.conf
pjsip.conf の設定に取り掛かる前に、PJSIP Configuration Wizard を確認してください。これは、1つの SIP プロバイダー/ ITSP のみの簡単なユースケースに役立ち、pjsip オブジェクトの多くを自動的に処理します。
ファイル pjsip.conf は、ini 形式の設定ファイルで、[section-headers-in-square-brackets] と、ハッシュ(#)またはセミコロン(;)をコメント文字として使用します。セクションヘッダーの下の各行は key=value ペアで、セクション固有のキーを指定された値に設定します。セクションヘッダーには、閉じる角括弧の後に (!) を追加できることに注意してください。これは、セクションがテンプレートであり、後で pjsip.conf 内で使用することを示しています。以前に定義されたテンプレートを使用してセクションをインスタンス化するには、セクションヘッダーに (template-name) を追加してください。
transport セクション
Asterisk で使用する SIP トランクを定義するために、PJSIP にはネットワーク transport という概念があります。Asterisk Wiki によると、トランスポートセクションは res_pjsip がトランスポート層でどのように動作するかを設定します。例えば、TCP、UDP、WebSockets などのプロトコルや、TLS/SSL などの暗号化方式の設定オプションをサポートしています。
トランスポートセクションの名前は自由に設定できますが、その意味が分かりやすい名前にすることを推奨します。以下の例では、SIP に UDP を使用し、NAT デバイスを経由することを示すために、[transport-udp-nat] という名前を付けています。
/etc/asterisk/pjsip.conf
[transport-udp-nat] type=transport ; signifies this is a transport definition protocol=udp ; specifies this uses the UDP transport protocol ; this transport binds to all configured network interfaces, ; replace with the IP address of the desired interface. 0.0.0.0 means all interfaces bind=0.0.0.0 ; ===== NOTE, the following directives are OPTIONAL local_net=10.20.30.0/24 ; specify the networks that this Asterisk server should consider as local/LAN networks. Change this to the local LAN subnet (in CIDR notation) local_net=127.0.0.0/8 ; specify the networks that this Asterisk server should consider as local/LAN networks (this one sets it to the IPv4 loopback network) external_media_address=96.69.199.60 ; specify the external/WAN IP address for RDP media (audio) external_signaling_address=96.69.199.60 ; specify the external/WAN IP address for SIP (signaling)
1 つの IP アドレス/ポート、または IP アドレス/プロトコルの組み合わせにつき、使用できるトランスポートは 1 つだけであることに注意してください。
複数のトランスポートプロトコル(例: TCP と UDP の両方)を設定したい場合は、それぞれのプロトコルを異なる IP アドレスにバインドする必要があります。同様に、同じプロトコルで複数のトランスポートを定義したい場合は、それぞれのトランスポート定義で異なるポートを使用する必要があります。
registration セクション
次に、SIP トランクが使用する登録を定義します。SIP ステーションの登録は、まずテンプレートを使用して定義されることに注意してください(セクション名の末尾に (!) を付けます)
各テンプレートは、そのテンプレートを使用する各セクションに共通の設定を定義し、各セクション自体には、そのセクション専用のオプションのみを設定します。
/etc/asterisk/pjsip.conf
[sipstation-reg](!) type=registration transport=transport-udp-nat contact_user=15055551234 retry_interval=60 ; ==== ... several other templates and sections will appear here ; ==== including the authentication sections, etc., which are also used by the registration ; ==== .... [siptsation-reg1](sipstation-reg) outbound_auth=sipstation-auth1 server_uri=sip:trunk1.freepbx.com ; trunk1 provided by SIP Station client_uri=sip:my_username@trunk1.freepbx.com [siptsation-reg2](sipstation-reg) outbound_auth=sipstation-auth2 server_uri=sip:trunk2.freepbx.com ; trunk2 provided by SIP Station client_uri=sip:my_username@trunk2.freepbx.com
authentication セクション
ここでは、認証テンプレートと、SIP ステーショントランクで使用する特定の認証セクションを定義します。
/etc/asterisk/pjsip.conf
[sipstation-auth](!) type=auth password=Super*Secret@Password! username=my_username ; ==== ... more templates may appear here [sipstation-auth1](sipstation-auth) realm=trunk1.freepbx.com [sipstation-auth2](sipstation-auth) realm=trunk2.freepbx.com
endpoint セクション
エンドポイントは、電話機やリモートサーバーなどの SIP デバイスの設定プロファイルのようなものです。 ここでは、トランスポートの設定、エンドポイントから発信された通話が処理される Asterisk ダイヤルプランのコンテキスト、およびエンドポイントで使用可能なオーディオコーデックを定義します。 SIP ステーショントランクの場合、次の設定を定義します:
/etc/asterisk/pjsip.conf
[sipstation-endpoint](!) type=endpoint transport=transport-udp-nat context=from-external ; Dialplan context, defined in extensions.conf or related file disallow=all ; disallows all codecs, including default ones, unless explicitly allowed below allow=ulaw ; standard G.711, uncompressed PCM codec. Uses the most bandwidth allow=gsm ; another standard, compressed codec. Uses less bandwidth than ulaw ; other codecs are available, and have different attributes. Some require paid licenses to use. aors=sipstation-aors ; AOR - Address of Record, to be defined later ;direct_media=no ; setting this may not allow audio to pass through NAT direct_media=yes rtp_symmetric=yes ; ==== ... more template definitions [sipstation-endpoint1](sipstation-endpoint) outbound_auth=sipstation-auth1 from_domain=trunk1.freepbx.com [sipstation-endpoint2](sipstation-endpoint) outbound_auth=sipstation-auth2 from_domain=trunk2.freepbx.com
identify セクション
res_pjsip_endpoint_identifier_ip モジュールが、受信パケットがどのエンドポイントからのものかを判断する方法を制御します、SIP ステーショントランクの場合、次の設定を定義します:
/etc/asterisk/pjsip.conf
[sipstation-identify](!) type=identify ; this is the LAN IP address of the NAT router, which calls from the SIP Station ; trunks may appear to come from (because of NAT). match=10.20.30.254/32 [sipstation-id1](sipstation-identify) endpoint=sipstation-endpoint1 match=192.159.66.3 ; IP address of trunk1.freepbx.com [sipstation-id2](sipstation-identify) endpoint=sipstation-endpoint2 match=162.253.134.142 ; IP address of trunk2.freepbx.com
AOR (Address Of Record) セクション
AOR オブジェクト (Address of Record) の主な機能は、Asterisk にエンドポイントの連絡先を知らせることです。 AOR セクションが関連付けられていないと、エンドポイントに接続できません。 SIP ステーショントランクの場合、次の設定を定義します:
/etc/asterisk/pjsip.conf
[sipstation-aors] type=aor contact=sip:trunk1.freepbx.com contact=sip:trunk2.freepbx.com
phone セクション
最後に、Asterisk に登録する SIP 電話のために必要なセクションを定義します。これは、SIP ステーショントランクと似たような複数のセクションがあります。複数のローカル SIP 電話が Asterisk PBX に登録する予定の場合は、これらをテンプレートで拡張してください。 リモート電話 (WAN/インターネットからのもの)も設定できますが、それはこの例の範囲外です。
/etc/asterisk/pjsip.conf
[home-phone] type=endpoint transport=transport-udp-nat context=from-internal ; Dialplan context that gets executed when a user dials from this phone disallow=all allow=ulaw allow=gsm auth=home-phone-auth aors=home-phone [home-phone-auth] type=auth auth_type=userpass password=MyPhonePa$$word0 username=home-phone [home-phone] type=aor max_contacts=1
PJSIP の管理
Asterisk CLI では、res_pjsip に関するいくつかのコマンドが利用可能で、すべて pjsip コマンドでプレフィックスが付けられています。Asterisk CLI にアクセスするには、以下のコマンドを asterisk ユーザーとして入力します:
$ asterisk -rvvv
これは、Asterisk がすでに実行中であることを前提としています(例:systemd サービスユニット経由)Asterisk CLI に入ると、プロンプトが hostname*CLI> と表示されます。利用可能な PJSIP コマンドのリストを表示するには、help pjsip と入力します。
PJSIP の登録リストを表示するには、以下のコマンドを入力します:
hostname*CLI> pjsip show registrations
<Registration/ServerURI..............................> <Auth....................> <Status.......> --------------------------------------------------------------------------------------------- siptsation-reg1/sip:trunk1.freepbx.com sipstation-auth1 Registered (exp. 2062s) siptsation-reg2/sip:trunk2.freepbx.com sipstation-auth2 Registered (exp. 2069s) Objects found: 2
PJSIP エンドポイントのリストを表示するには、次のように入力します:
hostname*CLI> pjsip show endpoints
Endpoint: <Endpoint/CID.....................................> <State.....> <Channels.>
I/OAuth: <AuthId/UserName...........................................................>
Aor: <Aor............................................> <MaxContact>
Contact: <Aor/ContactUri..........................> <Hash....> <Status> <RTT(ms)..>
Transport: <TransportId........> <Type> <cos> <tos> <BindAddress..................>
Identify: <Identify/Endpoint.........................................................>
Match: <criteria.........................>
Channel: <ChannelId......................................> <State.....> <Time.....>
Exten: <DialedExten...........> CLCID: <ConnectedLineCID.......>
----------------------------------------------------------------------------------------------
Endpoint: home-phone Not in use 0 of inf
InAuth: home-phone-auth/home-phone
Aor: home-phone 1
Contact: home-phone/sip:home-phone@10.20.30.229:506 f91928f561 NonQual nan
Transport: transport-udp-nat udp 0 0 0.0.0.0:5060
Endpoint: sipstation-endpoint1 Not in use 0 of inf
OutAuth: sipstation-auth1/mw3FSBsPPjQ7
Aor: sipstation-aors 0
Contact: sipstation-aors/sip:trunk1.freepbx.com 256c242e36 NonQual nan
Contact: sipstation-aors/sip:trunk2.freepbx.com c07c6c7180 NonQual nan
Transport: transport-udp-nat udp 0 0 0.0.0.0:5060
Identify: sipstation-id1/sipstation-endpoint1
Match: 10.20.30.254/32
Match: 192.159.66.3/32
Endpoint: sipstation-endpoint2 Not in use 0 of inf
OutAuth: sipstation-auth2/mw3FSBsPPjQ7
Aor: sipstation-aors 0
Contact: sipstation-aors/sip:trunk1.freepbx.com 256c242e36 NonQual nan
Contact: sipstation-aors/sip:trunk2.freepbx.com c07c6c7180 NonQual nan
Transport: transport-udp-nat udp 0 0 0.0.0.0:5060
Identify: sipstation-id2/sipstation-endpoint2
Match: 10.20.30.254/32
Match: 162.253.134.142/32
Objects found: 3
chan_sip
asterisk サーバーを動かしたら、後は2つのファイルを編集すれば設定できます: sip.conf と extensions.conf。asterisk の設定ディレクトリ (/etc/asterisk) に移動して、sip.conf を編集して以下を記述してください:
[me1] type=friend username=me1 secret=PASSWORD host=dynamic context=house [me2] type=friend username=me2 secret=PASSWORD host=dynamic context=house
これで house コンテキストに二人の SIP ユーザー me1 と me2 が作成されます。パスワードは PASSWORD です。
次にコンテキストを定義します。extensions.conf を以下のように編集:
[house] exten => 100,1,Dial(SIP/me1) exten => 101,1,Dial(SIP/me2)
これでコンテキスト house が作成され SIP ユーザー me1 にエクステンション 100 が、SIP ユーザー me2 にエクステンション 101 が割り当てられます。後は実際に動作するか確認するだけです。
保留音
保留音はとても楽しい機能です。簡単に設定することができます。/etc/asterisk/musiconhold.conf を編集して以下を追加してください:
[default] mode=files directory=mohmp3
後は合法的に入手したお気に入りの MP3 を /var/lib/asterisk/mohmp3 にコピーしてください。
ボイスメール
Asterisk にはボイスメール機能が存在します。設定する方法は多数ありますが、この記事ではシンプルな設定方法だけを紹介します。
voicemail.conf を作成・編集:
[general] format=gsm|wav49|wav serveremail=asterisk attach=no mailcmd=/usr/sbin/sendmail -t maxmessage=180 maxgreet=60 [default] 100 => 1234,Me,me@mydomain.com
[general] の設定の内容は こちら を見て下さい。Postfix が正しくセットアップされていれば PBX からメールの通知がユーザーに送信され、attach=yes と定義されている場合、メールに音声ファイルが添付されます。
次にメールボックスの設定です。フォーマットは:
mailbox => password,user,email
上記の場合、'Me' というユーザー名でメールアドレスが me@mydomain.com、パスワードが 1234 のメールボックス 100 が設定されます。
それから、ボイスメールボックスにメッセージを残す方法と、記録されたメッセージにアクセスする手段を用意する必要があります。
extensions.conf に戻り、既存のエントリを次のように変更します:
exten => 100,1,Dial(SIP/me1,20) exten => 100,2,Voicemail(100@default)
最初の 'exten' は 'Dial()' で20秒間電話を呼び出します。応答がない場合、default コンテキストの 100 番のボイスメールボックスに転送します。
さらに以下のように設定することで実際にボイスメールにアクセスすることができます:
exten => 600,1,VoiceMailMain,s100@default
600 番を呼び出すと、'VoiceMailMain' アプリケーションは default コンテキストの 100 番に行きます。s で自動ログインが許可されます。
PSTN に接続
ここまで設定できたら、次は外線と繋ぎましょう。OnSIP などのプロバイダが必要です。asterisk に接続する手順がプロバイダによって用意されているかもしれないため、このセクションは共通のことだけ記述します。
一般的なセットアップ
sip.conf
[general] register => username:password@sip.specific.com [whatever] fromdomain=specific.com host=sip.specific.com insecure=very ; check with provider username=usernameduh secret=passwordduh type=peer
extensions.conf
[outboundwithCID] ; this can be whatever
exten => _1NXXNXXXXXX,1,SetCIDNum(15555551234)
exten => _1NXXNXXXXXX,2,Dial(SIP/${EXTEN}@whatever)
exten => _1NXXNXXXXXX,3,Congestion()
exten => _1NXXNXXXXXX,103,Busy()
[default] ; This should be set in your sip.conf for incoming calls
;These should to be changed to your actual number
; ie 15555555555
exten => 1NXXNXXXXXX,1,Answer()
exten => 1NXXNXXXXXX,2,Playback(ttt-weasels)
exten => 1NXXNXXXXXX,3,HangUp()
- 発信(outbound)コンテキストでは、ダイアルした番号を全てサービスプロバイダに送信します。2 の 'whatever' は
sip.confの設定と一致させる必要があります。 - もちろん、着信(inbound)番号計画は、あなたが望むように変更することができます。例えば、
Dial(SIP/me1)とすることで、誰かがあなたの番号に電話をかけると、あなたのコンピュータの SIP 電話に転送されるようにすることができます。それから、ボイスメールなどを追加します。
iax.conf
まず、FWD にログインして、FWD 側の IAX を有効にします。これは extra features の下にあり、作者は有効化するのに少し時間がかかると主張しているのを覚えておいてください。
そして iax.conf の 'general' セクションを以下のように編集:
register => FWDNUMBER:PASSWORD@iax2.fwdnet.net disallow = all allow = ulaw
そして末尾に以下を追加:
[iaxfwd] type=user context=fromiaxfwd auth=rsa inkeys=freeworlddialup
これにより、FWD からの呼び出しが許可されます。
extensions.conf
'[globals]' の一番上に以下を記述:
FWDNUMBER=MYFWDNUMBER ; your calling number FWDCIDNAME="MyName"; your caller id FWDPASSWORD=MYFWDPASSWORD ; your password FWDRINGS=sip/office ; the phone to ring FWDVMBOX=1000 ; the VM box for this user
次に、これを発信用のコンテキストに追加します:
exten => _393.,1,SetCallerId,${FWDCIDNAME}
exten => _393.,2,Dial(IAX2/${FWDNUMBER}:${FWDPASSWORD}@iax2.fwdnet.net/${EXTEN:3},60,r)
exten => _393.,3,Congestion
「393」は好きなように変更できます。これは、「転送」番号をダイヤルする前にダイヤルするものです。例えば、「744561」をダイヤルする場合は、「393744561」をダイヤルします。
そして最後に、着信です。
[fromiaxfwd]
exten => ${FWDNUMBER},1,Dial(${FWDRINGS},20,r)
exten => ${FWDNUMBER},2,Voicemail,u${FWDVMBOX}
exten => ${FWDNUMBER},102,Voicemail,b${FWDVMBOX}
内線番号の 55555(有志のテスト回線)、514(会議)にかけてみてください。
音声
音声は /var/lib/asterisk/xx フォルダに保存します。xx は言語コードです。例えば英語なら "en" になります。新しい音声を追加したいときはこのフォルダにコピーしてください。以下のフォルダ構造を守って下さい:
/var/lib/asterisk/sounds/xx /var/lib/asterisk/sounds/xx/digits /var/lib/asterisk/sounds/xx/letters /var/lib/asterisk/sounds/xx/phonetic
sip.conf の language パラメータを編集してください:
[general] ... language=en ...
音声が入手できる場所:
- http://downloads.asterisk.org/pub/telephony/sounds/
- https://packages.debian.org/wheezy/all/asterisk-prompt-xx
- voip-info.org
MeetMe
MeetMe は電話会議をできるようにするアプリケーションです。設定は簡単です。
meetme.conf を編集:
conf => 1000
extensions.conf を編集:
exten => 999,1,MeetMe(1000|M)
999 にダイアルすることで会議 1000 に入ることができます。|M を設定することで誰もいないときは保留音が鳴ります。誰かが会議に参加すると保留音は自動的に消えます。
Asterisk コンソールとソフトフォン
Asterisk を立ち上げてください:
# asterisk -vvvvvvc
詳細な出力がされる Asterisk CLI が立ち上がります。
Asterisk が既に起動している場合、以下のコマンドを実行:
# asterisk -r
SIP クライアントを起動して sip.conf の情報にあわせて設定してください。Asterisk CLI に戻って以下のように表示されることを確認:
Registered SIP 'me1' at 192.168.0.142 port 5061 expires 60
これで me1 から 101 にダイアルして me2 と会話できるはずです。
トラブルシューティング
404 Not Found エラーが表示される場合は extensions.conf とダイアルした電話番号を確認してください。