Flexisip 2.6 配置参数详解
Flexisip 2.6.2 配置文件结构、四种查看修改方式、global/Registrar/Authentication/Router 等核心段参数默认值实测详解。
Flexisip 2.6 配置参数详解
目标:系统讲清 Flexisip 2.6 配置文件的结构、查看与修改方式、各核心段的参数含义与默认值,并给出生产配置模板。全部参数名与默认值来自 2026-10-25 在 Flexisip 2.6.2-1 上用
--dump-default与flexisip_cli.py CONFIG_LIST的实测输出。
一、环境信息
- 软件版本:Flexisip 2.6.2-1(Belledonne 官方 APT 仓库 noble/stable)
- 配置文件:
/etc/flexisip/flexisip.conf(INI 格式,默认 2762 行,全部参数以注释形式带官方说明与默认值) - 在线管理:
/opt/belledonne-communications/bin/flexisip_cli.py(CONFIG_GET/SET/LIST 热查热改) - 重载方式:文件修改需
systemctl restart flexisip-proxy;CONFIG_SET热改立即生效但不写回配置文件(重启后回退文件值)
二、前置条件
- 已安装 Flexisip 2.6.x(见《Ubuntu 24.04 安装 Flexisip 2.6.2 指南》),
flexisip-proxy服务在运行。 - 理解 Flexisip 的角色划分:proxy / presence / regevent / b2bua / voicemail 五类服务共用同一份配置文件,各服务只读自己相关的段。
三、参数查看与修改方式
Flexisip 提供四种互补的参数管理方式,先建立全貌再逐段详解:
3.1 配置文件(持久生效)
直接编辑 /etc/flexisip/flexisip.conf,去掉参数前的 # 并改值,重启服务生效。所有参数默认值都以 #param=值 注释形式躺在文件里,配注释自带的官方说明即权威文档。
3.2 命令行导出默认配置(查权威默认值)
/opt/belledonne-communications/bin/flexisip --dump-default module::Registrar # 导出单段
/opt/belledonne-communications/bin/flexisip --dump-default all # 导出全部
/opt/belledonne-communications/bin/flexisip --list-sections # 列出全部配置段
/opt/belledonne-communications/bin/flexisip --list-modules # 列出全部模块
实测 --list-sections 回显(2.6.2 共 38 个段):
notif
global
cluster
mdns-register
event-logs
stun-server
conference-server
global::flexiapi
presence-server
regevent-server
b2bua-server
b2bua-server::sip-bridge
b2bua-server::trenscrypter
voicemail-server
module::DoSProtection
module::SanityChecker
module::GarbageIn
module::Capabilities
module::NatHelper
module::Authentication
module::AuthTrustedHosts
module::AuthOpenIDConnect
module::Authorization
module::Redirect
module::RegEvent
module::B2bua
module::GatewayAdapter
module::Presence
module::Registrar
module::StatisticsCollector
module::ContactRouteInserter
module::Router
module::PushNotification
module::LoadBalancer
module::MediaRelay
module::Transcoder
module::Forward
inter-domain-connections
3.3 flexisip_cli 在线查改(临时生效)
python3 /opt/belledonne-communications/bin/flexisip_cli.py CONFIG_GET global/transports
实测回显:global/transports: sip:*
python3 /opt/belledonne-communications/bin/flexisip_cli.py CONFIG_SET global/log-level debug
实测回显:global/log-level: debug(立即生效,常用于临时开调试日志)。
CONFIG_LIST <段名> 可列出该段全部参数及说明(输出较长,适合 grep 检索):
python3 /opt/belledonne-communications/bin/flexisip_cli.py CONFIG_LIST global | grep -E "^(log|transports|aliases)"
实测回显:
log-directory: Path to the directory where log files will be created.
log-filename: Name of the log file
log-level: Logging verbosity.
transports: List of whitespace separated SIP URIs where the proxy must listen.
aliases: List of whitespace separated host names pointing to this machine.
⚠️ 注意:
CONFIG_SET只改运行中进程的内存值,不持久化;长期配置务必落回flexisip.conf。
3.4 配置翻新与清理(升级后对齐)
/opt/belledonne-communications/bin/flexisip -c /etc/flexisip/flexisip.conf --rewrite-config > flexisip.new # 保留现有值,补入新版本新增参数与文档
/opt/belledonne-communications/bin/flexisip -c /etc/flexisip/flexisip.conf --remove-deprecated --rewrite-config > flexisip.new # 顺带剔除已废弃参数
四、参数总览
配置段分两大类:
| 类别 | 段 | 作用 |
|---|---|---|
| 服务级 | global | 全局:监听、日志、TLS、超时、线程等 |
| 服务级 | cluster | 多实例集群(Redis 协同) |
| 服务级 | stun-server | 内置 STUN 服务 |
| 服务级 | presence-server / regevent-server / b2bua-server / voicemail-server | 各角色服务专属参数 |
| 服务级 | event-logs | 结构化事件日志(文件/MySQL) |
| 服务级 | notif / mdns-register / global::flexiapi / inter-domain-connections | 通知、mDNS 注册、FlexiAPI、域间互联 |
| 模块级 | module::*(23 个) | Proxy 消息处理链上的各功能模块 |
Proxy 的默认模块处理链(消息流经顺序,实测 debug 日志确认):DoSProtection → SanityChecker → Capabilities → NatHelper → Registrar → Router → Forward(Authentication/PushNotification/MediaRelay 等默认未进链,启用后加入)。
五、核心参数分类详解
5.1 [global] 全局段
所有服务共享的基础参数。实测默认值(--dump-default global):
| 参数 | 默认值 | 说明 |
|---|---|---|
default-servers | proxy | 不带 --server 启动时默认拉起的角色 |
transports | sip:* | 监听点列表(空格分隔 SIP URI)。sip:*=全地址 UDP 5060;加 TLS 用 sips:*;指定端口如 sip:0.0.0.0:5060;transport=tcp |
aliases | localhost | 指向本机的主机名列表,用于防路由回环判定 |
log-directory | /var/opt/belledonne-communications/log/flexisip | 日志目录 |
log-filename | flexisip-{server}.log | 日志文件名模板,{server} 自动替换角色名 |
log-level / syslog-level | error | 文件/ syslog 日志级别:debug/message/warning/error |
sofia-level | 5 | 底层 sofia-sip 协议栈内部日志级别(0-9) |
idle-timeout | 3600 | 空闲连接关闭时间(秒) |
keepalive-interval | 1800 | TCP/TLS 连接保活间隔(秒),0 关闭 |
transaction-timeout | 32000 | SIP 事务超时(毫秒,=T1×64) |
udp-mtu | 1460 | UDP 报文超过该大小建议走 TCP |
tls-certificates-file / tls-certificates-private-key | /etc/flexisip/tls/agent.pem | TLS 证书与私钥(启用 sips 前必须配好) |
tls-ciphers | HIGH:!SSLv2:!SSLv3:!TLSv1:!EXP:!ADH:!RC4:!3DES:!aNULL:!eNULL | TLS 密码套件白名单(默认已禁 SSLv2/v3/TLSv1 与弱套件) |
require-peer-certificate | false | 是否要求客户端证书(双向 TLS) |
enable-snmp | false | SNMP 监控导出开关 |
watchdog-notify-interval | 1s | 向 systemd watchdog 保活的间隔 |
5.2 [cluster] 集群段
多实例组成集群时的协同参数(实测默认值):
| 参数 | 默认值 | 说明 |
|---|---|---|
enabled | false | 集群开关 |
cluster-domain | 空 | 集群对外统一域名(SRV/A 记录解析到各节点) |
nodes | 空 | 集群节点列表(内部通信用) |
internal-transport | 空 | 节点间内部通信传输,默认沿用全局 |
集群启用后,module::Registrar/db-implementation 需切到 redis,各节点共享注册库。
5.3 [stun-server] 内置 STUN 段
| 参数 | 默认值 | 说明 |
|---|---|---|
enabled | true | 内置 STUN 开关 |
bind-address | 0.0.0.0 | 绑定地址 |
port | 3478 | UDP 监听端口(防火墙需放行) |
5.4 [module::Registrar] 注册模块
注册服务器核心,实测默认值:
| 参数 | 默认值 | 说明 |
|---|---|---|
enabled | true | 模块开关 |
reg-domains | localhost | 受理注册的域名列表(空格分隔,* 通配)。非列表内域的 REGISTER 不被本模块受理——默认配置下只对 localhost 域响应 |
max-expires / min-expires / default-expires | 86400 / 60 / 10min | 注册有效期上限/下限/默认 |
max-contacts-by-aor | 12 | 同一 AOR 最多绑定的联系地址数(多终端上限) |
unique-id-parameters | +sip.instance pn-tok line | 区分终端设备的 Contact 参数及优先级 |
enable-gruu | true | 为支持的客户端分配 pub-gruu |
db-implementation | internal | 注册库后端:internal(内存)/redis。重启即丢注册信息的根源就是默认内存库 |
redis-server-domain / redis-server-port | localhost / 6379 | Redis 后端地址 |
redis-use-slaves-as-backup | true | Redis 主挂后是否读从库 |
static-records-file | 空 | 静态注册记录文件(无客户端的固定路由场景) |
5.5 [module::Authentication] 认证模块
| 参数 | 默认值 | 说明 |
|---|---|---|
enabled | false | 默认关闭(这就是为什么默认配置 REGISTER 直接 200,不开认证先跑通再开) |
auth-domains | localhost | 负责认证的域列表 |
available-algorithms | MD5 | 摘要算法白名单(可加 SHA-256) |
db-implementation | file | 密码库后端:file/soci(数据库) |
file-path | 空 | file 后端的密码文件路径(格式 user@domain clrtxt:密码 或 MD5 HA1) |
soci-backend | mysql | SOCI 数据库后端类型 |
soci-connection-string | db=mydb user=myuser password='mypass' host=myhost.com | 数据库连接串(示例值,需改) |
soci-password-request | select password, algorithm from passwords where account_id = (select id from accounts where username = :id and domain = :domain and activated = true) | 查密码的 SQL(可适配自有库表结构) |
soci-poolsize | 100 | 数据库连接池大小(官方提示注意数据库 max_connections 上限,默认约 151) |
nonce-expires | 3600 | 摘要认证 nonce 有效期(秒) |
cache-expire | 1800 | 认证结果缓存(秒),与 AUTH_CACHE_* CLI 对应 |
💡 技术拓展:SIP 摘要认证算法可选 MD5 / SHA-256 / SHA-512-256(RFC 8760)。MD5 兼容性最好但强度弱;SHA-256 为当前推荐,但老客户端可能不支持。Flexisip 用
available-algorithms白名单同时声明多种算法时按客户端能力协商,本文默认值为MD5,生产建议追加SHA-256。
5.6 [module::Router] 路由模块
消息分发与叉路(fork)策略,实测默认值:
| 参数 | 默认值 | 说明 |
|---|---|---|
enabled | true | 模块开关 |
fork-late | false | 晚叉路:优先串行尝试再并行,降低并发冲击 |
call-fork-timeout | 90 | 呼叫叉路总超时(秒) |
message-fork-late | true | 消息(MESSAGE)默认晚叉路 |
message-delivery-timeout | 604800 | 消息离线保存投递窗口(7 天,配合 message-database) |
message-database-enabled | false | 消息持久化开关(配合 MySQL) |
fallback-route | 空 | 无注册绑定时的兜底路由 |
no-contact-for-aor-return-code | 404 | 被叫无可用绑定时回的 SIP 码 |
static-targets | 空 | 静态路由目标 |
forwarding-status-codes | 408 486 603 | 触发转接/下一路由尝试的响应码 |
enable-call-diversions / max-call-diversions | false / 10 | 呼叫转移开关与最大跳转次数 |
5.7 [module::PushNotification] 推送模块
移动端唤醒(RFC 8599),默认 enabled=false,要点:
| 参数 | 默认值 | 说明 |
|---|---|---|
apple / firebase | true / true | 两类推送通道开关(模块启用后生效) |
apple-certificate-dir | /etc/flexisip/apn | APNs 证书目录 |
firebase-service-accounts | 空 | FCM 服务账号 JSON 配置 |
external-push-uri / external-push-method / external-push-protocol | 空 / GET / http2 | 外接推送网关(自建推送服务时用) |
max-queue-size | 100 | 推送队列长度 |
retransmission-count / retransmission-interval | 0 / 5 | 推送重发次数与间隔(秒) |
配套命令行推送测试工具 flexisip_pusher 见《Flexisip 2.6.2 常用 CLI 命令与工具详解》。
5.8 [module::MediaRelay] 媒体中继段
| 参数 | 默认值 | 说明 |
|---|---|---|
enabled | true | 模块开关(媒体转发按需触发) |
nortpproxy | nortpproxy | 关闭中继的 SDP 标记约定 |
sdp-port-range | 1024-65535 | 中继 UDP 端口池(生产务必收窄,防火墙要按此段放行) |
max-calls | 0 | 并发中继呼叫上限(0=不限) |
force-relay-for-non-ice-targets | true | 对不支持 ICE 的终端强制中继 |
prevent-loops | true | 防媒体回环 |
inactivity-period | 3600 | 无媒体流自动释放(秒) |
5.9 [event-logs] 事件日志段
结构化话单/事件输出(注册、呼叫、消息),默认 enabled=false、logger=filesystem(写 /var/log/flexisip),可切 database-backend=mysql 落库,配合 database-connection-string 与 database-max-queue-size 100。
六、生产配置模板
场景:单台 8GB 内存服务器,为公司域 sip.example.com 提供带认证的 SIP 代理 + 注册服务,启用 TLS,日志 info 级。相对默认配置的最小改动集(直接改 /etc/flexisip/flexisip.conf 对应行):
[global]
transports=sip:* sips:*
aliases=sip.example.com
log-level=message
tls-certificates-file=/etc/flexisip/tls/agent.pem
tls-certificates-private-key=/etc/flexisip/tls/agent-key.pem
[module::Registrar]
reg-domains=sip.example.com
db-implementation=internal # 单节点先用内存;多节点集群改 redis 并配 [cluster]
[module::Authentication]
enabled=true
auth-domains=sip.example.com
available-algorithms=MD5 SHA-256
db-implementation=file
file-path=/etc/flexisip/passwd
[module::MediaRelay]
sdp-port-range=40000-49999 # 收窄媒体端口池,防火墙按此放行
[event-logs]
enabled=true
logger=filesystem
filesystem-directory=/var/log/flexisip
改完重启并验证:
systemctl restart flexisip-proxy
python3 /opt/belledonne-communications/bin/flexisip_cli.py CONFIG_GET global/transports
⚠️ 注意:密码文件
/etc/flexisip/passwd建议权限chmod 640,内容形如alice@sip.example.com clrtext:q1w2e3r4(演示口令);生产接 MySQL 时用db-implementation=soci并改写soci-password-request适配自有账号表。
七、常见问题
Q1:改了 flexisip.conf 没生效?
文件修改必须 systemctl restart flexisip-proxy;若之前用 CONFIG_SET 热改过同名参数,重启后以文件值为准。用 CONFIG_GET <段>/<参数> 可查看当前运行值。
Q2:怎么确认某参数名的写法与默认值?
/opt/belledonne-communications/bin/flexisip --dump-default <段名> 导出官方带注释的默认段;或 flexisip_cli.py CONFIG_LIST <段名> 在线列出。
Q3:升级到 2.6 后配置里多出/少了参数?
用 --rewrite-config 生成对齐新版本的配置(保留现有值、补新参数),再 diff 审阅后替换。
Q4:reg-domains 与 auth-domains、aliases 三者关系?
reg-domains 决定 Registrar 受理哪些域的注册;auth-domains 决定对哪些域发起认证质询;global/aliases 是「本机=哪些名字」的防环判定。三者通常设成同一组域名。