【Asterisk/FreePBX】手持ちのiPhoneを2台つかってIP電話内線網の試作

こんにちは。

かなり久しぶりの投稿です。今回はIP電話のお話です。

今の所、ただ単にIP電話の内線網を作ってみたかっただけなので、自宅の電話をAsteriskで受けるなんてのは考えていません。

もちろん、外に向けて公開もしません。(SIPサーバーはめっちゃ攻撃されるらしい)

あくまで試作なので、セキュリティとかは考えていません。

主、IP電話界隈に触れるのは初めてですので、何か間違っていたりしたらコメントで指摘してくれるとありがたいです。

構成

今回の構成です。

サーバー側

・Ubuntu Server 22.04.2

 (自宅鯖のProxmox VE上のVM)

・Asterisk 18

クライアント側

・iPhone 14 (内線番号6001)

・iPhone 8 (内線番号6002)

・MacBook Air (内線番号6003)

SIPクライアントには「Zoiper」を使用します。

VM上にUbuntu Serverをインスコ

Proxmox VEにVMとしてUbuntu Serverを入れます。入れ方は探せばいくらでも出てくると思うので割愛

Asteriskをインスコ

インスコの前に儀式を執り行います。

sudo apt update && sudo apt upgrade -y

そしたら次に

sudo apt install asterisk -y

でAsteriskをインストールします。

asterisk@asterisk:~$ sudo asterisk -r
Asterisk 18.10.0~dfsg+~cs6.10.40431411-2, Copyright (C) 1999 - 2021, Sangoma Technologies Corporation and others.
Created by Mark Spencer <[email protected]>
Asterisk comes with ABSOLUTELY NO WARRANTY; type 'core show warranty' for details.
This is free software, with components licensed under the GNU General Public
License version 2 and other licenses; you are welcome to redistribute it under
certain conditions. Type 'core show license' for details.
=========================================================================
Connected to Asterisk 18.10.0~dfsg+~cs6.10.40431411-2 currently running on atrerisk (pid = 21421)
atrerisk*CLI> version
No such command 'version' (type 'core show help version' for other possible commands)
atrerisk*CLI> 

これでよし。

Asterisk設定ファイルの書き込み

/etc/asterisk/

の中に「pjsip.conf」「extensions.conf」があります。それらを編集します

(参考: https://qiita.com/xecus/items/3f816e9fa0b31e9f3c2b )

pjsip.conf

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

[6001]
type=endpoint
context=from-internal
disallow=all
allow=ulaw
auth=6001
aors=6001
rewrite_contact = yes
callerid=iPhone14 <6001>

[6001]
type=auth
auth_type=userpass
password=パスワード
username=6001

[6001]
type=aor
max_contacts=10

[6002]
type=endpoint
context=from-internal
disallow=all
allow=ulaw
auth=6002
aors=6002
rewrite_contact = yes
callerid=iPhone8 <6002>

[6002]
type=auth
auth_type=userpass
password=パスワード
username=6002

[6002]
type=aor
max_contacts=10

[6003]
type=endpoint
context=from-internal
disallow=all
allow=ulaw
auth=6003
aors=6003
rewrite_contact = yes
callerid=MacBook-Master <6003>

[6003]
type=auth
auth_type=userpass
password=パスワード
username=6003

[6003]
type=aor
max_contacts=10

これでエンドポイントの定義?ができました。

また、相手の着信時に電話番号ではなく自分の名前を表示させたい場合は

callerid=表示させたい名前 <内線番号>

で設定ができるそうです。

まだこれだけでは内線通話できません。

今度は「番号が呼び出されたら、どんな挙動をするのか」を記述していきます。

extensions.conf

[from-internal]

exten = 100,1,Answer()
same = n,Wait(1)
same = n,Playback(hello-world)
same = n,Hangup()

# 内線番号6001にかけると内線番号6001が着信
exten = 6001,1,Dial(PJSIP/6001,30,r)
same = n.Hangup()

# 内線番号6002にかけると内線番号6002が着信
exten = 6002,1,Dial(PJSIP/6002,30,r)
same = n.Hangup()

# 内線番号6003にかけると内線番号6003が着信
exten = 6003,1,Dial(PJSIP/6003,30,r)
same = n.Hangup()

Dial()の中身ですが、以下の構文だそうです。

Dial(PJSIP/かける先の内線番号(電話番号の表現が正しい?),タイムアウトまでの時間,明示的に鳴動させるか)

一応、これで設定はできました。

Zoiperで内線通話してみる

iPhone14(内線番号6001)でiPhone8(内線番号6002)を呼び出してみると、、、

↓この通り、iPhone8で「iPhone14」としっかり表示されて着信しています。

まとめ

・Ubuntu ServerとAsteriskでIp電話の内線網を作成することができた

・pjsip.confでcallerid=任意の名前 <内線番号>でディスプレイ表示を変更することができた

・Zoiperで相互で発着信及び内線通話ができた。

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です