サイト内検索

Rocky/Alma/CentOS 9|8にFreeRADIUSとDaloradiusをインストールする


CentOS 8/RHEL 8 に FreeRADIUS と Daloradius をインストールしたいですか?RADIUS は「Remote Authentication Dial-In User Service(リモート認証ダイヤルアップユーザーサービス)」の略で、リモートユーザーの認証と課金のために使用されるネットワークプロトコルです。これは AAA サービス、すなわち 認可、認証、および 課金 を提供します。

FreeRADIUSはオープンソースで、高性能、スケーラブル、モジュール型で機能が豊富なRADIUSサーバーです。FreeRADIUSはリクエストプロキシ、フェイルオーバー、ロードバランシングのサポートに加え、さまざまなデータベースバックエンドへのアクセスも提供します。

FreeRADIUSの主な特徴

  • ユーザー設定を選択するための幅広い方法による柔軟な構成。
  • RFC 2865およびRFC 2866属性に完全対応。
  • EAP-MD5、EAP-SIM、EAP-TLS、EAP-TTLS、EAP-PEAP、およびCisco LEAPのEAPサブタイプを使用したEAP
  • ベンダーごとの特定属性は、BinTec、Foundry、Cisco、Juniper、Lucent/Ascend、HP ProCurve、Microsoft、USR/3Com、Acc/Newbridge など、ほぼ100社のベンダーを含みます。

daloRADIUSを取り入れる

daloRADIUSは、PHPとJavaScriptで書かれた高度なRADIUSウェブ管理プラットフォームです。主に、FreeRADIUSサーバーを利用したホットスポットや汎用ISP展開の管理を目的としています。以下はdaloRADIUSの主な機能です:

  • 多くのデータベースシステムをサポートするデータベース抽象化レイヤー – MySQL、SQLite、PostgreSQL、MsSQL、Oracle
  • 高度なユーザー管理
  • 強力なグラフィカルレポートと会計
  • Googleマップと統合して位置情報を利用
  • 請求エンジンを持っている

次に説明する手順に従って、CentOS 8/RHEL 8 LinuxシステムにFreeRADIUSとdaloRADIUSをインストールしてください。

ステップ1:サーバーを更新する

更新されていないシステムは決して信頼してはいけません。インストールされているすべてのパッケージは、以下のコマンドをターミナルで実行することで更新できます。

sudo dnf -y update

ステップ2:ApacheとPHPをインストールする

システムに daloRADIUS をホストするために Apache httpd サーバーを使用します。以下のコマンドで httpd と PHP の両方のパッケージをインストールしてください。

sudo dnf module reset -y php
sudo dnf module reset -y php && sudo dnf module install -y php:8.0
sudo dnf -y install php-{cli,curl,mysqlnd,devel,gd,pear,mbstring,xml,pear,zip}
sudo pear install DB
sudo pear install MDB2

インストールが成功したか確認するために、インストールされているPHPのバージョンを確認してください。

$ php -v
PHP 8.0.30 (cli) (built: Aug  3 2023 17:13:08) ( NTS gcc x86_64 )
Copyright (c) The PHP Group
Zend Engine v4.0.30, Copyright (c) Zend Technologies

Apacheウェブサーバーをインストールする:

sudo dnf -y install @httpd

php-fpmとhttpdサービスを起動して有効にします。

sudo systemctl enable --now httpd php-fpm

まずは、2つのサービスの状態を確認して、開始を確認しましょう。

systemctl status httpd php-fpm

ファイアウォールで HTTP と HTTPS ポートを許可してください。

sudo firewall-cmd --add-service={http,https} --permanent
sudo firewall-cmd --reload

Apache httpd のインストール参考資料:

  • RHEL/CentOS 8 に Apache httpd サーバーをインストールする

ステップ3:MariaDBのインストールと設定

RHEL/CentOS 8 における MariaDB データベースサーバーのインストールについては、別のガイドがあります。以下のリンクをご参照ください。

  • CentOS/RHEL 8 に MariaDB データベースサーバーをインストールする

インストール後、rootユーザーとしてMySQLコンソールにアクセスし、FreeRADIUS/daloRADIUS用のデータベースとユーザーを作成します。

$ mysql -u root -p
CREATE DATABASE radius;
GRANT ALL ON radius.* TO radius@localhost IDENTIFIED BY "StrongradIusPass";
FLUSH PRIVILEGES;
\q

ステップ4:FreeRADIUSのインストール

FreeRADIUSのパッケージはモジュラーリポジトリで利用可能です。

$ sudo dnf module list freeradius
Last metadata expiration check: 0:04:00 ago on Thu 10 Oct 2019 05:08:54 PM EAT.
CentOS-8 - AppStream
Name                      Stream                 Profiles                 Summary                                                                  
freeradius                3.0 [d]                server [d]               High-performance and highly configurable free RADIUS server              

Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled

インストールするには、コマンドを実行するだけです。

sudo dnf install -y @freeradius freeradius-utils freeradius-mysql

インストール後にサービスを開始してください。

sudo systemctl enable --now radiusd.service

これで状況を確認できます:

$ systemctl status radiusd.service
● radiusd.service - FreeRADIUS high performance RADIUS server.
   Loaded: loaded (/usr/lib/systemd/system/radiusd.service; enabled; vendor preset: disabled)
   Active: active (running) since Thu 2023-11-23 01:53:42 UTC; 3s ago
  Process: 14781 ExecStart=/usr/sbin/radiusd -d /etc/raddb (code=exited, status=0/SUCCESS)
  Process: 14778 ExecStartPre=/usr/sbin/radiusd -C (code=exited, status=0/SUCCESS)
  Process: 14732 ExecStartPre=/bin/sh /etc/raddb/certs/bootstrap (code=exited, status=0/SUCCESS)
  Process: 14731 ExecStartPre=/bin/chown -R radiusd.radiusd /var/run/radiusd (code=exited, status=0/SUCCESS)
 Main PID: 14783 (radiusd)
    Tasks: 6 (limit: 22612)
   Memory: 77.8M
   CGroup: /system.slice/radiusd.service
           └─14783 /usr/sbin/radiusd -d /etc/raddb

Nov 23 01:53:41 rocky8.mylab.io sh[14769]:                   URI:http://www.example.com/example_ca.crl
Nov 23 01:53:41 rocky8.mylab.io sh[14769]: Certificate is to be certified until Jan 22 01:53:41 2024 GMT (60 days)
Nov 23 01:53:41 rocky8.mylab.io sh[14769]: Write out database with 1 new entries
Nov 23 01:53:41 rocky8.mylab.io sh[14769]: Data Base Updated
Nov 23 01:53:41 rocky8.mylab.io sh[14741]: openssl pkcs12 -export -in client.crt -inkey client.key -out client.p12  -passin pass:'whatever' -passout pass:'whatever'
Nov 23 01:53:41 rocky8.mylab.io sh[14741]: chmod g+r client.p12
Nov 23 01:53:41 rocky8.mylab.io sh[14741]: openssl pkcs12 -in client.p12 -out client.pem -passin pass:'whatever' -passout pass:'whatever'
Nov 23 01:53:41 rocky8.mylab.io sh[14741]: chmod g+r client.pem
Nov 23 01:53:41 rocky8.mylab.io sh[14741]: cp client.pem '[email '.pem
Nov 23 01:53:42 rocky8.mylab.io systemd[1]: Started FreeRADIUS high performance RADIUS server..

Firewalldサービスが実行中の場合、radiusとhttpのトラフィックを出入りできるように許可してください。RadiusサーバーはUDPポート1812と1813を使用します。

sudo firewall-cmd --add-service=radius --permanent
sudo firewall-cmd --reload

ステップ5: FreeRADIUSを設定する

FreeRADIUSをMariaDBで使用するように設定するには、以下の手順に従ってください。

1 – Radiusデータベースを作成するために、Radiusデータベーススキーマをインポートします

sudo su -
mysql -u root -p radius < /etc/raddb/mods-config/sql/main/mysql/schema.sql

2 – Radiusの設定

まず、/etc/raddb/mods-enabled の下に SQL のソフトリンクを作成する必要があります

sudo ln -s /etc/raddb/mods-available/sql /etc/raddb/mods-enabled/

SQLモジュール /raddb/mods-available/sql を設定し、環境に合わせてデータベース接続パラメータを変更してください:

sudo vi /etc/raddb/mods-available/sql
  • sql セクションは、以下のように表示されるはずです。
sql {
driver = "rlm_sql_mysql"
dialect = "mysql"

# Connection info:

server = "localhost"
port = 3306
login = "radius"
password = "StrongradIusPass"

# Database table configuration for everything except Oracle

radius_db = "radius"
}

# Set to ‘yes’ to read radius clients from the database (‘nas’ table)
# Clients will ONLY be read on server startup.
read_clients = yes

# Table to keep radius client info
client_table = "nas"

MySQLのSSL設定にコメントを付ける。

 mysql {
                # If any of the files below are set, TLS encryption is enabled
#               tls {
#                       ca_file = "/etc/ssl/certs/my_ca.crt"
#                       ca_path = "/etc/ssl/certs/"
#                       certificate_file = "/etc/ssl/certs/private/client.crt"
#                       private_key_file = "/etc/ssl/certs/private/client.key"
#                       cipher = "DHE-RSA-AES256-SHA:AES128-SHA"
#
#                       tls_required = yes
#                       tls_check_cert = no
#                       tls_check_cert_cn = no
#               }

次に、/etc/raddb/mods-enabled/sql のグループ権限を radiusd に変更します:

sudo chgrp -h radiusd /etc/raddb/mods-enabled/sql

radiusdサービスを再起動する

sudo systemctl restart radiusd

ステップ6:Daloradius のインストールと設定(任意)

Daloradiusを使用すると、ウェブインターフェースからRadiusサーバーを管理できます。これはオプションの設定であり、使用状況に応じて選択できます。

Githubからdaloradiusのコードをダウンロードする。

sudo yum -y install git vim
git clone https://github.com/lirantal/daloradius.git

Daloradius の MySQL テーブルをインポートする

mysql -u root -p radius < daloradius/contrib/db/fr3-mariadb-freeradius.sql
mysql -u root -p radius < daloradius/contrib/db/mariadb-daloradius.sql

/var/www/html のパスに daloradius フォルダを移動する

sudo mv daloradius /var/www/

次に、httpフォルダーの権限を変更し、daloradiusの設定ファイルに適切な権限を設定します。

cd /var/www/daloradius/app/common/includes/
sudo cp daloradius.conf.php.sample daloradius.conf.php
sudo chown -R apache:apache /var/www/daloradius/

次に、MySQLデータベースの情報を調整するために、daloradius.conf.phpファイルを変更する必要があります。

sudo vim daloradius.conf.php

接続用のデータベース名、ユーザー名、パスワードを設定してください。

$configValues['CONFIG_DB_HOST'] = 'localhost';
$configValues['CONFIG_DB_PORT'] = '3306';
$configValues['CONFIG_DB_USER'] = 'radius';
$configValues['CONFIG_DB_PASS'] = 'StrongradIusPass';
$configValues['CONFIG_DB_NAME'] = 'radius';

すべてが正常に動作することを確認するために、radiusd と httpd サービスを再起動してください。

sudo systemctl restart radiusd.service httpd
systemctl status radiusd.service httpd

サービスステータスの出力にエラーがあってはいけません:

必要な追加のディレクトリを作成します。

cd /var/www/daloradius/
sudo mkdir -p var/{log,backup}
sudo chown -R apache:apache var

以下のPHPモジュールをインストールしてください。

sudo pear install DB
sudo pear install MDB2

Apacheウェブサーバーを設定する

Apacheをポート80とポート8000でリッスンするように設定する

$ sudo vim /etc/httpd/conf/httpd.conf
Listen 80
Listen 8000

オペレーター モジュール用の仮想ホストを設定する:

sudo tee /etc/httpd/conf.d/operators.conf<<EOF
<VirtualHost *:8000>
    ServerAdmin operators@localhost
    DocumentRoot /var/www/daloradius/app/operators

    <Directory /var/www/daloradius/app/operators>
        Options -Indexes +FollowSymLinks
        AllowOverride None
        Require all granted
    </Directory>

    <Directory /var/www/daloradius>
        Require all denied
    </Directory>

    ErrorLog /var/log/httpd/daloradius/operators/error.log
    CustomLog /var/log/httpd/daloradius/operators/access.log combined
</VirtualHost>
EOF

次に、ユーザー用の仮想ホストを作成します:

sudo tee /etc/httpd/conf.d/users.conf<<EOF
<VirtualHost *:80>
    ServerAdmin users@localhost
    DocumentRoot /var/www/daloradius/app/users

    <Directory /var/www/daloradius/app/users>
        Options -Indexes +FollowSymLinks
        AllowOverride None
        Require all granted
    </Directory>

    <Directory /var/www/daloradius>
        Require all denied
    </Directory>

    ErrorLog /var/log/httpd/daloradius/users/error.log
    CustomLog /var/log/httpd/daloradius/users/access.log combined
</VirtualHost>
EOF

ログファイルを保存するディレクトリを作成します。

sudo mkdir -p /var/log/httpd/daloradius/{operators,users}

デフォルトの Apache ウェブサーバーのウェルカムページを無効にする。

sudo rm /etc/httpd/conf.d/welcome.conf

SELinux が有効な場合は、ディレクトリに適切なラベルを付けてください。

sudo yum -y install policycoreutils-python-utils
sudo semanage fcontext -a -t httpd_sys_rw_content_t "/var/www/daloradius(/.*)?"
sudo restorecon -Rv /var/www/daloradius

もしSELinuxが強制モードの場合、httpdで使用するためにポート8000にラベルを追加してください。

sudo semanage port -m -t http_port_t -p tcp 8000

正しく適用されているか確認してください。

# semanage port -l | grep -w http_port_t
http_port_t                    tcp      8000, 80, 81, 443, 488, 8008, 8009, 8443, 9000

ファイアウォールからのポートアクセスを許可する。

sudo firewall-cmd --add-service={http,https,radius} --permanent
sudo firewall-cmd --add-port=8000/tcp --permanent
sudo firewall-cmd --reload

すべてが正常に動作していることを確認するために、サービスを再起動してください。

sudo systemctl restart httpd radiusd.service

サービスの状態は、systemctl を使用して確認できます。

systemctl status httpd radiusd

以下のURLでDaloradiusにアクセスしてください。

  • RADIUS管理アプリケーション: http://<ip>:8000/
  • RADIUS ユーザーポータルアプリケーション: http://<ip>

RADIUS管理アプリケーションポータルのインターフェース例。

デフォルトのログイン情報は次の通りです:

Username: administrator
Password: radius

daloRADIUS 管理 UI の外観:

FreeRADIUS と daloRADIUS をお楽しみください:

  • UbuntuにFreeRADIUSとdaloRADIUSをインストールする