Radiusセットアップ

By siteadministrator, 13 6月, 2020

Freeradius+MySQLでRdiusサーバーを立てる。

必要パッケージをインストール

apt install freeradius
apt install freeradius-mysql

MySQLにデータベース、ユーザーを作成する。結構表現がややこしい。以下の設定は、ローカルホスト上にDBが存在するとしている。

CREATE DATABASE radius CHARACTER SET UTF8 COLLATE UTF8_BIN;
CREATE USER 'radius'@'%' IDENTIFIED BY 'radius';
GRANT ALL PRIVILEGES ON radius.* TO 'radius'@'%';
QUIT;

データベース名、ユーザー名、パスワードは適宜変更すること。

mysql -u radius -p radius < /etc/freeradius/3.0/mods-config/sql/main/mysql/schema.sql

moduleの設定ファイルを変更し、作成したDBに接続出来るようにする。

vi /etc/freeradius/3.0/mods-enabled/sql

sql {
    driver = "rlm_sql_mysql"
    dialect = "mysql"
    server = "localhost"
    port = 3306
    login = "radius"
    password = "radius"
    radius_db = "radius"
    acct_table1 = "radacct"
    acct_table2 = "radacct"
    postauth_table = "radpostauth"
    authcheck_table = "radcheck"
    groupcheck_table = "radgroupcheck"
    authreply_table = "radreply"
    groupreply_table = "radgroupreply"
    usergroup_table = "radusergroup"
    delete_stale_sessions = yes
    pool {
        start = ${thread[pool].start_servers}
        min = ${thread[pool].min_spare_servers}
        max = ${thread[pool].max_servers}
        spare = ${thread[pool].max_spare_servers}
        uses = 0
        retry_delay = 30
        lifetime = 0
        idle_timeout = 60
    }
    read_clients = yes
    client_table = "nas"
    group_attribute = "SQL-Group"
    $INCLUDE ${modconfdir}/${.:name}/main/${dialect}/queries.conf
}

管理用UIの設定

上記のようにMySQLを使用する場合には、データベースにさえアクセスできれば、Radiusサーバー上にUI用のWebサーバーを置く必要はない。ここれは、daloRADIUSを使用する。また、Nginxを使用した環境とする。

daloRADIUSをダウンロードする。以下のコマンドを投入するか、ここからダウンロードする。配置場所は/opt/Daloradius/daloradiusとする。

mkdir /opt/Daloradius

cd /opt/Daloradius

ソフトウェアをダウンロードする。

wget https://codeload.github.com/lirantal/daloradius/zip/master

unzip daloradius-1.1-2.zip

接続データベースのパラメータを書き込む。

vi Daloradiusのパス/library/daloradius.conf.php

$configValues['FREERADIUS_VERSION'] = '3';
$configValues['CONFIG_DB_ENGINE'] = 'mysqli';
$configValues['CONFIG_DB_HOST'] = 'DBサーバー名';
$configValues['CONFIG_DB_PORT'] = '3306';
$configValues['CONFIG_DB_USER'] = 'ユーザー名';
$configValues['CONFIG_DB_PASS'] = 'パスワード';
$configValues['CONFIG_DB_NAME'] = 'データベース名';

Nginx用の設定ファイルを作成する。

vi /etc/nginx/sites-available/daloradius

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name ホスト名;
    root daloradiusへのパス;
    index index.html index.php login.php;
    allow 192.168.0.0/24;  
    deny all;
    location / {
        index index.php;
        try_files $uri $uri/ /index.php;
    }
    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass fastcgi_backend;
        fastcgi_param  SCRIPT_FILENAME  $document_root/$fastcgi_script_name;
        include        fastcgi_params;
    }
}
server {
    listen 80 http2;
    listen [::]:80 http2;
    server_name ホスト名;
    root daloradiusへのパス;
    return 301 https://$server_name$request_uri;
}

設定を有効化する。

ln -s /etc/nginx/sites-available/daloradius /etc/nginx/sites-enabled/

Nginxを再起動する。

service nginx restart

Debianでは標準パッケージのみでは、Daloradiusが動作しなかった。以下のコマンドで追加モジュールをインストールする。

pear install DB

 

 

 

 

 

 

 

 

 

 

 

 

タグ

コメント