radius服务器创建方法

/***********************************/

依赖:ubuntu18.04 + freeradius-3.0

/**********************************/

1、安装freeradius

sudo apt-get install freeradius

#安装的时候会提示有依赖关系的及建议安装的其它工具,一起全部安装

sudo apt-get install freeradius-ldap freeradius-postgresql freeradius-mysql freeradius-krb5 snmp libmldbm-perl libnet-daemon-perl libsql-statement-perl make-doc

2、停止服务

sudo service freeradius stop

3、建立freeradius的软链接

cd /usr/sbin

sudo ln -s freeradius radiusd

4、修改防火墙允许freeradius端口

sudo ufw allow 1812/udp

sudo ufw allow 1813/udp

5、开启radius服务

radiusd -X

6、测试服务是否正常开启

gedit或vim /etc/freeradius/3.0/mods-config/files/authorize

插入以下内容:

testing Cleartext-Password := "password"

保存退出

停止服务再重新开启服务(执行2、5)

输入测试命令:

radtest testing password 127.0.0.1 0 testing123

如果接收到"Access-Accept"则说明正常

7、增加EAP相关的用户

gedit或vim /etc/freeradius/3.0/mods-config/files/authorize

插入以下内容:

test Cleartext-Password := "testpwd"

Auth-Type := Local,

Service-Type = Framed-User,

Framed-IP-Address = 255.255.255.255,

Framed-IP-Netmask = 255.255.255.0

8、增加路由器的相关配置

gedit或vim /etc/freeradius/3.0/clients.conf

插入以下内容:

client wifi_ap {

ipaddr = 192.168.1.0/24

secret = testing123

require_message_authenticator = no

}

这里的ip对路由器的lan口ip有要求,必须为同一网段

9、生成EAP相关的证书

注意:

CA的common name和server、client的common name不能一样,否则验证配套性的时候会提示自签名

以下命令中需要输入用于解密的密码,千万要记住,我一般都固定为123456

openssl req -newkey rsa:2048 -nodes -keyout ca.key -x509 -days 3650 -out ca.crt

openssl pkcs12 -export -in ca.crt -inkey ca.key -out ca.p12

openssl genrsa -out server.key 2048

openssl req -new -key server.key -out server.csr

openssl x509 -req -days 3650 -in server.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out server.crt

openssl pkcs12 -export -in server.crt -inkey server.key -out server.p12

openssl genrsa -out client.key 2048

openssl req -new -key client.key -out client.csr

openssl x509 -req -days 3650 -in client.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out client.crt

openssl pkcs12 -export -in client.crt -inkey client.key -out client.p12

生成文件说明

ca.crt:ca根证书,用于验证server/client子证书

ca.key:ca私钥,用于签名server/client子证书,wifi连接过程中不需要

ca.p12:ca根证书+加密私钥,wifi连接过程中不需要

client.crt:客户端证书

client.csr:客户端未签名的证书摘要,wifi连接过程中不需要

client.key:客户端私钥,因未签名,出于安全考虑,客户端可能不能使用,可使用client.p12

client.p12:客户端证书+加密私钥

server.crt:服务器端证书

server.csr:服务器端未签名的证书摘要,wifi连接过程中不需要

server.key:服务器端私钥,因未签名,出于安全考虑,服务器端可能不能使用,可使用client.p12

server.p12:服务器端证书+加密私钥

windows下tls连接默认使用client.p12内的用户连接,可勾选"为此连接使用一个不同的用户名"

openssl pkcs12 -in client.p12 -out client.pem

openssl pkcs12 -in server.p12 -out server.pem

openssl x509 -in ca.crt -out ca.pem

验证证书是否配套:

openssl verify -CAfile ca.pem client.pem server.pem

10、将生成的证书拷贝到freeradius路径下

/etc/freeradius/3.0/certs/

11、修改EAP相关配置

gedit或vim /etc/freeradius/3.0/mods-enabled/eap

涉及到的修改如下:tls-config tls-common

private_key_password = 123456 #这里是前面生成证书时输入的密码

private_key_file = /etc/freeradius/3.0/certs/server.pem

certificate_file = /etc/freeradius/3.0/certs/server.pem

ca_file = /etc/freeradius/3.0/certs/ca.pem

12、路由器页面上的相关设置

radius服务器ip:跟client.conf中网段一样的ip,也就是ubuntu服务器ip,我这里手动设置静态ip为192.168.1.5

radius端口:1812(默认)

radius密码:testing123

13、客户端连接wifi时的配置

method:TLS

身份:test

CA证书:ca.pem

用户证书:client.pem

用户私钥:client.pem

私钥密码:123456

相关推荐
skywalk816315 小时前
unbound dns解析出现问题,寻求解决之道
运维·服务器·dns·unbound
酉鬼女又兒15 小时前
零基础入门Linux指南:每天一个Linux命令_pwd
linux·运维·服务器
云飞云共享云桌面15 小时前
高性能图形工作站的资源如何共享给10个SolidWorks研发设计用
linux·运维·服务器·前端·网络·数据库·人工智能
skywalk816315 小时前
走近科学:unbound dns域名服务器自己本地解析出现问题,寻求解决之道
运维·服务器·dns·unbound
choke23315 小时前
Python 基础语法精讲:数据类型、运算符与输入输出
java·linux·服务器
AZ996ZA16 小时前
自学linux的第二十一天【DHCP 服务从入门到实战】
linux·运维·服务器·php
Web极客码16 小时前
WordPress博客关键词
服务器·wordpress·网站加速
神梦流17 小时前
GE 引擎的非标准数据流处理:稀疏张量与自定义算子在图优化中的语义保持
linux·运维·服务器
郝学胜-神的一滴18 小时前
深入浅出:使用Linux系统函数构建高性能TCP服务器
linux·服务器·开发语言·网络·c++·tcp/ip·程序人生
Doro再努力18 小时前
【Linux操作系统12】Git版本控制与GDB调试:从入门到实践
linux·运维·服务器·git·vim