基于 ubuntu 使用 Freeradius 搭建 EAP-TLS 测试环境
一、环境准备
系统:服务器 ubuntu(如果使用 VM 虚拟机,请将网络连接方式改为桥接模式)
工具:使用 freeradius 作为 radius 服务的工具
二、环境搭建
1. 安装 freeradius
本次使用 freeradius 最新版本与 openssl,ubuntu 系统使用如下命令安装
sudo su
#切换至 root 用户
apt update
#升级系统预装的 apt
apt-get install freeradius openssl
#安装 freeradius 和 openssl
2.配置 Freeradius
2-1.配置 users
目前 freeradius3.0 的版本变为/etc/freeradius/3.0/
cd /etc/freeradius/3.0/
vim users
注意点 1:可能系统会没有装 vim,需要使用命令 apt-get install vim 来安装,然后再执
行 vim users 命令编辑文件。
在文件末尾或其他合适的地方添加如下内容:
Testing
为密码,可自己定义
#进入到 freeradius 安装目录下
#编辑 users 文件
Cleartext-Password := ”password”
#备注:Testing 为身份名称,password
2-2.配置 client.conf 配置文件
vim client.conf
client client1 { #client1 是认证终端的别名
#编辑 client.conf 配置文件
ipaddr = 192.168.1.1 #这是认证终端地址,
secret = testing123 #共享对称密钥,可以任意修改,注意在路由器参数也需要修改以
匹配
require_message_authenticator = no #建 议为 no, 旧版 本 协议 设备 不 支持 message
authenticator
}
#进入到证书目录下
#编译 certs 目录下的 makefile 文件
3.TLS 模块的配置
3-1.生成证书文件
cd /etc/freeradius/3.0/certs
make
一段时间后会生成一系列的证书:
ca.pem :自签发的根证书,用于服务器验证客户证书或客户验证服务器证书
server.pem:服务器证书
server.key:服务器私钥,保护密码默认为 whatever
client.p12:PKCSv12 编码的个人证书文件,包含了证书,私钥,并由密码“whatever”,
需要导出并在自由的设备上安装。
讲 client.p12 证书导至设备中安装
3-2.配置 eap 文件
cd /etc/freeradius/3.0/mods-enabled/
vim eap
Eap 文件修改参数如下:
eap{
#编辑 eap 文件
default_eap_type=tls
#修改默认的 eap 方法
tls-config tls-common {
#服务器私钥密码
private_key_password = whatever
private_key_file = ${certdir}/server.key
#服务器私钥
Certificate_file = ${certdir}/server.pem #服务器证书
Ca_file = ${cadir}/ca.pem
Dh_file = ${certdir}/dh
#ca 根证书
#Diffie-Hellman
}
}
4. 配置路由器
将路由器用网线连接。192.168.1.1 登录路由器管理页面,设置无线设置方式为 WPA,设置
radius 服务器地址及密码,然后保存
5.启动 freeradius 服务器
Freeradius -X
若见到如下提示:
#启动 freeradius 服务器
此为读取证书权限问题,需要修改权限,在 certs 目录下执行如下命令:
chmod 777 ca.pem dh server.key server.pem
chmod o-w ca.pem dh server.key server.pem
执行后如果遇到如下错误提示:
表示 1812 端口被占用,reboot 服务器后,再次执行 freeradius -X 启动服务
见到 ready to process requests,则表示服务启动成功
三、测试
1.将 certs 目录下的 client.p12 证书导入到设备中安装
2.设备连接路由器的广播的热点,选择身份为 EAP-TLS,ca 证书不用选择,客户证书选择刚安
装的证书,连接即可