freeRadius配置2

FREERADIUS验证配置

1. FREERADIUS简介

FREERADIUS是一套开源,免费的完全兼容RADIUS协议的RADIUS服务器/客户端软件,可以用它对用户的接入和访问特定的网络进行有效的控制,授权,计费等等,它支持多种验证,包括文件,LDAP,以及主流的支持SQL的数据库(ORACLE,MYSQL,DB2等等).我们可以使用FREERADIUS来搭建一个3A认证的服务器,下面对详细介绍如何配置FREERADIUS.

2. FREERADIUS配置

2.1 安装FREERADIUS

首先从FREERADIUS的官方网站上下载最新的FREERADIUS的安装包,网址是:

http://www.freeradius.org/press/index.html#1.1.5

安装包一般被命名为freeradius-1.1.x.tar.gz,其中X是带表其版本号,根据不同的发布时间,其值将会有所不同,这里我们以freeradius-1.1.5的安装包为例.

1. 从官方网站上下载安装包至操作系统的某个目录下.

2. 执行gunzip freeradius-1.1.5 对安装包进行解压.此安装包变成了freeradius-1.1.5.tar.

3. 执行tar –xzf freeradius-1.1.5.tar对其进行解包,将在本目录下生成一个freeradius-1.1.5的文件夹.

4. 进入此文件夹. 执行cd freeradius-1.1.5 并执行安装配置命令./configure.

5. 编译安装包.执行 make.

6. 安装radius . 执行 make install.

至此,FREERADIUS的安装过程就已经结束了,如果你是严格安装以上的顺序进行安装的那么,FREERADIUS将被默认安装在/usr/local的目录下,其中,在/usr/local/etc/raddb的目录下存放的是FREERADIUS的配置文件,/usr/local/bin下面存放的是FREERADIUS的常用命令.另外,在FREERADIUS的安装包文件夹的DOC目录下存放有大量的关于FREERADIUS的说明文档资料,有兴趣的话可以去看看.

2.2 启动和停止RADIUS的服务

1. 启动radius服务

FREERADIUS的启动分为两种模式,一种是DEBUG模式,另一种是正常启动模式.其中前者

用于观察RADIUS的运行情况,可以对验证请求的整个过程进行监测,从NAS发出验证请求到服务器回应验证的结果的这段时间内,服务器做了哪些事情,我们都可以通过DEBUG模式进行观察到.后者就是单纯的启动RADIUS的服务,一般在后台运行,等待并处理NAS发出的验证请求.

要启动DEBUG模式,可以在系统终端下的命令行中执行:radius –X 其中参数X代表以DUBUG模式启动.

要正常启动,可以在系统终端下的命令行中执行:radius.

2. 停止radius服务

在DEBUG模式下启动的RADIUS服务可以按键盘的CTRL+C来终止.

正常启动的RADIUS服务可以按照以下步骤来终止:

1. 执行 ps –ef 来调出当前正在运行的所有进程,找到其中名为radiusd的进程,记住进程号.这里我们假设进程ID为1234.

2. 执行kill -9 1234 来直接终止RADIUS的服务进程.

2.3 配置RADIUS服务

1. 配置NASLIST文件

进入目录/usr/local/etc/raddb 运行vi naslist来进行编辑,添加:

localhost local portslave

2. 配置USR文件

运行 vi users 来进行编辑user文件,最尾端添加:

“test” Auth-Type := Local,User-Password == “test”

3. 配置RADIUSD.CONF文件

运行 vi radius.conf 来编辑radiusd.conf文件.找到authorize部分,确认file块没有被注释

Authorize {

……

files

……

}

4. 配置CLIENTS.CONF文件

运行vi clients.conf 来编辑 clients.conf文件,找到本地配置,修改为:

client 127.0.0.1{

secret = testing123

shortname = localhost

nastype = other

}

5. 测试配置的结果

首先启动RADIUS服务,(DEBUG模式启动需要另开登录窗口进行测试).

运行 radtest test test localhost 0 testing123

如果radius返回Access-Accept的消息,则表示验证已经成功.否则,请检查以上的几个配置有没有配置正确.

3. FREERADIUS + LDAP的验证配置

3.1 LDAP的配置

假设LDAP为OPENLDAP,并且已经安装完毕(关于LDAP的详细说明,可以参考LDAP的配置

手册).我们假设LDAP的域名为dc=my-domain,dc=com.

LDAP的slapd.conf文件中的配置如下(省略了注释部分):

include /usr/local/etc/openldap/schema/core.schema

include /usr/local/etc/openldap/schema/openldap.schema

pidfile /usr/local/var/run/slapd.pid

argsfile /usr/local/var/run/slapd.args

access to dn.base="" by * read

access to dn.base="cn=Subschema" by * read

access to *

by self write

by users read

by anonymous auth

database bdb

suffix "dc=my-domain,dc=com"

rootdn "cn=Manager,dc=my-domain,dc=com"

rootpw secret

directory /usr/local/var/openldap-data

index objectClass eq

index uid eq

其中openldap.schema这个文件是在FREERADIUS安装包的doc/examples的目录下,我们首先应该将其拷贝到OPENLDAP的SCHEMA的目录下,详细情况,请参考LDAP的配置手册.

再向LDAP中添加一条记录用于验证,LDIF格式的文件如下

ou=people,dc=my-domain,dc=com

objectClass=organizationUnit

ou=people

uid=tom,ou=people,dc=my-domain,dc=com

objectClass=person

uid=tom

cn=tom

userPassword=12345678

telephoneNumber=87654321

将以上文件保存成一个LDIF文件,例如保存为test.ldif

将test.ldif拷贝到/usr/local/bin的目录下,运行以下命令:

ldapadd –x –D –f test.ldif ‘cn=Manager,dc=my-domain,dc=com’ –w secret

如果命令执行成功则会出现以下提示:

Adding “ou=people,dc=my-domain,dc=com” to directory.

Adding “uid=tom,ou=people,dc=my-domain,dc=com” to directory.

如果要查看其内容可以执行以下命令:

ldapsearch –x –b ‘dc=my-domain,dc=com’ ‘(objectClass=*)’

屏幕将会打出刚才输入的内容.

3.2 FREERADIUS的配置

1. 配置radiusd.conf文件:

找到authorize部分,将LDAP前的注释去掉,如下:

authorize {

Preprocess

chap

……..

files

……..

ldap

}

authenticate{

……

Auth-Type LDAP {

ldap

}

eap

}

全局部分的几个设定改成:

log_auth = yes

log_auth_badpass = no

log_auth_goodpass = no

再找到modules部分,配置为:

Modules {

……

ldap {

……

server=192.168.1.200 (我们假设LDAP服务的IP地址是这个)

port = 389

identity = "cn=Manager,dc=my-domain,dc=com"

password = secret

basedn = "dc=my-domain,dc=com"

filter = "(uid=%{Stripped-User-Name:-%{User-Name}})"

start_tls = no

ldap_connections_number = 5

timeout = 4

timelimit = 3

net_timeout = 1

……

}

……

}

再找到main的模块,修改部分如下

main {

……

lower_user = yes

lower_time = before

……

}

2. 配置USERS文件

找到DEFAULT Auth-Type部分,改成:

DEFAULT Auth-Type = ldap

Fall-Through = 1

3. 启动radius服务

radius –X

3.3 配置的验证

重新打开一个SSH(或TELNET)登陆窗口登陆FREERADIUS所在的LINUX(或UNIX)操作系统,

以管理员的身份登陆,在终端下运行以下命令:

radtest tom 12345678 localhost 0 testing123 回车测试FREERADIUS的验证过程.

如果验证成功,在执行命令的窗口将出现以下内容:

Sending Access-Request of id 4 to 127.0.0.1 port 1812

User-Name = "tom"

User-Password = "12345678"

NAS-IP-Address = 255.255.255.255

NAS-Port = 0

rad_recv: Access-Accept packet from host 127.0.0.1:1812, id=4, length=20

在运行DEBUG模式的窗口下将出现以下内容:

rad_recv: Access-Request packet from host 127.0.0.1:1024, id=4, length=59

User-Name = "tom"

User-Password = "12345678"

NAS-IP-Address = 255.255.255.255

NAS-Port = 0

Processing the authorize section of radiusd.conf

modcall: entering group authorize for request 0

modcall[authorize]: module "preprocess" returns ok for request 0

modcall[authorize]: module "chap" returns noop for request 0

users: Matched entry DEFAULT at line 150

modcall[authorize]: module "files" returns ok for request 0

rlm_ldap: - authorize

rlm_ldap: performing user authorization for tom

radius_xlat: '(uid=tom)'

radius_xlat: 'dc=my-domain,dc=com'

rlm_ldap: ldap_get_conn: Checking Id: 0

rlm_ldap: ldap_get_conn: Got Id: 0

rlm_ldap: attempting LDAP reconnection

rlm_ldap: (re)connect to 192.168.1.200:389, authentication 0

rlm_ldap: bind as cn=Manager,dc=my-domain,dc=com/secret to 192.168.1.200:389

rlm_ldap: waiting for bind result ...

rlm_ldap: Bind was successful

rlm_ldap: performing search in dc=my-domain,dc=com, with filter (uid=tom)

rlm_ldap: looking for check items in directory...

rlm_ldap: looking for reply items in directory...

rlm_ldap: user tom authorized to use remote access

rlm_ldap: ldap_release_conn: Release Id: 0

modcall[authorize]: module "ldap" returns ok for request 0

modcall: leaving group authorize (returns ok) for request 0

rad_check_password: Found Auth-Type ldap

auth: type "LDAP"

Processing the authenticate section of radiusd.conf

modcall: entering group LDAP for request 0

rlm_ldap: - authenticate

rlm_ldap: login attempt by "tom" with password "12345678"

rlm_ldap: user DN: uid=tom,ou=admins,ou=radius,dc=my-domain,dc=com

rlm_ldap: (re)connect to 192.168.1.200:389, authentication 1

rlm_ldap: bind as uid=tom,ou=admins,ou=radius,dc=my-domain,dc=com/12345678 to 192.168.1.200:389

rlm_ldap: waiting for bind result ...

rlm_ldap: Bind was successful

rlm_ldap: user tom authenticated succesfully

modcall[authenticate]: module "ldap" returns ok for request 0

modcall: leaving group LDAP (returns ok) for request 0

Login OK: [billing] (from client localhost port 0)

Sending Access-Accept of id 4 to 127.0.0.1 port 1024

Finished request 0

Going to the next request

--- Walking the entire request list ---

Waking up in 6 seconds...

--- Walking the entire request list ---

Cleaning up request 0 ID 4 with timestamp 45c9b3f6

Nothing to do. Sleeping until we see a request.

到这里,一个简单的RADIUS+LDAP验证就已经完成了.

4. 参考资料

1. freeradius安装包下的DOC目录中的ldap_howto.txt文件.

2. http://www.freeradius.org/radiusd/doc.

3. http://www.openldap.org/doc/admin21.

4. http://www.freeradius.org/radiusd/doc/rfc/rfc2865.txt

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
下面是在Linux系统中使用FREERADIUS配置DOT1x的基本步骤: 1. 安装FREERADIUS软件包 ``` sudo apt-get update sudo apt-get install freeradius ``` 2. 配置FREERADIUS服务器 在`/etc/freeradius/`目录下,编辑`/etc/freeradius/users`文件,添加用户信息。例如: ``` bob Cleartext-Password := "password" ``` 这将创建一个名为“bob”的用户,密码为“password”。此外,还需要在`/etc/freeradius/clients.conf`文件中添加客户端信息。例如: ``` client 192.168.1.0/24 { secret = testing123 shortname = localnet } ``` 这将创建一个名为“localnet”的客户端,IP地址为“192.168.1.0/24”,共享密钥为“testing123”。 3. 配置DOT1x认证 在`/etc/freeradius/eap.conf`文件中,配置EAP认证协议,例如: ``` eap { default_eap_type = peap timer_expire = 60 ignore_unknown_eap_types = no cisco_accounting_username_bug = no max_sessions = 4096 tls { private_key_password = password private_key_file = /etc/freeradius/certs/server.pem certificate_file = /etc/freeradius/certs/server.pem ca_file = /etc/freeradius/certs/ca.pem dh_file = /etc/freeradius/certs/dh } peap { default_eap_type = mschapv2 copy_request_to_tunnel = no use_tunneled_reply = no proxy_tunneled_request_as_eap = yes virtual_server = "inner-tunnel" } } ``` 这将启用PEAP认证协议,并将其配置为使用MSCHAPv2作为默认EAP类型。 4. 配置网络接入设备 在网络接入设备(例如交换机或无线接入点)上,配置DOT1x认证。根据设备型号和厂商不同,具体配置方式可能会有所不同。 5. 测试认证 使用以下命令测试认证: ``` radtest bob password localhost 0 testing123 ``` 这将使用用户名“bob”和密码“password”对本地FREERADIUS服务器进行认证。 以上就是使用FREERADIUS配置DOT1x认证的基本步骤。具体的配置方式可能会因环境和需求的不同而有所变化。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值