【freeradius3】安装和拓展需求
2024-10-16 16:40:57
这次主要来看看 freeradius的安装,以及Python拓展的例子,还有计费字段根据厂家进行拓展。
3.0版本的安装
yum install libtalloc-devel
wget -c ftp://ftp.freeradius.org/pub/freeradius/freeradius-server-3.0.11.tar.gz
tar zxvf freeradius-server-3.0.11.tar.gz
cd freeradius-server-3.0.11
./configure
make
make install
ldconfig
如果需要用mysql 和 python拓展 yum 安装下 python-devel, mysql-devel
默认的安装位置 /usr/local/etc/raddb/
开启python拓展
把
mods-available/python
软连接到mods-enabled/python
编辑 mods-enabled/python文件,这里是配置不同阶段使用那些python模块的地方,我这里只要去掉
#func_authorize = authorize
这行的注释即可指定python的路径
export PYTHONPATH='/usr/local/etc/raddb/mods-config/python'
由于只启用了认证的部分,默认的配置的还是example.py 文件,所以这里就用这部分来实验下。
打印一些操作信息
def authorize(p):
print "*** authorize ***"
print
radiusd.radlog(radiusd.L_INFO, '*** radlog call in authorize llllll***')
print
print p
print sys.path
print os.getcwd()
radiusd.radlog(radiusd.L_INFO, '*** python part end ***')
return radiusd.RLM_MODULE_OK
自定义reply
def authorize(p):
print "*** authorize ***"
print
radiusd.radlog(radiusd.L_INFO, '*** radlog call in authorize llllll***')
print
print p
reply = (('Reply-Message', ':=', 'Hello from rlm_python'),
('Benu-Redirection-URL', ':=', 'http://baidu.com'),)
config = (('Cleartext-Password', 'benu123'),)
radiusd.radlog(radiusd.L_INFO, '*** python part end ***')
return (radiusd.RLM_MODULE_OK, reply, config)
config 配置的是用户的密码, 来看下测试结果
# echo "User-Name=cc:ff:ff:ff:ff,User-Password=benu123" |radclient 127.0.0.1:1812 auth testing123 -x
Sent Access-Request Id 182 from 0.0.0.0:48733 to 127.0.0.1:1812 length 54
User-Name = "cc:ff:ff:ff:ff"
User-Password = "benu123"
Cleartext-Password = "benu123"
Received Access-Accept Id 182 from 127.0.0.1:1812 to 0.0.0.0:0 length 67
Reply-Message = "Hello from rlm_python"
Benu-Redirection-URL = "http://baidu.com"
拓展计费表字段
以mysql作为计费表为例子。
调整mysql中计费表的字段
/mods-enabled/sql
中要设置mysql数据库, 否则还是加载默认的sqlite修改
mods-config/sql/main/mysql/queries.conf
里的insert和update语句,根据已经有语句的作为参照语法,调整sql即可。修改完之后 使用
radiusd -Xx
来启动,如果语法正确是可以正常启动的,否则会报错。接着就可以用 radclient 来模拟认证请求测试了。
最新文章
- git 查看远程分支、本地分支、创建分支、把分支推到远程repository、删除本地分支
- Windows 10 周年更新正式版下载 + win10 快捷键
- 流媒体一些server
- js定义变量需赋予初始值
- jquery的$.extend和$.fn.extend作用及区别
- 一些xcode5.1创建的工程在xcode6.0下不能编译的问题
- Object-C中的内存管理小记
- python 装饰器简介
- 关于phpcms中模块_tag.class.php中的pc_tag()方法的含义
- 九天学会Java,第二天,算术运算
- hbase thrift 访问队列
- opencv利用hough概率变换拟合得到直线后,利用DDA算法得到直线上的像素点坐标
- Java语言基础之数组
- IDEA永久激活方法
- GreenDao 使用和数据库升级
- Using Spring.net in console application
- chromedriver与chrome版本映射表(更新至v2.30)
- 2.6 CMMI2级——供应商协议管理(Supplier Agreement Management)
- Vue学习笔记之Nodejs入门
- c++中指针常量,常指针,指向常量的常指针区分
热门文章
- 关于bootstrap在IE8下不能支持自适应的问题
- Android自定义View(一、初体验自定义TextView)
- collection 中对类排序
- 【Netty源码分析】ChannelPipeline(二)
- [ExtJS5学习笔记]第十六节 Extjs5使用panel新增的ViewModel属性绑定数据
- java的list几种实现方式的效率(ArrayList、LinkedList、Vector、Stack),以及 java时间戳的三种获取方式比较
- 02Framelayout:帧布局
- Git工程迁移方法总结(命令行)
- python的operator.itemgetter('click')用于定义获取'click'项的函数
- java linux 项目经常无故被关闭 进程无故消息