1、系统已经安装mysql的环境了,没有mysql的先装好mysql(编译安装或yum安装均可)2、yum安装freeradius软件
[root@Zabbix-Server ~]# yum install freeradius freeradius-mysql
3、创建数据库、数据库用户、导入数据(freeradius的版本是2.1.12,不同的版本可能sql文件名和位置不一样)
mysql> create database radius;mysql> grant all privileges on radius.* to radius@localhost identified by "radius";mysql> grant all privileges on radius.* to radius@127.0.0.1 identified by "radius";mysql> use radius;mysql> source /etc/raddb/sql/mysql/schema.sqlmysql> source /etc/raddb/sql/mysql/nas.sqlmysql> show tables;+------------------+| Tables_in_radius |+------------------+| nas || radacct || radcheck || radgroupcheck || radgroupreply || radpostauth || radreply || radusergroup |+------------------+8 rows in set (0.00 sec)
主数据库各字段含义:radcheck 用户检查信息表radreply 用户回复信息表radgroupcheck 用户组检查信息表radgroupreply 用户组检查信息表radusergroup 用户和组关系表radacct 计费情况表radpostauth 认证后处理信息,可以包括认证请求成功和拒绝的记录。nas 网络设备表扩展功能表,可以按需导入ippool.sql、wimax.sql wimax、cui.sql cui详细的表定义参见:http://wiki.freeradius.org/MySQL_DDL_script。4、配置、启动、验证修改/etc/raddb/site_enabled下的defoult文件(2.1.1与1.1.7不同,radius.conf被 分成了几个部分,authorize 被放在了defoult文件下,请注意),把authorize{} 、accounting {}中的sql前面的#去掉,并把authorize{} 中的files前加#,更改后的authorize{} 、accounting {}如下:
authorize { preprocess chap mschap digest suffix eap { ok = return } sql expiration logintime pap}accounting { detail unix radutmp sql exec attr_filter.accounting_response}
修改与mysql数据库连接的配置文件/etc/raddb/sql.conf,默认端口3306可以通过port参数更改,修改的部分如下:
server = "localhost" #主机login = "radius" #用户password = "radius" #密码radius_db = "radius" #数据库名
修改客户端信息配置文件:/usr/local/etc/raddb/clients.conf,默认文件只需添加shorname = localhost项:
client localhost { ipaddr = 127.0.0.1 secret = testing123 shorname = localhost require_message_authenticator = no}
修改radius的配置文件,在目录/etc/raddb/radiusd.conf中一定要取消这一行的注释:$INCLUDE sql.conf。要是在debug时出现load module的任何相关错误,都要取消radiusd.conf中的关于那一行module的注释,否则不会加载。启动radiusd,并将该服务加入开机启动项
[root@Zabbix-Server raddb]# /etc/init.d/radiusd start正在启动 radiusd: [确定][root@Zabbix-Server raddb]# chkconfig radiusd on#这样开启dubug模式[root@Zabbix-Server raddb]# radiusd -X
向mysql的radius插入测试数据并测试
mysql> insert into radcheck (username,attribute,op,value) values ('test','Cleartext-Password',':=','test');
用radtest测试test用户,密码是test(如果没有radtest命令,执行yum instll freeradius*)
[root@Zabbix-Server ~]# radtest test test localhost 0 testing123Sending Access-Request of id 53 to 127.0.0.1 port 1812User-Name = "test"User-Password = "test"NAS-IP-Address = 127.0.0.1NAS-Port = 0Message-Authenticator = 0x00000000000000000000000000000000rad_recv: Access-Accept packet from host 127.0.0.1 port 1812, id=53, length=20[root@Zabbix-Server ~]#
服务器如果返回有“Access-Accept”的字样,代表认证成功了,如果有“Access-Reject”字样则认证失败,这时可以停用radiusd服务,用命令radiusd -X开启服务从全部的debug信息中找到问题并解决。如果测试的时候发现没有找到主机的,如下:
[root@Zabbix-Server sites-enabled]# radtest test test localhost 0 testing123radclient:: Failed to find IP address for DataBakradclient: Nothing to send.
更改/etc/hosts文件添加本地主机解析记录即可
[root@Zabbix-Server sites-enabled]# cat /etc/hosts127.0.0.1 Zabbix-Server... ...... ...
文章出处:http://www.xiaomastack.com/2014/12/04/installradius/
你可以很有个性,但某些时候请收敛。