这次主要来看看 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拓展

  1. mods-available/python 软连接到 mods-enabled/python

  2. 编辑 mods-enabled/python文件,这里是配置不同阶段使用那些python模块的地方,我这里只要去掉 #func_authorize = authorize这行的注释即可

  3. 指定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作为计费表为例子。

  1. 调整mysql中计费表的字段

  2. /mods-enabled/sql 中要设置mysql数据库, 否则还是加载默认的sqlite

  3. 修改 mods-config/sql/main/mysql/queries.conf 里的insert和update语句,根据已经有语句的作为参照语法,调整sql即可。

  4. 修改完之后 使用 radiusd -Xx 来启动,如果语法正确是可以正常启动的,否则会报错。

  5. 接着就可以用 radclient 来模拟认证请求测试了。

最新文章

  1. git 查看远程分支、本地分支、创建分支、把分支推到远程repository、删除本地分支
  2. Windows 10 周年更新正式版下载 + win10 快捷键
  3. 流媒体一些server
  4. js定义变量需赋予初始值
  5. jquery的$.extend和$.fn.extend作用及区别
  6. 一些xcode5.1创建的工程在xcode6.0下不能编译的问题
  7. Object-C中的内存管理小记
  8. python 装饰器简介
  9. 关于phpcms中模块_tag.class.php中的pc_tag()方法的含义
  10. 九天学会Java,第二天,算术运算
  11. hbase thrift 访问队列
  12. opencv利用hough概率变换拟合得到直线后,利用DDA算法得到直线上的像素点坐标
  13. Java语言基础之数组
  14. IDEA永久激活方法
  15. GreenDao 使用和数据库升级
  16. Using Spring.net in console application
  17. chromedriver与chrome版本映射表(更新至v2.30)
  18. 2.6 CMMI2级——供应商协议管理(Supplier Agreement Management)
  19. Vue学习笔记之Nodejs入门
  20. c++中指针常量,常指针,指向常量的常指针区分

热门文章

  1. 关于bootstrap在IE8下不能支持自适应的问题
  2. Android自定义View(一、初体验自定义TextView)
  3. collection 中对类排序
  4. 【Netty源码分析】ChannelPipeline(二)
  5. [ExtJS5学习笔记]第十六节 Extjs5使用panel新增的ViewModel属性绑定数据
  6. java的list几种实现方式的效率(ArrayList、LinkedList、Vector、Stack),以及 java时间戳的三种获取方式比较
  7. 02Framelayout:帧布局
  8. Git工程迁移方法总结(命令行)
  9. python的operator.itemgetter('click')用于定义获取'click'项的函数
  10. java linux 项目经常无故被关闭 进程无故消息