Hyper-Vを利用したサーバ検証環境の構築 その5 RADIUS構築と動作確認
1. 前書き
前回の続きです。
前回まででやっと開発環境が整った!
今回はinternalにRADIUSを構築します。動作確認までです。
2.構成
ubuntuにfreeRADIUSをインストールしていきます。
またRADIUSの確認のためのスイッチを追加します。
3.freeRADIUSのインストール
ubuntuのインストールは前回を参考に。インストール時にProxy入力があるのでそちらを追加で入力しています。
公式のドキュメントを参考に、freeRADIUSをインストールして動作確認します。
まずはインストール
公式はapt-get
でしたが、apt
でもインストールできました。
user@radius:/$ sudo apt install freeradius
動作しているか確認します。
user@radius:/$ sudo systemctl status freeradius ● freeradius.service - FreeRADIUS multi-protocol policy server Loaded: loaded (/lib/systemd/system/freeradius.service; enabled; vendor preset: enabled) Active: active (running) since Tue 2023-08-22 01:08:00 UTC; 18min ago Docs: man:radiusd(8) man:radiusd.conf(5) http://wiki.freeradius.org/ http://networkradius.com/doc/ Process: 5111 ExecStartPre=/usr/sbin/freeradius $FREERADIUS_OPTIONS -Cx -lstdout (code=exited, status=0/SUCCESS) Main PID: 5113 (freeradius) Status: "Processing requests" Tasks: 6 (limit: 4555) Memory: 78.7M (limit: 2.0G) CPU: 265ms CGroup: /system.slice/freeradius.service mq5113 /usr/sbin/freeradius -f Aug 22 01:08:00 radius freeradius[5111]: Compiling Post-Auth-Type Challenge for attr Post-Auth-Type Aug 22 01:08:00 radius freeradius[5111]: Compiling Post-Auth-Type Client-Lost for attr Post-Auth-Type Aug 22 01:08:00 radius freeradius[5111]: Compiling Auth-Type PAP for attr Auth-Type Aug 22 01:08:00 radius freeradius[5111]: Compiling Auth-Type CHAP for attr Auth-Type Aug 22 01:08:00 radius freeradius[5111]: Compiling Auth-Type MS-CHAP for attr Auth-Type Aug 22 01:08:00 radius freeradius[5111]: # Skipping contents of 'if' as it is always 'false' -- /etc/freeradius/3.0/sites-enabled/inner-tunnel:336 Aug 22 01:08:00 radius freeradius[5111]: Compiling Post-Auth-Type REJECT for attr Post-Auth-Type Aug 22 01:08:00 radius freeradius[5111]: radiusd: #### Skipping IP addresses and Ports #### Aug 22 01:08:00 radius freeradius[5111]: Configuration appears to be OK Aug 22 01:08:00 radius systemd[1]: Started FreeRADIUS multi-protocol policy server.
初期テスト
公式のテストを実施してみます。/etc/freeradius/3.0/mods-config/files
にあるauthorize
の1行目に以下を追加します。
user@radius:/$ sudo vi /etc/freeradius/3.0/mods-config/files/authorize
+ testing Cleartext-Password := "password" # # Configuration file for the rlm_files module. # Please see rlm_files(5) manpage for more information.
接続アドレスの許可を変更します。
user@radius:/$ sudo vi /etc/freeradius/3.0/clients.conf
client localhost { # Only *one* of ipaddr, ipv4addr, ipv6addr may be specified for # a client. # # ipaddr will accept IPv4 or IPv6 addresses with optional CIDR # notation '/<mask>' to specify ranges. # # ipaddr will accept domain names e.g. example.org resolving # them via DNS. # # If both A and AAAA records are found, A records will be # used in preference to AAAA. - ipaddr = 127.0.0.1 + ipaddr = 10.24.2.0/24
一度freeradiusを再起動し、接続のテストをします。
user@radius:/$ sudo systemctl restart freeradius
接続テストのコマンドはradtestを使用します。
radtest <ユーザ名> <パスワード> <RADIUSのIP> <port番号> <共有シークレット>を入力します。
共有シークレットは/etc/freeradius/3.0/clients.conf
にデフォルトが記載されていました。
# The default secret below is only for testing, and should # not be used in any real environment. # secret = testing123
user@radius:~$ radtest testing password 10.24.2.10 0 testing123 Sent Access-Request Id 145 from 0.0.0.0:38963 to 10.24.2.10:1812 length 77 User-Name = "testing" User-Password = "password" NAS-IP-Address = 127.0.1.1 NAS-Port = 0 Message-Authenticator = 0x00 Cleartext-Password = "password" Received Access-Accept Id 145 from 10.24.2.10:1812 to 10.24.2.10:38963 length 20
無事Access-Accept
が表示されました。RADIUSが動作しています。
4.VyOSの認証先にRADIUSを追加
RADIUS認証を確認するためのスイッチを作成します。
vyos@internalSW# set interfaces ethernet eth0 address 10.24.2.12/24 vyos@internalSW# set protocols static route 0.0.0.0/0 next-hop 10.24.2.2 vyos@internalSW# set system login radius-server 10.24.2.10 port 1812 vyos@internalSW# set system login radius-server 10.24.2.10 secret testing123 vyos@internalSW# set system login radius-server 10.24.2.10 timeout 5
SSHでログイン時に、RADIUSで設定したユーザを指定し、ログインできるか確認します。
$ ssh testing@10.24.2.12 Welcome to VyOS testing@10.24.2.12's password: Welcome to VyOS! Check out project news at https://blog.vyos.io and feel free to report bugs at https://phabricator.vyos.net You can change this banner using "set system login banner post-login" command. VyOS is a free software distribution that includes multiple components, you can check individual component licenses under /usr/share/doc/*/copyright Last login: Tue Aug 22 18:09:08 2023 from 10.24.2.14 testing@internalSW>
無事ログインができました。しかし、特権は所持していないようです。
testing@internalSW> Possible completions: clear Clear system information connect Establish a connection delete Delete an object disconnect Take down a connection force Force an operation monitor Monitor system information ping Send IPv4 or IPv6 ICMP (Internet Control Message Protocol) echo requests release Release specified variable renew Renew specified variable reset Reset a service set Set operational options show Show system information telnet Telnet to a node traceroute Track network path to node update Update data for a service
5.特権を付与
RADIUSのユーザ設定で以下を追加します。
/etc/freeradius/3.0/mods-config/files
にあるauthorize
に追加したユーザに、設定を追加します。
user@radius:/$ sudo vi /etc/freeradius/3.0/mods-config/files/authorize
testing Cleartext-Password := "password" + Cisco-AVPair = "shell:priv-lvl=15" # # Configuration file for the rlm_files module. # Please see rlm_files(5) manpage for more information.
これで特権が付きました。
testing@internalSW:~$ configure [edit] testing@internalSW#
次回はAzureADとの連携を検証予定です。