「利用者:Pin ptr」の版間の差分

提供: VoIP-Info.jp
移動先: 案内検索
116行目: 116行目:
 
xxx.xxx.xxx.x:5060                      N      0xxxxxxxxx@n      3585 Registered          Tue, 04 Apr 2017 04:55:15
 
xxx.xxx.xxx.x:5060                      N      0xxxxxxxxx@n      3585 Registered          Tue, 04 Apr 2017 04:55:15
 
1 SIP registrations.</nowiki>
 
1 SIP registrations.</nowiki>
 +
 +
== IPv6 ==
 +
 +
client-idは -D LL を指定してdhclientを起動していればいらないと思いきや、うっかりleaseファイルからDUID-LLTを読んでしまうと困るので書いておく。
 +
 +
* dhclient.conf
 +
 +
<nowiki>
 +
option space my-vsio code width 4 length width 2 hash size 3;
 +
option my-vsio.ntt6 code 210 = string;
 +
option dhcp6.my-vendor-opts code 16 = encapsulate my-vsio;
 +
 +
option space ntt6 code width 2 length width 2 hash size 7;
 +
option ntt6.mac      code 201 = string;
 +
option ntt6.number  code 202 = text;
 +
option ntt6.domain  code 204 = domain-list;
 +
option ntt6.firmware code 210 = domain-list;
 +
option vsio.ntt6 code 210 = encapsulate ntt6;
 +
 +
interface "eth0" {
 +
  send dhcp-client-identifier = hardware;
 +
  request subnet-mask, routers, ip-sip-servers, rfc3442-classless-static-routes, vivso;
 +
  send vendor-class.ntt = concat(06, suffix(hardware, 6));
 +
 +
  send dhcp6.client-id = concat(00:03:00, hardware);
 +
  also request dhcp6.name-servers, dhcp6.domain-search, dhcp6.sntp-servers, dhcp6.sip-servers-addresses, dhcp6.vendor-opts;
 +
  send my-vsio.ntt6 = suffix(hardware, 6);
 +
}</nowiki>
 +
 +
* /etc/network/interfaces
 +
<nowiki>
 +
iface eth0 inet6 manual
 +
    #(ip -6 address show dev eth0 の結果がtentativeでなくなるのを待って)
 +
    #(NGNの経路を足して)
 +
    up /sbin/dhclient -1 -6 -P -D LL -pf /run/dhclient6.eth0.pid -lf /var/lib/dhcp/dhclient6.eth0.leases -I -df /var/lib/dhcp/dhclient.eth0.leases eth0
 +
    pre-down /sbin/dhclient -r -pf /run/dhclient6.eth0.pid eth0
 +
</nowiki>
 +
 +
うまくいくと /var/lib/dhcp/dhclient6.eth0.leases にIPv4のものと同等の情報が入る。

2017年5月1日 (月) 00:02時点における版

直収

Ubuntuでひかり電話を直収するのに試したことメモ。

接続

壁| -- |VDSLモデム| -- |Raspberry Pi3| -- |KX-UT123N|

DHCP

Ubuntu 16.04 Serverのisc-dhcp-clientにはclassless-static-routeのサポートが入っている。 また、dhclient.confで新たなオプションを定義できるので、再コンパイルせずに使う。

  • /etc/network/interface
auto eth0
iface eth0 inet dhcp
  • /etc/dhcp/dhclient.conf
# 既存の dhclient.conf に追加する
option ip-sip-servers code 120 = { boolean, array of ip-address };

option vendor-class.ntt  code 210 = string;

option space ntt code width 1 length width 1 hash size 3;
option ntt.mac      code 201 = string;
option ntt.number   code 202 = text;
option ntt.domain   code 204 = domain-list;
option ntt.firmware code 210 = domain-list;
option vendor.ntt code 210 = encapsulate ntt;

interface "eth0" {
  also request ip-sip-servers, vivso;

  send vendor-class.ntt = concat(06, suffix(hardware, 6));
}

うまくいくと、dhclient.eth0.leases に設定が入っているのが確認できる。

Asterisk

Ubuntu 16.04のAsteriskは壊れていて面倒そうなので使わない。 https://bugs.launchpad.net/ubuntu/+source/asterisk/+bug/1314058

install_prereqはX関連のアレコレが入るので使わない。

$ sudo apt install build-essential libncurses-dev uuid-dev libjansson-dev libxml2-dev libsqlite3-dev libssl-dev
$ tar xvf asterisk-13.14.0.tar.gz
$ cd asterisk-13.14.0
$ ./configure --with-pjproject-bundled --prefix=/usr/local
$ make menuconfig # CORE-SOUNDS-JA-GSM
$ make
$ sudo make isntall
$ sudo make config
$ sudo make samples
$ sudo make install-logrotate
  • /etc/default/asteriskのALTCONFを/usr/local/etc/asterisk/asterisk.confに変えたり…
  • ログが /usr/local/var/lib/log に出力されるので、適当に移動したり…

ntt.conf

dhclientが起動するスクリプトからasteriskの設定を作る。

  • /etc/dhcp/dhclient-exit-hooks.d/sip-configuration
if [ "eth0" = "$interface" ]; then
        case $reason in
                BOUND|RENEW|REBIND|REBOOT)
                        domain=$(echo "$new_ntt_domain" | sed -e 's/[.]$//')
                        number="$new_ntt_number"
                        is_ip=$(echo "$new_ip_sip_servers" | awk '{ print $1; }')
                        server=$(echo "$new_ip_sip_servers" | awk '{ print $2; }')

                        if [ -n "$domain" ] && [ -n "$number" ] && [ "$is_ip" = 'true' ] && [ -n "$server" ]; then
                                cat /etc/asterisk/ntt.conf.up | \
                                sed \
                                        -e "s/DOMAIN/$domain/g" \
                                        -e "s/NUMBER/$number/g" \
                                        -e "s/SERVER/$server/g" \
                                        > /usr/local/etc/asterisk/ntt.conf
                                service asterisk reload
                        fi
                        ;;

                EXPIRE|FAIL|RELEASE|STOP)
                        cp /etc/asterisk/ntt.conf.down /usr/local/etc/asterisk/ntt.conf
                        service asterisk reload
                        ;;
        esac
fi
  • /etc/asterisk/ntt.conf.up
register => NUMBER@DOMAIN@SERVER/NUMBER

[ntt]
type=peer
host=SERVER
context=fromntt
fromdomain=DOMAIN
  • /etc/asterisk/ntt.conf.down
; empty
  • sip.conf
[general]
(略)
#include <ntt.conf>

[201]
(略)

結果

eri*CLI> sip show registry
Host                                    dnsmgr Username       Refresh State                Reg.Time
xxx.xxx.xxx.x:5060                      N      0xxxxxxxxx@n      3585 Registered           Tue, 04 Apr 2017 04:55:15
1 SIP registrations.

IPv6

client-idは -D LL を指定してdhclientを起動していればいらないと思いきや、うっかりleaseファイルからDUID-LLTを読んでしまうと困るので書いておく。

  • dhclient.conf
option space my-vsio code width 4 length width 2 hash size 3;
option my-vsio.ntt6 code 210 = string;
option dhcp6.my-vendor-opts code 16 = encapsulate my-vsio;

option space ntt6 code width 2 length width 2 hash size 7;
option ntt6.mac      code 201 = string;
option ntt6.number   code 202 = text;
option ntt6.domain   code 204 = domain-list;
option ntt6.firmware code 210 = domain-list;
option vsio.ntt6 code 210 = encapsulate ntt6;

interface "eth0" {
  send dhcp-client-identifier = hardware;
  request subnet-mask, routers, ip-sip-servers, rfc3442-classless-static-routes, vivso;
  send vendor-class.ntt = concat(06, suffix(hardware, 6));

  send dhcp6.client-id = concat(00:03:00, hardware);
  also request dhcp6.name-servers, dhcp6.domain-search, dhcp6.sntp-servers, dhcp6.sip-servers-addresses, dhcp6.vendor-opts;
  send my-vsio.ntt6 = suffix(hardware, 6);
}
  • /etc/network/interfaces
iface eth0 inet6 manual
    #(ip -6 address show dev eth0 の結果がtentativeでなくなるのを待って)
    #(NGNの経路を足して)
    up /sbin/dhclient -1 -6 -P -D LL -pf /run/dhclient6.eth0.pid -lf /var/lib/dhcp/dhclient6.eth0.leases -I -df /var/lib/dhcp/dhclient.eth0.leases eth0
    pre-down /sbin/dhclient -r -pf /run/dhclient6.eth0.pid eth0

うまくいくと /var/lib/dhcp/dhclient6.eth0.leases にIPv4のものと同等の情報が入る。