zkat’s diary

技術ブログ

FREDをインストールしてTLDゾーンのレジストリになる

はじめに

タイトルの通り、cz.nic が作っているFRED(Free Registry for ENUM and Domains)をインストールして、適当なTLDゾーンを作ってみたいと思います。
IANAから正式に委任されているTLD*1を使うのは気が引けるので、今回は example を TLDとしてみます。

インストール

今回インストールをする環境情報です。Ubuntu 16.04 でやりたいと思います。

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 16.04.4 LTS
Release:        16.04
Codename:       xenial
fred@ubuntu:~$ uname -a
Linux ubuntu 4.4.0-119-generic #143-Ubuntu SMP Mon Apr 2 16:08:24 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

公式の手順に従い、 何も考えずに Installation script を叩いてみます。

1.2. Installation of binaries on Ubuntu — FRED 2.37 Documentation

$ sudo su -
# wget https://fred.nic.cz/files/fred/fred-ubuntu-install.sh
# . fred-ubuntu-install.sh

上記シェルスクリプトが何をしているかは、Installation stepsに書いてあります。

TLDゾーンの作成

つづいて TLDゾーンの作成に移ります。やり方は2つ存在するようです。 1つは、ゾーンのセットアップスクリプトを実行する方法。2つめは、手動でコマンドをたたいていく方法。 1つめの方法を公式から引用します。

$ wget https://fred.nic.cz/files/fred/fred-config-zone.py
$ python fred-config-zone.py cz > fred-config-cz.sh
$ . fred-config-cz.sh

上記スクリプト fred-config-zone.py は 作成したい TLD名を引数にとるスクリプトで、 TLDゾーンのセットアップ用のコマンドを標準出力に出力します。 但し、上記スクリプトには実在するTLD名を与えないと動かないようです。
どうもTLDゾーンのSOA等を引いて、セットアップ用に値を取ってきているようです。(シリアルとかTTLとか)

とういうことで、2つめの方法、コマンドを愚直に叩いていく方法でセットアップをしていこうと思います。 セットアップは以下の流れで実施する必要がある様です。
それぞれのタスクは、インストール時に作られた fred-adminというコマンドで行えるようです。fred-admin --help で詳細な使い方が分かります。

1.ゾーンの作成

コマンドを実行します。

$ fred-admin --zone_add \
    --zone_fqdn=example \
    --ex_period_min=12 \
    --ex_period_max=120 \
    --ttl=18000 \
    --hostmaster=hostmaster@nic.example \
    --refresh=900 \
    --update_retr=300 \
    --expiry=604800 \
    --minimum=900 \
    --ns_fqdn=a.dns.example

--ex_period_minは登録可能期間の最小値(月単位)、--ex_period_maxは登録可能期間の最大値(月単位) を表しているようです。
それ以外のオプションは、TLDゾーンのSOAレコードに記載される値です。

つづいて、TLDゾーンの権威DNSサーバーを登録します。

$ fred-admin --zone_ns_add --zone_fqdn=example --ns_fqdn=a.dns.example --addr=127.0.0.1

2. レジストラアカウントの作成

作成できるレジストラのタイプは、common registrar と system registrar の2つが存在するようです。
system registrar については、レジストリ自身がゾーンの情報を変更するためのアカウントで、
common registrarアカウントはそれ以外の目的のアカウントとなる様です。
system registrarを作成し認証情報を設定し、example ゾーンへの権限を追加します。
認証情報の設定については、fred-clientが使用するクライアント証明書(/usr/share/fred-client/ssl/test-cert.pem)のfingerprintを正しく設定する必要があります。 フィンガープリントの作り方は以下の通り。

$ openssl x509 -noout -fingerprint -md5 -in /path/to/cert.pem | cut -d= -f2
$ fred-admin --registrar_add --handle=REG-SYS --reg_name="System registrar" --country=JP --system
$ fred-admin --registrar_acl_add --handle=REG-SYS --certificate="上記で作ったfingerprintの値。16新数2桁のコロン区切り" --password=passwd
$ fred-admin --registrar_add_zone --zone_fqdn=example --handle=REG-SYS

3. 課金情報の作成

EPPにおけるそれぞれの操作に対応した形で課金情報の設定をする事ができるようです。
CreateDomainにはいくら、RenewDomainにはいくら、それ以外のEPP操作にはいくら という感じです。

$ fred-admin --price_add --operation='CreateDomain' --zone_fqdn=example    --operation_price 150 --period 1
$ fred-admin --price_add --operation='RenewDomain' --zone_fqdn=example    --operation_price 200 --period 1
$ fred-admin --price_add --operation='GeneralEppOperation'    --zone_fqdn=example    --operation_price 0.05 --period 1 --enable_postpaid_operation

ドメインを登録してみる

さて、セットアップを一通り終えましたので実際にドメインを登録してみたいと思います。登録するドメインは、nic.example とします。
レジストラアカウントは、system registrar を使用します。 登録の前に、登録対象のドメイン nic.example をwhoisで引いてみます。

$ whois -h localhost nic.example
% Domain Information over Whois protocol
%
% Whoisd Server Version: 3.10.2

%ERROR:101: no entries found
%
% No entries found.

ドメインを登録するには、fred-clientコマンドを使用します。
fred-clientが使用する認証情報については、REG-SYSアカウントのもので適当に設定する必要があります。 設定ファイルは、/etc/fred/fred-client.confです。

$ fred-client
FredClient upstream/2.10.1-132-gad39
Type "help", "license" or "credits" for more information.

Using configuration from /etc/fred/fred-client.conf
Connecting to localhost, port 700 ...
Connected!

REG-SYS@localhost> check_contact ID99
ID99:                     Available. Not in registry: Object is available.
REG-SYS@localhost> create_contact ID99 'Nanashi no Gombei' nanashi.gombei@nic.example 'Example Street' ExampleCity 12300 JP
Do you really want to send this command to the server? (y/N): y
Contact ID:               ID99
Created on:               2018-06-25T02:49:00+09:00
REG-SYS@localhost> check_contact ID99
ID99:                     Not available. Registered already
REG-SYS@localhost> info_contact ID99
Contact ID:               ID99
Repository object ID:     C0000000001-EPP
Created by:               REG-SYS
Designated registrar:     REG-SYS
Created on:               2018-06-25T02:49:00+09:00
Name:                     Nanashi no Gombei
Street:                   Example Street
City:                     ExampleCity
Postal code:              12300
Country code:             JP
Password for transfer:    NWmUd5vp
Email:                    nanashi.gombei@nic.example
Status:                   ok - Object is without restrictions
Disclose:                 voice
                          fax
                          email
                          vat
                          ident
                          notify_email
Hide:                     addr
REG-SYS@localhost> !create_nsset
Interactive input mode started. Press Ctrl+C to abort or Ctrl+D to finish command.
NSSET ID [required]: ID99
LIST of DNS[1/9] / Name server [required]: ns1.nic.example
LIST of DNS[1/9] / Server address[1/oo] [optional]: 127.0.0.1
LIST of DNS[1/9] / Server address[2/oo] [optional]:
LIST of DNS[2/9] / Name server [required]: ns2.nic.example
LIST of DNS[2/9] / Server address[1/oo] [optional]: 127.0.0.1
LIST of DNS[2/9] / Server address[2/oo] [optional]:
LIST of DNS[3/9] / Name server [optional]:
Technical contact[1/oo] [required]: ID99
Technical contact[2/oo] [optional]:
Password required by server to authorize the transfer [optional]: test
Report range level (0 - 10; higher = more detailed) [optional]:
Client transaction ID [optional]:

Interactive input completed. [Press Enter]
Command to issue:
create_nsset ID99 ((ns1.nic.example 127.0.0.1), (ns2.nic.example 127.0.0.1)) ID99 test
Do you really want to send this command to the server? (y/N): y
NSSET ID:                 ID99
Created on:               2018-06-25T02:52:20+09:00
REG-SYS@localhost> info_nsset ID99
NSSET ID:                 ID99
Repository object ID:     N0000000002-EPP
Created by:               REG-SYS
Designated registrar:     REG-SYS
Created on:               2018-06-25T02:52:20+09:00
Password for transfer:    test
Status:                   ok - Object is without restrictions
Technical contact:        ID99
Name servers:             ns1.nic.example, (127.0.0.1)
                          ns2.nic.example, (127.0.0.1)
Report level:             3
REG-SYS@localhost> create_domain nic.example ID99 NULL ID99
Do you really want to send this command to the server? (y/N): y
Domain name:              nic.example
Created on:               2018-06-25T02:53:18+09:00
Expiration date:          2019-06-24
REG-SYS@localhost> quit
Logout command sent to server

History IOError: [Errno 13] Permission denied
Ending session at localhost
Disconnected.

無事登録できたので、whoisとRDAPを引いてみます。

$ whois -h localhost nic.example
% Domain Information over Whois protocol
%
% Whoisd Server Version: 3.10.2
% Timestamp: Sun Jun 24 17:54:56 2018

domain:       nic.example
registrant:   ID99
nsset:        ID99
registrar:    REG-SYS
registered:   25.06.2018 02:53:18
expire:       24.06.2019

contact:      ID99
name:         Nanashi no Gombei
address:      Example Street
address:      ExampleCity
address:      12300
address:      JP
registrar:    REG-SYS
created:      25.06.2018 02:49:00

nsset:        ID99
nserver:      ns1.nic.example (127.0.0.1)
nserver:      ns2.nic.example (127.0.0.1)
tech-c:       ID99
registrar:    REG-SYS
created:      25.06.2018 02:52:20

RDAPのアクセス先は、http://localhost/rdap/domain/nic.example となります。

{
    "status": [
        "active"
    ],
    "fred_nsset": {
        "nameservers": [
            {
                "ipAddresses": {
                    "v4": [
                        "127.0.0.1"
                    ]
                },
                "objectClassName": "nameserver",
                "handle": "ns1.nic.example",
                "links": [
                    {
                        "href": "http://localhost/rdap/nameserver/ns1.nic.example",
                        "type": "application/rdap+json",
                        "rel": "self",
                        "value": "http://localhost/rdap/nameserver/ns1.nic.example"
~~~長いので省略~~~

肝心な example ゾーンのゾーンファイルですが、
/etc/fred/genzone.confのzonedirに指定したディレクトリにゾーンファイルが作られています。

$ cat /etc/bind/db.example
 18000 ;default TTL for all records in zone
example.                IN      SOA     a.dns.example.  hostmaster.nic.example. (1529832016 900 300 604800 900)
                IN      NS      a.dns.example.
a.dns.example.  IN      A       127.0.0.1
;
;--- domain records ---
;
nic.example.    IN      NS      ns1.nic.example.
ns1.nic.example.        IN      A       127.0.0.1
nic.example.    IN      NS      ns2.nic.example.
ns2.nic.example.        IN      A       127.0.0.1

最後に、レジストラへの課金情報ですが、 レジストリオペレータ向けのWebインターフェース(WebAdmin)が localhost:18456 にて動いているようで
そこから invoiceの情報をレジストラごとに見れそうでした。
今回は、system registrar によってドメインを登録したせいなのかわかりませんが、 特に請求情報を見つけられませんでした。

WebAdminについては、今後詳しく見ていこうと思います。