FreeBSD 11.0 bind 9.18 ソースコンパイル

bind-9.18.37
bind-9.20.9

https://www.isc.org/download/

必須要件

❌ Unsupported platforms
These are platforms on which BIND is known not to build or run:

  • Platforms without at least OpenSSL 1.0.2
  • Windows Server (any version)
  • Platforms that don't support IPv6 Advanced Socket API (RFC 3542)
  • Platforms that don't support atomic operations (via compiler or library)
  • Linux without Native POSIX Thread Library (NPTL)
  • Platforms on which libuv cannot be compiled

https://kb.isc.org/docs/supported-platforms

BIND 9.18 requires libuv 1.0.0 or higher; using libuv >= 1.40.0 is recommended. Compiling or running with libuv 1.35.0 or 1.36.0 is not supported, as this could lead to an assertion failure in the UDP receive code.
...
OpenSSL 1.0.2e or newer is required.
...
https://bind9.readthedocs.io/en/v9.18.37/chapter10.html#required-libraries

BIND 9.20 requires libuv 1.34.0 or higher; using libuv >= 1.40.0 is recommended. Compiling or running with libuv 1.35.0 or 1.36.0 is not supported, as this could lead to an assertion failure in the UDP receive code.
...
OpenSSL 1.0.2e or newer is required.
...
The Userspace RCU library liburcu (https://liburcu.org/) is used for lock-free data structures and concurrent safe memory reclamation.
https://bind9.readthedocs.io/en/v9.20.9/chapter10.html#required-libraries

https://dist.libuv.org/dist/

https://openssl-library.org/source/

https://liburcu.org/

コンパイル

gcc をソースコンパイルする(必要な場合)https://kurita1.hatenadiary.com/entry/2025/05/22/203137

cd /usr/local/src

curl -LO https://dist.libuv.org/dist/v1.34.2/libuv-v1.34.2.tar.gz
tar xzf libuv-v1.34.2.tar.gz 
cd libuv-v1.34.2
sh autogen.sh
./configure --prefix=/usr/local/bind918
make
make install

cd ..
curl -LO https://github.com/openssl/openssl/releases/download/openssl-3.0.16/openssl-3.0.16.tar.gz
tar xzf openssl-3.0.16.tar.gz
cd openssl-3.0.16
./Configure --prefix=/usr/local/bind918
make 
make install

cd ..
curl -LO http://web.mit.edu/kerberos/dist/krb5/1.21/krb5-1.21.3.tar.gz
tar xzf krb5-1.21.3.tar.gz
cd krb5-1.21.3/src
./configure --prefix=/usr/local/bind918
make
make install

cd ..
curl -LO https://downloads.isc.org/isc/bind9/9.18.37/bind-9.18.37.tar.xz
tar xzf bind-9.18.37.tar.xz 
cd bind-9.18.37
setenv CC "/usr/local/gcc11/bin/gcc"
setenv PKG_CONFIG_PATH "/usr/local/bind918/lib/pkgconfig"
./configure --prefix=/usr/local/bind918 --with-gssapi=/usr/local/bind918/bin/krb5-config

(確認)
/usr/local/bind918/sbin/named -v
BIND 9.18.37 (Extended Support Version) <id:d8ff479>
gcc

libatomic が必要

netmgr/netmgr.c:3809:10: error: address argument to atomic operation must be a pointer to non-const _Atomic type
      ('const isc_refcount_t *' (aka 'const _Atomic(__uint_fast32_t) *') invalid)
        REQUIRE(VALID_NMHANDLE(handle));
                ^~~~~~~~~~~~~~~~~~~~~~
libuv

libuv 1.49.2 → named 起動するがクエリに応答しない
libuv 1.39.0 → pid 69010 (named), uid 53: exited on signal 11 で起動しない
libuv 1.23.0 → 以下エラー

netmgr/uverr2result.c:98:isc___nm_uverr2result(): unexpected error: 
unable to convert libuv error code in udp_send_cb (netmgr/udp.c:806) to isc_result: -56: socket is already connected

https://github.com/libuv/libuv/blob/v1.x/ChangeLog

2020.03.12, Version 1.35.0 (Stable), e45f1ec38db882f8dc17b51f51a6684027034609

Changes since version 1.34.2:
...
* unix: remove support for FreeBSD < 10 (Saúl Ibarra Corretgé)
...

このあたり?

openssl

OpenSSL 1.0.2k → 以下エラー

openssl_shim.c:132:17: error: implicit declaration of function 'ERR_load_crypto_strings'; did you mean 'ERR_load_CRYPTO_strings'? [-Werror=implicit-function-declaration]
  132 |                 ERR_load_crypto_strings();
      |                 ^~~~~~~~~~~~~~~~~~~~~~~
      |                 ERR_load_CRYPTO_strings

3.0 を使う。1.1.1 でも問題ないはず

krb5

https://web.mit.edu/kerberos/dist/

以下エラー

/usr/bin/ld: warning: libcrypto.so.8, needed by /usr/lib/libheimntlm.so, may conflict with libcrypto.so.3

/usr/lib/libheimntlm.so が libcrypto.so.8 (openssl 1.0.2) で libcrypto.so.3 (openssl 3.0) と conflict

MIT で実装された Kerberos は、 security/krb5 package または port から利用できます。 バージョン 5 のもう一つの実装が、 Heimdal Kerberos です。 この実装は、アメリカ合衆国の外で開発されたため、 輸出の制限を避けることができます。 Heimdal Kerberos は security/heimdal> package または port からインストールできますが、最小構成は FreeBSD の base インストールに含まれています。
https://docs.freebsd.org/ja/books/handbook/security/#kerberos5

krb5-config は pkg-config のようなもの

https://web.mit.edu/kerberos/krb5-latest/doc/user/user_commands/krb5-config.html

SPHINX

sphinx (sphinx-build) がインストールされていてエラー

make  all-am
Making all in man
echo ""

  SPHINX   manpages.stamp

Warning, treated as error:
../../bin/delv/delv.rst:105:Undefined substitution referenced: "bind_keys".

が出る場合は

setenv ac_cv_path_SPHINX_BUILD
をしてから
./configure --prefix=/usr/local/bind918 --with-gssapi=/usr/local/bind918/bin/krb5-config

Problems building bind 9.18.1 on FreeBSD 2022