スポンサーリンク

asterisk直収するテスト

NVR510使っているのももったいないので、asteriskで直収できるかの実験記録

手順

パッケージなかったので適当にasterisk 18.26.4を拾ってきてビルド。 ファイルとビルド手順は次の公式ページを見て作業

インストールしたら systemctl enable asterisk && systemctl start asterisk で起動。

ひかり電話の接続先は、前にテストしたdhclientで取得するか、NVR510とかで接続先は確認する。
手元にはNVR510が有るので、そっちの show status dhcpc とかして拾って入れ替え。

設定

/etc/hosts

118.177.*.* ntt-east.ne.jp # 取得したSIPドメイン

取得したデータをもとにasteriskを設定。

pjsip.conf

[global]
type = global
debug = no

[system]
type = system
disable_rport = yes ;via headerにrportが入らないよう必須

[acl]
type=acl
deny=0.0.0.0/0.0.0.0
permit=192.168.0.0/16
permit=118.177.0.0/16

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

[reg_HIKARI-DENWA]
type = registration
contact_user = 03******** ;電話番号
transport = transport-udp
client_uri = sip:03********@ntt-east.ne.jp ; 電話番号@SIPドメイン
server_uri = sip:ntt-east.ne.jp

[HIKARI-DENWA]
type = aor
contact = sip:118.177.*.* ; SIPサーバ
qualify_frequency = 60

[HIKARI-DENWA]
type = identify
endpoint = HIKARI-DENWA
match = 118.177.*.* ; SIPサーバ

[HIKARI-DENWA]
type = endpoint
context = incoming ;extension.confで使うやつ
disallow = all
allow = ulaw
rtp_symmetric = no ;via headerにrportが入らないよう必須
force_rport = no ;via headerにrportが入らないよう必須
rewrite_contact = no ;via headerにrportが入らないよう必須
direct_media = no ;RTPをAsteriskで中継するため必要
from_domain = ntt-east.ne.jp ;SIPドメイン
aors = HIKARI-DENWA

[101]
type=auth
password=101
username=101

[101]
type=aor
max_contacts=1

[101]
type=endpoint
context=default
transport=transport-udp
aors=101
auth=101
disallow=all
allow=ulaw

[102]
type=auth
password=102
username=102

[102]
type=aor
max_contacts=1

[102]
type=endpoint
context=default
transport=transport-udp
aors=102
auth=102
disallow=all
allow=ulaw

extensions.conf

[globals]
HIKARI_PEER=HIKARI-DENWA
USEVOICEMAIL=NO
HIKARIDENWA=03********
PHONEALL=PJSIP/101

[default]
include => demo

exten => 101,1,Dial(PJSIP/101)
exten => 101,n,Hangup

exten => 600,1,Playback(demo-echotest)      ; Let them know what's going on
same => n,Echo()                            ; Do the echo test
same => n,Playback(demo-echodone)           ; Let them know it's over
same => n,Goto(s,6)                         ; Start over

exten => _X.,1,Dial(PJSIP/${EXTEN}@HIKARI-DENWA)
exten => _X.,n,Hangup

[incoming]
exten => ${HIKARIDENWA},1,Noop("${CALLERID(name)}" "${CALLERID(num)}")
same => n(call),Set(CIDNAME = ${DB(cidname/${CALLERID(num)})})
same => n,Set(CALLERID(name) = ${IF($["${CIDNAME}" = ""]?UNKNOWN:${CIDNAME})})
same => n,Wait(1)
same => n,Dial(PJSIP/101&PJSIP/102)
same => n,Answer()
same => n,Congestion()
same => n,Busy()
same => n,Hangup()

exten => _X.,1,Set(free_dial="0120")
exten => _X.,2,Set(free_call="0800")
exten => _X.,3,GotoIf($["${CALLERID(num)}"="anonymous"]?99:4)
exten => _X.,4,GotoIf($[${CALLERID(num)}:${free_dial}]?99:5)
exten => _X.,5,GotoIf($[${CALLERID(num)}:${free_call}]?99:6)
exten => _X.,6,Dial(${PHONEALL})
exten => _X.,99,Answer()
exten => _X.,n,Hangup

indications.conf

[general]
country=jp ; default location

設定後ちゃんとレジストできているか確認 asterisk -r でコンソールに入る

*CLI>pjsip show registrations
<Registration/ServerURI..............................> <Auth....................> <Status.......>
==========================================================================================
reg_HIKARI-DENWA/sip:ntt-east.ne.jp                    n/a                        Registered (exp. 644s)

Objects found: 1

Unregisterdで時間かかる場合もあるみたいで、ちょっと待つとRegisterdになっていた

電話機

手元にはHT813があるのでコレを使う。
FXSのタブで
Account Active: yes
Primary Server, SIP User ID, Authenticate ID, SIP Registration:yes を設定して、
FXSのポートに電話機をつなぐ。 発着テストは携帯から適当にやって問題なければ完了。

放置しすぎのasterisk13更新前にテストしてみただけですが、10年前と違ってもう色々と情報有るので、ほぼ詰まらずに接続できちゃいますね。

参考

NTT光ネクストのひかり電話へAsteriskを直接接続する – Qiita

Asterisk+RTXでひかり電話直収のはなし|Takao Takahashi

コメント

タイトルとURLをコピーしました