CentOS7 に FreeRadius をインストールした際の手順をメモしておきます。
インストール
標準リポジトリで提供される FreeRadius のバージョンは 3.0.4 でした。
# yum info freeradius Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: ftp.riken.jp * extras: ftp.riken.jp * updates: ftp.riken.jp Installed Packages Name : freeradius Arch : x86_64 Version : 3.0.4 Release : 6.el7 Size : 3.2 M Repo : installed From repo : base Summary : High-performance and highly configurable free RADIUS server URL : http://www.freeradius.org/ License : GPLv2+ and LGPLv2+ Description : The FreeRADIUS Server Project is a high performance and highly configurable : GPL'd free RADIUS server. The server is similar in some respects to : Livingston's 2.0 server. While FreeRADIUS started as a variant of the : Cistron RADIUS server, they don't share a lot in common any more. It now has : many more features than Cistron or Livingston, and is much more configurable. : : FreeRADIUS is an Internet authentication daemon, which implements the RADIUS : protocol, as defined in RFC 2865 (and others). It allows Network Access : Servers (NAS boxes) to perform authentication for dial-up users. There are : also RADIUS clients available for Web servers, firewalls, Unix logins, and : more. Using RADIUS allows authentication and authorization for a network to : be centralized, and minimizes the amount of re-configuration which has to be : done when adding or deleting new users.
yum でインストールします。
yum -y install freeradius freeradius-utils
デフォルトの設定ファイル
FreeRadius の設定ファイルは /etc/raddb にあります。主な設定ファイルは以下だと思います。
- /etc/raddb/radiusd.conf
- /etc/raddb/clients.conf
- /etc/raddb/users
コメントを除外するとデフォルトでは以下のようになっていました。
/etc/raddb/radiusd.conf
prefix = /usr exec_prefix = /usr sysconfdir = /etc localstatedir = /var sbindir = /usr/sbin logdir = ${localstatedir}/log/radius raddbdir = ${sysconfdir}/raddb radacctdir = ${logdir}/radacct name = radiusd confdir = ${raddbdir} modconfdir = ${confdir}/mods-config certdir = ${confdir}/certs cadir = ${confdir}/certs run_dir = ${localstatedir}/run/${name} db_dir = ${localstatedir}/lib/radiusd libdir = /usr/lib64/freeradius pidfile = ${run_dir}/${name}.pid max_request_time = 30 cleanup_delay = 5 max_requests = 1024 hostname_lookups = no log { destination = files colourise = yes file = ${logdir}/radius.log syslog_facility = daemon stripped_names = no auth = no auth_badpass = no auth_goodpass = no msg_denied = "You are already logged in - access denied" } checkrad = ${sbindir}/checkrad security { user = radiusd group = radiusd allow_core_dumps = no max_attributes = 200 reject_delay = 1 status_server = yes } proxy_requests = yes $INCLUDE proxy.conf $INCLUDE clients.conf thread pool { start_servers = 5 max_servers = 32 min_spare_servers = 3 max_spare_servers = 10 max_requests_per_server = 0 auto_limit_acct = no } modules { $INCLUDE mods-enabled/ } instantiate { } policy { $INCLUDE policy.d/ } $INCLUDE sites-enabled/
/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 localhost_ipv6 { ipv6addr = ::1 secret = testing123 }
/etc/raddb/users
DEFAULT Framed-Protocol == PPP Framed-Protocol = PPP, Framed-Compression = Van-Jacobson-TCP-IP DEFAULT Hint == "CSLIP" Framed-Protocol = SLIP, Framed-Compression = Van-Jacobson-TCP-IP DEFAULT Hint == "SLIP" Framed-Protocol = SLIP
FreeRadius の設定
以下の設定ファイルを修正します。
/etc/raddb/clients.conf
clients.conf に以下を追記します。ipaddr には「クライアントからのアクセスを許可する範囲」を指定し、secret には「Radius シークレット」を指定します。
client private { ipaddr = 10.0.0.0/8 proto = * secret = SECRET require_message_authenticator = no nas_type = other # localhost isn't usually a NAS... limit { max_connections = 16 lifetime = 0 idle_timeout = 30 } }
/etc/raddb/users
users にはユーザ情報を記載します。元の内容は消去し、以下だけを記載しました。
user1 Cleartext-Password := "password1"
FreeRadius の起動
設定が完了したら FreeRadius を起動&自動起動設定しておきます。
systemctl start radiusd systemctl enable radiusd
Radius の認証テスト
Radius のテストには radtest を使います。テスト PC 側にも freeradius-utils をインストールします。
yum -y install freeradius-utils
今回は以下の環境でテストします。
項目 | 値 |
---|---|
Radius クライアント | 10.101.0.11 |
Radius サーバ | 10.101.0.51 |
Radius シークレット | SECRET |
認証するユーザ | user1 |
パスワード | password1 |
テスト結果は以下のようになりました。
$ radtest user1 password1 10.101.0.51 0 SECRET Sending Access-Request Id 196 from 0.0.0.0:55192 to 10.101.0.51:1812 User-Name = 'user1' User-Password = 'password1' NAS-IP-Address = 127.0.0.1 NAS-Port = 0 Message-Authenticator = 0x00 Received Access-Accept Id 196 from 10.101.0.51:1812 to 10.101.0.11:55192 length 20
認証ログを取得する
認証ログを取得するには /etc/raddb/radiusd.conf の auth, auth_badpass, auth_goodpass を yes に設定し、FreeRadius を再起動して設定変更を反映します。
log { destination = files colourise = yes file = ${logdir}/radius.log syslog_facility = daemon stripped_names = no auth = yes auth_badpass = yes auth_goodpass = yes msg_denied = "You are already logged in - access denied" }