-
文件配置
<
/p>
文件是
freeradius
的核心配置
文件,其中设置了
服务器的基本信息,
配
置文件与日志文件的环境变量,
并详细配置
free
radius
模块所使用的信息,
与认证和计费
所使用模块的配置
. <
/p>
配置的变量定义的形式为
$${foo}
,
他们就在这个文件上,并且不随请
求到请求而改变
.
变量的格式参照
.
此处定义其他配置文件以及目录的位置,也就是环境变量
prefix = /usr/local
exec_prefix = $${prefix}
sysconfdir = $${prefix}/etc
localstatedir = $${prefix}/var
sbindir = $${exec_prefix}/sbin
logdir = $${localstatedir}/log/radius
raddbdir = $${sysconfdir}/raddb
radacctdir = $${logdir}/radacct
配置文件和日志文件的位置
confdir = $${raddbdir}
run_dir = $${localstatedir}/run/radiusd
日志文件的信息,添加到如下配置文件的底部
log_file = $${logdir}/
模块的位置由
libdir
来配置。
如果不能工作,那么你可以从新配置,从新
< br>Build
源码,并且使用
共享库。
pidfile:
Where to place the PID of the RADIUS
server
.
pidfile =
$${run_dir}/
user/group
如果有评论,服务器会运行
用户
/
组
启动它
.
修改用户
< br>/
组,必须具有
root
权限启
动服务
器这里的含义是指定启动
radius
< br>服务可以限定操作系统上的用户和组,
但是不建议启动它
.
#user = nobody
#group = nobody
最长请求时间
(
秒
)
< br>,这样的问题经常需要存在在应用
SQL
数据库时候,建
议设置为
5
秒到
120
秒之间
.
max_request_time =
30
当请求超过最长请求时间的时候,可以设置服务器删除
请求
.
当你的服务在
threaded
(
线程
下
)
运
行,或者
线程池
(thread
pool)
模式,建议这里设置为
no.
但用
threaded
服务设
置
为
yes
时,有可能使服务器崩溃
.
delete_blocked_requests = no
在
reply
发送给
NAS
后的等待清空时间
.
建议
2
秒
到
10
秒
cleanup_delay = 5
服务器的请求最大数
,建议值
256
到无穷
max_requests
= 1024
让服务器监听某个
I
P
,并且从次
IP
发送
相应
信息
.
主要是为了
服务器同时具有多服务
器时候使用
.
bind_address = *
可以指定
raidus
的使用端口号,使用
< br>0
表示使用默认的
radius
端口,
在配置文件
/etc/services
配置
.
port = 0
如果需要服务器
同时监听其他的
IP
,可以用
list
en
块
.
下面是例子
#listen {
# IP address on
which to listen.
# Allowed values are:
# dotted quad (1.2.3.4)
#
hostname ()
# wildcard (*)
#
ipaddr = *
# Port on which to listen.
# Allowed values are:
#
integer port number (1812)
# 0 means
# port = 0
# Type of packets
to listen for
.
# Allowed
values are:
# auth listen for
authentication packets
# acct listen
for accounting packets
#
#
type = auth
#}
h
ostname_lookups
大概是表示为
NAS
查找它的域名信息
?
可以通过域名配置
NAS?
hostname_lookups = no
是否允许
core dumps.
allow_core_dumps
= no
expressions
支持,规则和扩展
.
regular_expressions = yes
extended_expressions = yes
记录
User-
Name
属性的全称
.
log_stripped_names = no
是否记录认证请求信息到日志文件
log_auth = no
当请求被拒绝时记录密码,
当请求正确时记录密码
log_auth_badpass = no
log_auth_goodpass = no
是否允许用户名冲突,即重复同用户同时登陆
.
强烈不建议启用重复用户
.
usercollide =
no
将用户名
小写化,
将密码小写化
.
lower_user = no
lower_pass =
no
是否去除用户名和密码中的空格
nospace_user = no
nospace_pass = no
程序执行并发检查
(
不理解含义
)
checkrad = $${sbindir}/checkrad
安全
配置
域
security {
指在
Radi
us
包中的最大属性数目
.
设置为
p>
0
表示无穷大
.
max_attributes = 200
发送
Access-Reject
包时候,可以设置一定的延迟,以缓慢
DOS
< br>攻击,也可以缓慢穷举
破解用户名和密码的攻击
reject_delay = 1
服务器是否对状态服务器的请求信息进行相应
.
status_server = no
}
PROXY CONFIGURATION
代理域
.
是否开启代理服务,具体配置参照
$${confdir}/
proxy_requests =
yes
$$INCLUDE $${confdir}/
Clients
配置
$$INCLUDE $${confdir}/
是否启用
snmp
配置,具体配置文件在
snmp = no
$$INCLUDE
$${confdir}/
线程池
配置
域
thread pool {
启动时服务的个数
.(
在启动
Mysql
模块
后可以明显看到
.)
当同时进行的请求数超过
< br>5
个时,
会增加线程服务
.
start_servers = 5
最大的服务数
max_servers = 32
当少于最少空闲服务时,它会建立服务,大于最大空闲服务时会停止多余的服务
.
p>
最少空闲
服务,与最大空闲服务
.
min_spare_servers = 3
max_spare_servers = 10
每个
server
最大的请求数
.
当有内存漏洞时,可能需要配置
.
max_requests_per_server = 0
}
1.3
模块配置
1.3.1 PAP
模块
# Supports
multiple encryption schemes
支持多种加密方式
# clear: Clear text
明文
#
crypt: Unix crypt Unix
加密
# md5: MD5 ecnryption
MD5
加密
# sha1: SHA1 encryption.
SHA1
加密
# DEFAULT: crypt
默认是
< br>Unix
加密
pap {
encryption_scheme = crypt
}
1.3.2
CHAP
模块
chap {
authtype = CHAP
}
1.3.3
PAM
模块
PAM
模块
(PAM)
是行业标准验证框架,
鉴
于很多系统的
PAM
库都有内存漏洞,
所以不建
议使用。
pam {
pam_auth =
radiusd
}
1.3.4 UNIX
系统用户的
认证模块
unix {
cache = no
cache_reload =
600
# passwd = /etc/passwd
#
shadow = /etc/shadow
# group =
/etc/group
radwtmp =
$${logdir}/radwtmp
}
1.3.5
EAP
模块
详细见
$${confdir}/
$$INCLUDE $${confdir}/
1.3.6 MSCHAP
模块
mschap {
#use_mppe = no
#require_encryption = yes
#require_strong = yes
#
为了纠正
window
发送
chap
时有时包括域,有时又不包括域的信
息
.
#with_ntdomain_hack =
no#ntlm_auth =
–
request-nt-
key
–
username=%{Stripped-
User-Name:-%{User-Name:-None}}
–
challenge=%{mschap:Challenge:-00}
–
nt-response=%{mschap:NT-
Response:-00}
}
1.3.7 LDAP
配置
模块
LDAP
模块只能在
Access-
Request packet
中包含明文密码属性才可以被使用。
< br>LDAP
认证不能在其他任何认证方法中使用。具体配置详见下属章节。
(参看
doc/rlm_ldap
)
。
1.3.8
passwd
模块
Passwd<
/p>
模块允许通过任何
passwd
样式的文
件进行授权,并可以从这些模块中提取属性
信息。
smbpasswd
例子
#passwd etc_smbpasswd {
# filename = /etc/smbpasswd
# format =
#
authtype = MS-CHAP
# hashsize = 100
# ignorenislike = no
#
allowmultiplekeys = no
#}
#passwd etc_group {
# filename = /etc/group
# format =
,
User-
Name
# hashsize = 50
#
ignorenislike = yes
# allowmultiplekeys
= yes
# delimiter =
#}
1.3.9 Realm
模块
应用在代理上
. You can have
multiple instances of the realm module to support
multiple realm syntaxs at the same
time. The search order is defined by the
order in the authorize and preacct
sections.
realm IPASS {
format = prefix
delimiter =
ignore_default = no
ignore_null = no
}
#
?
us
ername@realm
?
#
realm suffix {
format = suffix
delimiter =
ignore_default = no
ignore_null = no
}
#
?
us
ername%realm
?
#
realm realmpercent {
format = suffix
delimiter =
ignore_default = no
ignore_null = no
}
#
?
do
mainuser
?
#
realm ntdomain
{
format = prefix
delimiter =
ignore_default =
no
ignore_null = no
}
1.3.10
简单值检查模块
(checkval)
It can be used to check if an attribute
value in the request matches a (possibly
multi valued) attribute in the check
items This can be used for example for
caller-id authentication. For the
module to run
,
both the request attribute and
the check items attribute must exist.
checkval {
# The attribute
to look for in the request
#
Request
包中查找的属性名称
item-name = Calling-Station-Id
# The attribute to look for in check
items. Can be multi valued
# Check
表中查找的属性名称
check-
name = Calling-Station-Id
# The data
type. Can be
#
数据类型的种类
# string<
/p>
,
integer
,
ipaddr
,
date
,
abinary
,
octets
data-type = string
# If set
to yes and we dont find the item-name attribute in
the
# request then we send back a
reject
#
如果设置为
yes
,我们不在
request
包中查找属
性名称直接发送
reject.
# DEFAULT is
no
#notfound-reject = no
}
1.3.11
从写属性模块
(attr_rewrite)
从写任何包,在认证和计费时都很有用
.
在拿到包后,
可以从写包里属性的内容
.
#attr_rewrite
sanecallerid {
# attribute = Called-
Station-Id
# may be
,
,
,
# searchin = packet
# searchfor =
# replacewith
=
# ignore_case = no
#
new_attribute = no
# max_matches = 10
# ## If set to yes then the replace
string will be appended to the original string
# append = no
#}
1.3.12
预处理
radius<
/p>
请求模块
(preprocess)
预
处理
Radius
请求,在交付其他模块处理前
.
包含这两个配置文件
.
可以从写那些由一些
NAS
添加的很奇怪的属性
.
然后把这些属性转换到一个形态。参见第二章。
配置实例
:
preprocess {
huntgroups =
$${confdir}/huntgroups
hints =
$${confdir}/hints
with_ascend_hack = no
ascend_channels_per_line = 23
with_ntdomain_hack = no
with_specialix_jetstream_hack = no
with_cisco_vsa_hack = no
}
1.3.13
用户文件模块
(files)
files {
usersfile =
$${confdir}/users
acctusersfile =
$${confdir}/acct_users
preproxy_usersfile =
$${confdir}/preproxy_users
compat = no
}
1.3.14
日志信息记录模块
(detail)
将计费信息详细记录到文件上,按照设定时间,每隔一个时段生成一个新文件记录
.
detail {
detailfile =
$${radacctdir}/%{Client-IP-Address}/detail-%Y%m%d
detailperm = 0600
#suppress
{
# User-Password
#}
}
将认证信息详细记录到文件上,
按照设定时间,每隔一个时段生成一个新文件记录
.
detail auth_log {
detailfile
= $${radacctdir}/%{Client-IP-Address}/auth-
detail-%Y%m%d
This MUST be
0600
,
otherwise
anyone can read
the users passwords!
detailperm = 0600
}
将相应
(Reply)
信息详细记录到文件上,按照设定时间,每隔一个时段生成一个新文件记录
detail reply_log {
detailfile = $${radacctdir}/%{Client-IP-
Address}/reply-detail-%Y%m%d
This MUST
be 0600
,
otherwise anyone can read
the users passwords!
detailperm = 0600
}
This module logs packets
proxied to a home server
.
detail pre_proxy_log {
detailfile = $${radacctdir}/%{Client-IP-
Address}/pre-proxy-detail-%Y%m%d
This
MUST be 0600
,
otherwise anyone can read
the users passwords!
detailperm = 0600
}
This module logs response
packets from a home server
.
detail post_proxy_log {
detailfile = $${radacctdir}/%{Client-IP-
Address}/post-proxy-detail-%Y%m%d
This
MUST be 0600
,
otherwise anyone can read
the users passwords!
detailperm = 0600
}
1.3.15
SQL
日志记录模块
(sql_log)
The rlm_sql_log module appends the SQL
queries in a log file which is read later
by the radsqlrelay program.
它只是将
sql
语句写到文件里,而后由
radsqlrelay
程序读取
.
参看
1.3.16
计费唯一
sessio
nid
模块
针对
NAS
不停重复
Acct-Session-Id val
ues
造成混淆的问题,
建立唯一的计费
sessionid
acct_unique {
key
=
,
Acct-Session-
Id
,
NAS-IP-
Address
,
Client-
IP-Address
,
NAS-
Port
}
1.3.17
SQL
模块
通过
$$INCLUDE
来把数据库的模块的配置文件链接进来
.
# The following configuration file is
for use with MySQL.
#
# For
Postgresql
,
use:
$${confdir}/
# For MS-
SQL
,
use:
$${confdir}/
# For
Oracle
,
use:
$${confdir}/
$$INCLUDE $${confdir}/
1.3.18
Radutmp
模块
记录了那些在线用户的用户名,以及他们从哪里登陆的信息
.
实例
1 radutmp
radutmp {
filename =
$${logdir}/radutmp
username = %{User-
Name}
case_sensitive = yes
check_with_nas = yes
perm =
0600
callerid =
}
实例
2
radutmp sradutmp {
filename
= $${logdir}/sradutmp
perm = 0644
callerid =
}
1.3.19
属性过滤模块
属性过滤模块,过滤从
代理
raidus
服务器那里收到响应信息里的属性,来确保我
们可以发
送回给我们的
Radius
客
户端,详细见
attrs
配置文件
.
attr_filter {
attrsfile =
$${confdir}/attrs
}
1.3.20
计数模块
从计费包信息中拿去一个属性及它的值,统计这个属性不同值的总数
.
counter daily {
filename =
$${raddbdir}/
key = User-Name
count-attribute = Acct-Session-Time
reset = daily
counter-name =
Daily-Session-Time
check-name = Max-
Daily-Session
allowed-servicetype =
Framed-User
cache-size = 5000
}
1.3.21
SQL
计数模块
该模块所需要的信息
都储存
raddacct
表中。
它并不
进行在数据库中插入数据项和更新数据
项,它完全依赖
SQL<
/p>
模块来处理计费信息包。
(具体请参照
S
QL
模块配置分析第七章)
例
1
sqlcounter dailycounter {
counter-name = Daily-Session-Time
check-name = Max-Daily-Session
sqlmod-inst = sql
key =
User-Name
reset = daily
query =
GREATEST((%b - UNIX_
TIMESTAMP(AcctStartTime))
,
0))
FROM radacct WHERE User
Name=
?
%{%k}
?
AND
UNIX_TIMESTAMP(AcctStartTime) +
AcctSessionTime >
?
%b
?
}
例
2
sqlcounter
monthlycounter {
counter-name =
Monthly-Session-Time
check-name = Max-
Monthly-Session
sqlmod-inst = sql
key = User-Name
reset =
monthly
query =
GREATEST((%b
- UNIX_TIMESTAMP(AcctStartTime))
,
0))
FROM radacct
WHERE UserName=
?
%{%k}
?
AND
UNIX_TIMESTAMP(AcctStartTime) +
AcctSessionTime >
?
%b
?
}
1.3.22
Always
模块
为了测试用的
p>
Always
模块,不做任何事情
.
always fail {
rcode = fail
}
always reject
{
rcode = reject
}
always ok {
rcode = ok
simulcount = 0
mpp = no
}
1.3.23
Expression
模块
(expr)
This module is useful only for
< br>?
xlat
?
.
expr {
}
1.3.24
Digest
模块
目前没有配置
.
1.3.25
外部程序执行模块
(exec)
This module is useful only for
?
xlat
?
可以将外界程序运行的结果赋予给属性值
.
如
:Attribute-Name =
`%{exec:/path/to/program args}`
exec {
wait = yes
input_pairs = request
}
例
This is a more
general example of the execute module.
exec echo {
wait = yes
program =
input_pairs =
request
output_pairs = reply
}
IP
地址池模块
服务器端
IP
地址池管理,应该在
post-auth
和
accounting
< br>域应该被添加
.
例
:
ippool
main_pool {
range-start = 192.168.1.1
range-stop = 192.168.3.254
netmask = 255.255.255.0
cache-size = 800
session-db
= $${raddbdir}/
ip-index = $${raddbdir}/x
override = no
maximum-
timeout = 0
}
1.4
关键域
1.4.1
实例化域
(Instantiation)
< br>这部分的目的是装载模块,那些被列在该域的模块讲在
authorize
,
authenticate
,等域
之前装载
.
本部分并不是必须步骤
.
instantiate {
exec
expr
}
1.4.2 authorize
域
The preprocess module takes care of
sanitizing some bizarre attributes in the