RADIUS製品では有償のアプライアンスなど各メーカーから販売されておりますが、ちょっとした検証や小規模システムなどでRADIUSを利用したい場合は無償のFreeRADIUSをおすすめします。
まず、yumからインストールを行います。
# dnf install freeradius freeradius-utils # rpm -qa | grep freeradius freeradius-3.0.21-37.el9.x86_64 freeradius-utils-3.0.21-37.el9.x86_64 |
設定ファイルは/etc/raddb以下にインストールされます。主に以下の3つのファイルを編集していくことになります。
■/etc/raddb/radiusd.conf (RADIUSサーバ全般の設定)
■/etc/raddb/clients.conf (RADIUS Clientsの定義ファイル)
■/etc/raddb/users (RADIUS認証を行うユーザ名、パスワードの定義ファイル)
まず/etc/raddb/radiusd.confから編集していきます。RADIUSの認証ログを残しておくべきだと考えますので、認証ログを出力するよう以下の箇所を編集していきます。ファイル全体は長いので編集した箇所のみ記載しています。
# vi /etc/raddb/radiusd.conf <一部抜粋> auth = yes auth_badpass = yes auth_goodpass = yes |
次に/etc/raddb/clients.confを編集します。このファイルにRADIUS Clientsを定義します。まずはテスト的に自分自身を定義しますが、既に定義があり、編集する必要もないのでそれをそのまま利用できます。以下はlocalhost部分の抜粋です。
# vi /etc/raddb/clients.conf
<一部抜粋>
client localhost {
ipaddr = 127.0.0.1
proto = *
secret = testing123
require_message_authenticator = no
nas_type = other # localhost isn't usually a NAS...
limit {
max_connections = 16
lifetime = 0
idle_timeout = 30
}
}
|
Clientを追加したい場合、最低限、必要な記述は以下となります。
client 192.168.0.1 {
ipaddr = 192.168.0.1
secret = secret-password
}
|
次に/etc/raddb/usersを編集します。これは実際に認証するアカウントを登録しておくものです。このファイルの最後尾に以下のような記述を追記します。ユーザ名がunixpower、パスワードがpasswordというアカウントを追加しています。
# vi /etc/raddb/users unixpower Cleartext-Password:="password" |
次に実際使用するのかは別として証明書関係の操作を行っておきます。デフォルトだと/etc/raddb/mods-enabled/eap内で証明書関連のファイルが指定されているため、ファイルが存在しないとエラーがでてしまいました。
# tail /var/log/radius/radius.log -n 100 Wed Jul 26 13:54:57 2023 : Info: Debugger not attached Wed Jul 26 13:54:57 2023 : Error: Unable to check file "/etc/raddb/certs/server.pem": No such file or directory Wed Jul 26 13:54:57 2023 : Error: /etc/raddb/mods-enabled/eap[183]: Failed parsing configuration item "private_key_file" Wed Jul 26 13:54:57 2023 : Error: rlm_eap_tls: Failed initializing SSL context Wed Jul 26 13:54:57 2023 : Error: rlm_eap (EAP): Failed to initialise rlm_eap_tls Wed Jul 26 13:54:57 2023 : Error: /etc/raddb/mods-enabled/eap[14]: Instantiation failed for module "eap" |
そのため次の操作を行っておきます。
# cd /etc/raddb/certs # make all # chmod 755 server.pem dh または # chgrp radiusd server.pem dh |
これで/etc/raddb/certs配下に証明書関係のファイルが生成されます。
またバージョンによっては以下のファイルも編集しないと起動に失敗するケースがありました。※具体的なエラー箇所はradiusd -Xで確認可能です。
# vi /etc/raddb/sites-enabled/default
<一部抜粋>
listen {
type = auth
port = 1812
}
listen {
type = acct
port = 1813
}
# IPv6 versions of the above - read their full config to understand options
#listen {
# type = auth
# ipv6addr = :: # any. ::1 == localhost
# port = 0
# interface = eth0
# clients = per_socket_clients
# limit {
# max_connections = 16
# lifetime = 0
# idle_timeout = 30
# }
#}
#listen {
# ipv6addr = ::
# port = 0
# type = acct
# interface = eth0
# clients = per_socket_clients
#
# limit {
# max_pps = 0
# idle_timeout = 0
# lifetime = 0
# max_connections = 0
# }
#}
|
ここまできたらFreeRADIUSを有効にして起動します。
# systemctl enable radiusd.service # systemctl start radiusd.service |
先程作成したテストユーザで認証テストを実施してみます。テストコマンドは以下のように行います。/etc/raddb/clients.confにlocalhostがデフォルトで登録されているので、これを使用します。書式はradtest -4 [ユーザ名] [パスワード] localhost [Port] [SecretKey]となります。SecretKeyはtesting123と設定されています。
# radtest -4 unixpower password localhost 1812 testing123
Sent Access-Request Id 64 from 0.0.0.0:59470 to 127.0.0.1:1812 length 79
User-Name = "unixpower"
User-Password = "password"
NAS-IP-Address = 127.0.0.1
NAS-Port = 1812
Message-Authenticator = 0x00
Cleartext-Password = "password"
Received Access-Accept Id 64 from 127.0.0.1:1812 to 0.0.0.0:0 length 20
|
上記のようになれば認証成功です。/var/log/radius/radius.logにも次のようなログが出力されます。
Wed Jul 26 14:18:19 2023 : Auth: (0) Login OK: [unixpower/password] (from client localhost port 1812) |
動作上は影響ないのですが、radiusを再起動する度に以下のエラーが出力されていました。
Warning: Please use tls_min_version and tls_max_version instead of disable_tlsv1 Warning: Please use tls_min_version and tls_max_version instead of disable_tlsv1_2 |
少し気持ち悪かったので以下のファイルを編集し、解消しています。
# vi /etc/raddb/mods-enabled/eap
<一部抜粋>
eap {
tls-config tls-common {
# disable_tlsv1_2 = no
# disable_tlsv1_1 = yes
# disable_tlsv1 = yes
|