freeradius 区分PPTP,PPPOE和派克斯账号
本帖最后由 jike106397 于 2015-12-26 17:08 编辑最近一个项目需要,在同一台RADIUS服务器上,对接了VPN服务器,PPPOE服务器和派克斯VPN服务器,需要对每种资源的账号分开来。由于没有区分NAS,所以只能从账号上下手了。
没有找到FREERADIUS相关的简便方法,后来对比RM发现可以用C做个额外的认证程序,做好了有担心用户量打是性能问题。最终决定用freeradius子带的unlang来做
实现三种账号类型对应服务的分开
1、freeradius的radusergroup表中增加了usertype字段,值得类型是数字
0 所有类型服务都可以使用
1 PPTP账号
2 PPPOE账号
3 派克斯账号
在/raddb/site-enabled/default 的authorise字段的最后PAP模块后加以下代码
update reply {
Reply-Message:="%{sql:select usertype from radusergroup where username='%{User-Name}' limit 1}"
}
if(reply:Reply-Message!="0") {
if(NAS-Port) {
if(NAS-Port-Id){
if (reply:Reply-Message!="2") {
update control {
Auth-Type:=reject
}
update reply {
Reply-Message:="不是PPPOE用户"
}
}
}
else {
if (reply:Reply-Message!="1") {
update control {
Auth-Type:=reject
}
update reply {
Reply-Message:="不是PPTP用户"
}
}
}
}
else {
if (reply:Reply-Message!="3") {
update control {
Auth-Type:=reject
}
update reply {
Reply-Message:="不是packetix用户"
}
}
}
}
这样,当认证时就能把账号分开了
更多技术文章,请访问 http://blog.dshoub.com
不错学习了
页:
[1]