1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

ラズパイ+Asterisk+黒電話(HT812)で内線通話を構築する

1
Last updated at Posted at 2026-03-27

ラズパイ+Asterisk+黒電話+HT812 で内線通話を構築する

自宅LAN内で、以下の構成を構築しました。

  • Raspberry Pi(Asterisk)
  • Grandstream HT812(黒電話接続)
  • Zoiper(スマホ: iPhoneアプリ)

黒電話 ⇔ スマホ で通話可能。当然通話料も無料。


構成イメージ

[黒電話] ─ HT812  ──┐
                   ├─ LAN ─ Raspberry Pi Zero 2 W(Asterisk)
[Zoiper (iPhone)] ─┘

黒電話:自宅にあったもの
HT812:Amazonで買いました。
Raspberry Pi Zero 2 W:秋月電子で買ったもの。ルーターで固定IPとなるように設定。

LANルーターの設定も必要です


① ラズパイ設定(Asterisk)

■ 依存ライブラリ

sudo apt update
sudo apt install build-essential libxml2-dev libncurses-dev uuid-dev libjansson-dev libsqlite3-dev libedit-dev -y

■ ダウンロード & ビルド

cd /usr/src
sudo wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-20-current.tar.gz
sudo tar xvf asterisk-20-current.tar.gz
cd asterisk-20.*

sudo ./configure
sudo make -j2   # Pi Zero 2 は軽め推奨
sudo make install

※ メモリ不足の場合は swap 追加

sudo fallocate -l 1G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile

■ 起動

sudo asterisk
sudo asterisk -rvvv

通信状況も見えるようになる。

終了は:

exit

■ (再起動)

sudo systemctl restart asterisk

■ PJSIP設定(/etc/asterisk/pjsip.conf)

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

; -------- 1001(黒電話) --------
[1001]
type=endpoint
context=internal
disallow=all
allow=ulaw
auth=1001-auth
aors=1001

[1001-auth]
type=auth
auth_type=userpass
username=1001
password=1001

[1001]
type=aor
max_contacts=1
remove_existing=yes

; -------- 1002(Zoiper) --------
[1002]
type=endpoint
context=internal
disallow=all
allow=ulaw
auth=1002-auth
aors=1002

[1002-auth]
type=auth
auth_type=userpass
username=1002
password=1002

[1002]
type=aor
max_contacts=1
remove_existing=yes

■ 内線設定(/etc/asterisk/extensions.conf)

[internal]
exten => 1001,1,Dial(PJSIP/1001)
exten => 1002,1,Dial(PJSIP/1002)

■ 再起動

sudo systemctl restart asterisk

■ 確認

pjsip show endpoints

Reachable になればOK


② HT812 設定(黒電話)

■ ファームウェア更新

  • Grandstream公式から最新FW
  • Web画面 → Upgrade

BASIC SETTINGS

Time Zone: GMT+09:00

ADVANCED SETTINGS

日本の電話らしい音にする設定

System Ring Cadence: c=1000/2000;
Dial Tone: f1=400@-19,c=0/0;
Ringback Tone: f1=400@-19,f2=385@-20,c=1000/2000;
Busy Tone: f1=400@-19,c=500/500;
Reorder Tone: f1=480@-19,f2=620@-19,c=1500/1500;
Confirmation Tone: f1=600@-16,c=250/250;
Call Waiting Tone: f1=440@-13,c=300/10000;
Prompt Tone: f1=350@-17,f2=440@-17,c=0/0;

時刻設定

NTP Server: ntp.nict.jp


■ Profile 1 設定

項目 設定
Primary SIP Server ラズパイIP(例: 192.168.3.102)
SIP Transport UDP
SIP Registration Yes

■ FXS Port(黒電話)

項目 設定
SIP User ID 1001
Authenticate ID 1001
Password 1001
Enable Port Yes

今回のハマりポイント

❌ Offhook Auto-Dial

Set Offhook Auto-Dial: No

これが ON だと勝手に発信されるので、つながらない


■ 日本向け設定

  • Ring Frequency: 20Hz (16Hz のほうがよいらしいが)
  • Impedance: 600Ω or default
  • Pulse Dialing: 有効(黒電話の場合)

■ コーデック

優先順:

PCMU(u-law)を最優先

③ Zoiper 設定(iPhone)

■ アカウント

項目 設定
ユーザー名 1002
パスワード 1002
ホスト ラズパイIP

※「アカウント名」は任意(未設定でもOK)


■ 重要ポイント

Zoiper でデフォルトでセットされている不要な機能をOFFにする

設定 理由
STUN LAN内では不要
IPv6 不要
ICE 不要

これに気づかなくてハマった


■ コーデック

ONにする:

  • u-law
  • a-law(予備)

OFFにする:

  • Opus(最初は切るのが無難)

④ 動作確認

■ 登録確認

pjsip show endpoints

■ テスト

  • Zoiper → 1001 → 黒電話鳴る ✔
  • 黒電話 → 1002 → Zoiper鳴る ✔

よくあるトラブル

■ Request Timeout (408)

SIPサーバIP or ネットワーク を確認する。


■ 音声片方向

コーデック or RTP設定 を確認する。


■ 番号がおかしい(例: 1002 → 1111)

Offhook Auto-Dial が原因
→黒電話からZoiperに電話できなかった


■ REGISTER失敗

auth / password 不一致


まとめ

この構成で:

  • レガシー(黒電話)
  • SIP(VoIP)
  • PBX(Asterisk)

全部つながる


ChatGPT に聞きながらやりましたが、一筋縄ではいきませんでした。
電話の仕組みがよく理解できました。

以上です。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?