ToughRADIUS 快速安装指南

ToughRADIUS 是一种健壮、高性能、易于扩展的开源 RADIUS 服务器。本指南将引导您快速地在您的系统上安装和配置 ToughRADIUS 服务。当前版本是基于Go语言开发的。

开源项目地址:https://github.com/talkincode/toughradius

官方文档:https://www.toughradius.net/docs/documents

编译安装

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
dnf install golang -y
# 以Rocky Linux为例,安装golang
go install github.com/talkincode/toughradius/[email protected]
# 执行自动编译,指定库和版本。
go install github.com/talkincode/toughradius/v8@latest
# 执行自动编译,使用最新源码。
tree -L 3 ./go
go/
├── bin
│   └── toughradius
└── pkg
├── mod
│   ├── cache
│   ├── github.com
│   ├── go.etcd.io
│   ├── golang.org
│   ├── gonum.org
│   ├── google.golang.org
│   ├── gopkg.in
│   ├── gorm.io
│   ├── go.uber.org
│   └── layeh.com
└── sumdb
└── sum.golang.org
# 查看编译后的目录,bin下为编译好的二进制文件

PS:安装参考二进制安装,直接执行toughradius -install 即可,可配置为服务,并安装。

快速安装

通过 curl 或 wget 执行shell脚本安装 (自动化编译和注册服务)

您可以使用 curlwget 工具来快速安装 ToughRADIUS。根据您的喜好选择以下命令之一执行即可。

使用 curl 安装:

1
sudo bash -c "$(curl -fsSL https://raw.githubusercontent.com/talkincode/toughradius/main/installer.sh)"

使用 wget 安装:

1
sudo bash -c "$(wget https://raw.githubusercontent.com/talkincode/toughradius/main/installer.sh -O -)"

二进制安装

我们以 v8.0.8 版本为例进行安装说明。请依据以下步骤进行:

  • Releases 页面 下载软件发行版。
  • 如果您具备一定的开发能力,您也可以选择自行编译版本。

使用 curl 下载 ToughRADIUS 并进行安装:

1
2
curl https://github.com/talkincode/toughradius/releases/download/v8.0.8/toughradius_amd64 -O /tmp/toughradius
chmod +x /tmp/toughradius && /tmp/toughradius -install

系统环境依赖

在开始安装之前,请确保您的系统满足以下条件:

  • 操作系统:支持跨平台部署(Linux、Windows、MacOS 等)
  • 数据库服务器:PostgreSQL 14 或更高版本

PG数据库实例安装

以Rocky Linux为例,安装PG 16

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
dnf module install postgresql:16 -y
# 指定安装16版本
postgresql-setup --initdb
# 初始化数据库
vim /var/lib/pgsql/data/pg_hba.conf
# "local" is for Unix domain socket connections only
local all all peer
# IPv4 local connections:
host all all 127.0.0.1/32 scram-sha-256
# IPv6 local connections:
host all all ::1/128 scram-sha-256
# 将主机连接的加密方式将ident改为scram-sha-256即可。
systemctl enable --now postgresql
systemctl restart postgresql
systemctl status postgresql
# 配置开机启动,查看状态

ToughRADIUS数据库初始化

在进行 ToughRADIUS 的安装和配置之前,请确保您的数据库服务器已经正确安装并且正在运行。下面是数据库的初始化步骤:

运行数据库创建脚本并创建一个专用用户:

1
2
3
4
5
6
7
8
9
10
sudo -u postgres psql
# 登录到PostgreSQL shell
CREATE USER toughradius WITH PASSWORD 'songxwn.com';
# 创建用户toughradius,指定密码songxwn.com
CREATE DATABASE toughradius WITH OWNER toughradius;
# 创建数据库toughradius
GRANT ALL PRIVILEGES ON DATABASE toughradius TO toughradius;
# 授权用户数据库权限
q
# 退出pg shell

请将 toughradius 替换成您想要设置的密码。

  • 在继续操作之前,请确保您已经创建了相应的数据库,并确保数据库服务器正在运行。
  • 修改配置文件 /etc/toughradius.yml

修改toughradius配置文件接入数据库

1
2
3
4
5
6
7
8
9
10
11
12
vim /etc/toughradius.yml
database:
type: postgres
host: 127.0.0.1
port: 5432
name: toughradius
user: toughradius
passwd: songxwn.com
max_conn: 100
idle_conn: 10
debug: false
# 配置数据库连接信息。

启动服务

安装完成后,您可以通过以下命令启动 ToughRADIUS 服务,并设置为开机自启:

1
2
systemctl enable toughradius
systemctl start toughradius

访问控制台

打开您的网络浏览器,输入 URL:http://服务器IP:1816。请将 “服务器IP” 替换成您的服务器实际的 IP 地址。

默认的用户名和密码是:admin/toughradius

至此,ToughRADIUS 的安装和基本配置已经完成。您现在可以开始配置您的 RADIUS 服务器,并管理您的用户认证和账户计费。

PS:若数据库为空,则也会提示密码错误。如果出现此问题可以尝试重启服务,或检查数据库配置。

技术交流群

发送邮件到 ➡️ [email protected]

或者关注WX公众号:网工格物

微信扫码