分类: LINUX
2011-11-07 16:45:35
Step 1:安装 Mysql
#groupadd mysql
#useradd mysql -g mysql
#sudo apt-get install mysql-server
这里会提示你为root用户设置密码,这里可以暂设为123456
Step2:安装freeradius-server-2.1.8
将freeradius-server-2.1.8.tar.gz 放至/software/下
#cd /software
#tar -zxvf freeradius-server-2.1.8.tar.gz
#cd freeradius-server-2.1.8
#./configure
#make
#make install
#radiusd -X
这里出现了error while loading shared libraries: libfreeradius-radius-2.1.8.so
其实在言下之意就是缺少一个叫做libfreeradius-radius-2.1.8.so的库文件,经查找发现这个库存在于/usr/local/lib目录下
采取的解决方式是将/usr/local/lib添加到/etc/ld.so.conf中
ld.so.conf文件内容如下:
include /etc/ld.so.conf.d/*.conf
添加一行 /usr/local/lib
完成后输入/sbin/ldconfig,再重新进行上面步骤。
出现以下信息说明安装成功。
Listening on authentication address * port 1812
Listening on accounting address * port 1813
Listening on command file /usr/local/var/run/radiusd/radiusd.sock
Listening on proxy address * port 1814
Ready to process requests.
Ldconfig命令是将/etc/ld.so.conf列出的路径下的库文件缓存到/etc/ld.so.cache以供使用。
Step3:配置mysql和freeradius
#mysql -uroot -p123456
mysql>create database radius
mysql>quit
#cd /software/freeradius-server-2.1.8/raddb/sql/mysql
#mysql -uroot -p123456 radius < schema.sql
接着:
更改/usr/local/etc/raddb/sites-available/default文件,使其支持sql
把 sql前的#去掉
authorize {
preprocess
chap
mschap
suffix
sql
}
accouting {
….
sql
…
}
更改/usr/local/etc/raddb/sql.Conf使其与mysql连接
server=”localhost”
login=”root”
password=”mysql的root的密码”
radius_db=”radius”
再更改/usr/local/etc/raddb/radiusd.conf
将$INCLUDE sql.conf前的#去掉
数据库加入测试账号
加入组:
mysql –uroot –p密码 radius
insert into radgroupreply (groupname,attribute,op,value) values (‘user’,‘Auth-Type’,’:=’,’Local’);
insert into radgroupreply (groupname,attribute,op,value) values (‘user’,‘Service-Type’,’:=’,’Framed-User’);
insert into radgroupreply (groupname,attribute,op,value) values (‘user’,‘Framed-IP-Address’,’:=’,’255.255.255.254’);
insert into radgroupreply (groupname,attribute,op,value) values (‘user’,‘Framed-IP-Netmask’,’:=’,’255.255.255.0’);
加入测试账号:
insert into radcheck (username,attribute,op,value) values (‘test’,’User-Password’,’:=’,’test’)
测试账号加入组:
insert into radusergroup (username,groupname) values (‘test’,’user’);
接着需要下载一个freeradius-mysql
#sudo apt-get install freeradius-mysql
然后到/usr/lib/freeradius将rlm_sql_mysql-2.1.0.so复制到/usr/lib下并改名为 rlm_sql_mysql.so
#cp /usr/lib/freeradius/rlm_sql_mysql_2.1.0.so /usr/lib
#mv rlm_sql_mysql_2.1.0.so rlm_sql_mysql.so
#radiusd -X
Listening on authentication address * port 1812
Listening on accounting address * port 1813
Listening on command file /usr/local/var/run/radiusd/radiusd.sock
Listening on proxy address * port 1814
Ready to process requests.
打开另一个终端:
#radtest test test localhost 0 testing123
这时会出现服务器没有响应的提示,这是由于ipv6的影响,将/etc/hosts文件中的::1前加上#再运行以上命令。出现以下信息说明配置成功。
Sending Access-Request of id 34 to 127.0.0.1 port 1812
User-Name = "test"
User-Password = "test"
NAS-IP-Address = 127.0.1.1
NAS-Port = 0
rad_recv: Access-Accept packet from host 127.0.0.1 port 1812, id=34, length=38
Service-Type = Framed-User
Framed-IP-Address = 255.255.255.254
Framed-IP-Netmask = 255.255.255.0