Debian 12 安装 ngIRCd 28 指南

目标:在 Debian 12 (bookworm) x8664 服务器上完成 ngIRCd 的安装与可连接验证,覆盖 Debian 官方仓库、作者 deb 仓库、源码编译三条路线,全部步骤与回显来自真实环境实测。

ngircdngircdIRC即时通讯2026/10/26

Debian 12 安装 ngIRCd 28 指南

目标:在 Debian 12 (bookworm) x86_64 服务器上完成 ngIRCd 的安装与可连接验证,覆盖 Debian 官方仓库、作者 deb 仓库、源码编译三条路线,全部步骤与回显来自真实环境实测。

一、环境与版本基线

本文实测环境:

  • 操作系统:Debian 12 (bookworm) x86_64,独立 systemd 环境
  • 内网:10.89.58.0/24(本机 10.89.58.2),仅内网互通
  • 安装目标:ngIRCd 28(上游最新稳定版,2026-07-12 发布;Debian 12 仓库当前提供 26.1-1+deb12u1)

三条路线的适用性先行说明:

路线得到的版本适用性
方案一:Debian 官方仓库26.1-1+deb12u1最省事,但版本落后上游近两年半,缺 28 版修复与新特性
方案二:作者 deb 仓库28Debian 12 上不可行(依赖与 GLIBC 均面向 Debian 13+),本文如实记录失败实录
方案三:源码编译28(全特性)推荐:拿到上游最新版,且可自选编译特性集

二、方案一:Debian 官方仓库安装(26.1)

sudo apt update
sudo apt install ngircd

安装过程关键回显(实测逐行):

Selecting previously unselected package ngircd.
(Reading database ... 19791 files and directories currently installed.)
Preparing to unpack .../ngircd_26.1-1+deb12u1_amd64.deb ...
Unpacking ngircd (26.1-1+deb12u1) ...
Setting up ngircd (26.1-1+deb12u1) ...

安装完成后确认版本与编译特性集(特性旗标串的含义见 《ngIRCd 28 介绍与选型指南》 3.1 节):

$ /usr/sbin/ngircd --version
ngIRCd 26.1-IDENT+IPv6+IRCPLUS+PAM+SSL+SYSLOG+ZLIB-x86_64/pc/linux-gnu

要点:

  • Debian 12 仓库版自带 IDENT、IPv6、IRCPLUS、PAM、SSL、SYSLOG、ZLIB 特性,不含 CHARCONV 与 TCPWRAP(与上游源码全特性编译的差异)。
  • 包安装即注册 ngircd.service 并启动,配置文件在 /etc/ngircd/ngircd.conf(默认服务器名 server.example.net,监听 6667),二进制在 /usr/sbin/ngircd。
  • 局限:26.1 不包含 28 版的修复与新特性(例如 DefaultChannelModes 配置项、无终结符数据导致 CPU 单核忙转的修复等,见 NEWS)。

仓库版适合「先跑起来再说」的场景;要上游 28,请走方案三。

三、方案二:作者 deb 仓库安装 28(Debian 12 不可行实录)

作者 Alex Barton 维护了一个非官方 Debian 仓库(官方下载页「Unofficial packages」列出,含 standard/full/full-dbg 三个变体),提供上游 28 的 deb 包。但在 Debian 12 上安装会失败,本文如实记录:

$ sudo dpkg -i ngircd_28-0ab1_amd64.deb
 ngircd depends on libident0; however:
  Package libident0 is not installed.
 ngircd depends on libssl3t64 (>= 3.0.0); however:
  Package libssl3t64 is not installed.

dpkg: error processing package ngircd (--install):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 ngircd

两个依赖都装不上,这不是缺包而是包名/ABI 代差:

  • libssl3t64 是 Debian 13 (trixie) 的 OpenSSL 库包名(64 位 time_t 迁移产物),Debian 12 对应的是 libssl3;
  • libident0 同样是 trixie 的包名,Debian 12 里叫 libident。

即使忽略依赖强行装上(包体本身能解包),运行时仍会因 GLIBC 版本不满足而失败:

$ /usr/sbin/ngircd --version
/usr/sbin/ngircd: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.38' not found (required by /usr/sbin/ngircd)

Debian 12 的 glibc 是 2.36,而该 deb 面向 Debian 13+(glibc ≥ 2.38)。结论:该 deb 在 Debian 12 上不可用,需清理干净:

$ sudo dpkg --remove ngircd
(Reading database ... 19822 files and directories currently installed.)
Removing ngircd (28-0ab1) ...

要上游 28,在 Debian 12 上唯一可行路线是方案三(源码编译)。

四、方案三:源码编译安装 28(推荐)

4.1 安装编译依赖

本文按全特性编译,需要的开发包:

sudo apt install -y build-essential zlib1g-dev libssl-dev libident-dev libpam0g-dev libwrap0-dev

对应关系:libssl-dev→SSL 特性、libident-dev→IDENT、libpam0g-dev→PAM、libwrap0-dev→TCP Wrappers、zlib1g-dev→链路压缩;IPv6/IRCPLUS/SYSLOG 无需额外库。

4.2 下载与校验

从官方下载页任一镜像(ngircd.barton.de / ngircd.mirror.3rz.de / ngircd.sourceforge.io)下载:

wget https://ngircd.barton.de/pub/ngircd/ngircd-28.tar.xz
sha256sum ngircd-28.tar.xz

实测校验值(379768 字节):

b48ba320a931d445ae335c47f88a9406a20f5c71c623bee5f7755d0522d435ee  ngircd-28.tar.xz

解包进入源码目录:

tar xf ngircd-28.tar.xz
cd ngircd-28

4.3 configure 与编译

按全特性配置(--with-iconv 即版本旗标串中的 CHARCONV):

./configure --with-openssl --with-ident --with-pam --with-iconv --with-tcp-wrappers

成功后 configure 输出安装路径与特性摘要(实测逐行):

    'ngircd' binary: /usr/local/sbin
 Configuration file: /usr/local/etc
       Manual pages: /usr/local/share/man
      Documentation: /usr/local/share/doc/ngircd

     Syslog support: yes     Enable debug code: no
   zlib compression: yes           IRC sniffer: no
   Use TCP Wrappers: yes       Strict RFC mode: no
      IDENT support: yes         IRC+ protocol: yes
      IPv6 protocol: yes           I/O backend: epoll(), select()
        PAM support: yes           SSL support: openssl
   libiconv support: yes

摘要确认四点:安装前缀 /usr/local;SSL 后端为 openssl;IO 后端 epoll(另有 select 备选);libiconv(CHARCONV)启用。随后编译并安装:

make -j$(nproc)
sudo make install

编译完成后二进制位于 /usr/local/sbin/ngircd,man 手册与文档随 make install 落位 /usr/local/share/。配置文件不自动生成,需按第五节自行创建(官方完整模板见源码树 doc/sample-ngircd.conf.tmpl,约 400 行逐项注释)。

4.4 专用运行用户

配置里的 ServerUID/ServerGID 降权需要专用用户(Debian 的 apt 包会自动创建,源码安装需手动):

sudo useradd -r -s /usr/sbin/nologin irc

五、配置与 systemd 服务

5.1 最小演示配置

写入 /usr/local/etc/ngircd.conf(本文演示配置,覆盖常用段;逐项参数详解见本系列配置篇):

[Global]
	Name = irc.example.com
	Info = ngIRCd 28 Demo Server
	AdminInfo1 = ngIRCd Demo Administrator
	AdminInfo2 = Shanghai, China
	AdminEMail = admin@example.com
	Listen = ::,0.0.0.0
	Ports = 6667
	Network = ExampleNet
	MotdFile = /usr/local/etc/ngircd.motd
	PidFile = /run/ngircd/ngircd.pid
	ServerUID = irc
	ServerGID = irc

[Limits]
	MaxConnections = 500
	MaxConnectionsIP = 10
	MaxJoins = 10
	MaxNickLength = 9
	MaxListSize = 100
	PingTimeout = 120
	PongTimeout = 20
	ConnectRetry = 60

[Options]
	DefaultChannelModes = n
	OperCanUseMode = yes
	PAM = no
	AllowedChannelTypes = #&+

[SSL]
	Ports = 6697
	CertFile = /usr/local/etc/ssl/server-cert.pem
	KeyFile = /usr/local/etc/ssl/server-key.pem

[Operator]
	Name = admin
	Password = q1w2e3r4

[Channel]
	Name = #lobby
	Autojoin = yes
	Topic = ngIRCd 28 Demo Lobby

⚠️ 注意 [Options] 里的 DefaultChannelModes = n:模式值不带 + 前缀,写成 +n 会导致 configtest 报错(本文实测踩过的坑,详见第八节排障)。

MOTD 文件 /usr/local/etc/ngircd.motd:

ngIRCd 28 Demo Server (ExampleNet)
Admin: admin@example.com

5.2 MOTD 的两种形态(优先级实测)

ngIRCd 支持两种 MOTD 提供方式:

  • MotdFile:读取文本文件(上例);
  • MotdPhrase:直接在配置里写一句短语(<127 字符),适合不想维护文件时使用。

两者同时设置时 MotdPhrase 优先——这是本文实测确认的行为:在 [Global] 同时写 MotdFile 与 MotdPhrase 后,ngircd --configtest 的 dump 显示 MotdFile 被置空、仅 MotdPhrase 生效:

  MotdFile = 
  MotdPhrase = Welcome to irc.example.com, a ngIRCd 28 demo server!

客户端连接时的 MOTD 回显也相应变为短语内容(见第七节 372 行)。

5.3 TLS 监听(自签证书)

[SSL] 段引用的证书对可用 openssl 自签生成:

sudo mkdir -p /usr/local/etc/ssl
sudo openssl req -x509 -newkey rsa:2048 -days 3650 -nodes \
  -keyout /usr/local/etc/ssl/server-key.pem \
  -out /usr/local/etc/ssl/server-cert.pem \
  -subj "/CN=irc.example.com"
sudo chown irc:irc /usr/local/etc/ssl/server-*.pem

生产环境请使用正规 CA 签发证书;另外自 27 版起服务器互联(出向)默认校验对端证书,自签证书互联需在对应 [Server] 段显式 SSLVerify = false。

5.4 systemd 单元与开机自启

创建 /etc/systemd/system/ngircd.service(本文实测使用的单元,Type=forking 配合 ngircd 自身的后台化行为):

[Unit]
Description=Next Generation IRC Daemon
Documentation=man:ngircd(8) man:ngircd.conf(5)
After=network.target

[Service]
Type=forking
User=irc
Group=irc
RuntimeDirectory=ngircd
RuntimeDirectoryMode=750
ExecStart=/usr/local/sbin/ngircd
ExecReload=/bin/kill -HUP $MAINPID
Restart=on-failure

[Install]
WantedBy=multi-user.target

💡 说明:ExecReload 通过 SIGHUP 触发配置重读,但实测中 ngircd 的重读会关闭并重建全部监听套接字,偶发端口重绑失败(地址仍被旧套接字占用)导致服务「活着但不再监听」。日常改配置建议直接 systemctl restart ngircd,详见本系列运维命令篇对 REHASH 竞态的分析。

启用并启动:

sudo systemctl daemon-reload
sudo systemctl enable --now ngircd

六、安装后验证

6.1 版本与特性确认

$ ngircd --version
ngIRCd 28-CHARCONV+IDENT+IPv6+IRCPLUS+PAM+SSL+SYSLOG+TCPWRAP+ZLIB-x86_64/pc/linux-gnu
Copyright (c)2001-2026 Alexander Barton (<alex@barton.de>) and Contributors.
Homepage: <http://ngircd.barton.de/>

与方案一的 26.1 对比,多了 CHARCONV 和 TCPWRAP 两个特性。

6.2 配置自检

$ ngircd --configtest
Using default configuration file "/usr/local/etc/ngircd.conf" ...
Reading configuration from "/usr/local/etc/ngircd.conf" ...
Ok, dump of your server configuration follows:

[GLOBAL]
  Name = irc.example.com
  AdminInfo1 = ngIRCd Demo Administrator
  AdminInfo2 = Shanghai, China
  AdminEMail = admin@example.com
  Info = ngIRCd 28 Demo Server
  Listen = ::,0.0.0.0
  MotdFile = /usr/local/etc/ngircd.motd
  ...

出现 Ok, dump of your server configuration follows: 即配置解析通过;有错误时 configtest 会明确指出错误行。

6.3 监听端口确认

$ ss -tlnp | grep ngircd
LISTEN 0      10           0.0.0.0:6667       0.0.0.0:*    users:(("ngircd",pid=12260,fd=9))
LISTEN 0      10           0.0.0.0:6697       0.0.0.0:*    users:(("ngircd",pid=12260,fd=10))
LISTEN 0      10              [::]:6667          [::]:*    users:(("ngircd",pid=12260,fd=7))
LISTEN 0      10              [::]:6697          [::]:*    users:(("ngircd",pid=12260,fd=8))

6667(明文)与 6697(TLS)均已监听,IPv4/IPv6 双栈。

6.4 客户端连接验证

在本机用任意 IRC 客户端(或下面的原始协议方式)连接 6667 端口,发送注册命令 NICK tester + USER tester 0 * :Test Client(末尾回显经实测逐行记录):

:irc.example.com 001 tester :Welcome to the Internet Relay Network tester!~tester@localhost
:irc.example.com 002 tester :Your host is irc.example.com, running version ngircd-28 (x86_64/pc/linux-gnu)
:irc.example.com 003 tester :This server has been started Mon Oct 26 2026 at 09:12:03 (UTC)
:irc.example.com 004 tester irc.example.com ngircd-28 abBcCFiIoqrRswx abehiIklmMnoOPqQrRstvVz
:irc.example.com 005 tester NETWORK=ExampleNet :is my network name
:irc.example.com 005 tester RFC2812 IRCD=ngIRCd CHARSET=UTF-8 CASEMAPPING=ascii PREFIX=(qaohv)~&@%+ CHANTYPES=#&+ CHANMODES=beI,k,l,imMnOPQRstVz CHANLIMIT=#&+:10 :are supported on this server
:irc.example.com 005 tester CHANNELLEN=50 NICKLEN=9 TOPICLEN=399 AWAYLEN=127 KICKLEN=399 MODES=5 MAXLIST=beI:50 EXCEPTS=e INVEX=I PENALTY FNC :are supported on this server
:irc.example.com 251 tester :There are 1 users and 0 services on 2 servers
:irc.example.com 254 tester 2 :channels formed
:irc.example.com 255 tester :I have 1 users, 0 services and 1 servers
:irc.example.com 265 tester 1 1 :Current local users: 1, Max: 1
:irc.example.com 266 tester 1 1 :Current global users: 1, Max: 1
:irc.example.com 250 tester :Highest connection count: 2 (2 connections received)
:irc.example.com 375 tester :- irc.example.com message of the day
:irc.example.com 372 tester :- Welcome to irc.example.com, a ngIRCd 28 demo server!
:irc.example.com 376 tester :End of MOTD command
:tester!~tester@localhost JOIN :#lobby
:irc.example.com 332 tester #lobby :ngIRCd 28 Demo Lobby
:irc.example.com 333 tester #lobby -Server- 1793005923
:irc.example.com 353 tester = #lobby :tester
:irc.example.com 366 tester #lobby :End of NAMES list
:irc.example.com NOTICE tester :Connection statistics: client 0.0 kb, server 1.6 kb.
ERROR :Closing connection: tester[~tester@localhost] ("")

逐项核对验证点:

  1. 注册序列 001–005:001 欢迎行、004 服务器能力行、005 ISUPPORT(NICKLEN=9、TOPICLEN=399、KICKLEN=399 为 28 版修复后的取值);
  2. MOTD(375/372/376):372 行显示的是 MotdPhrase 短语(5.2 节优先级实测的对应结果);
  3. 预置频道自动加入:[Channel] 段的 #lobby 在注册完成后自动 JOIN,332 行回频道主题;
  4. LAN 内其他机器连接:从内网另一台机器(10.89.58.x)以同样方式连接 10.89.58.2:6667 亦可完成注册与 MOTD 拉取(本文实测通过)。

七、排障记录

  1. configure 报错找不到 TCP Wrappers:--with-tcp-wrappers 需要 libwrap0-dev,未安装时 configure 直接失败,补装后重新 configure 即可。
  2. DefaultChannelModes = +n 写法报错:模式值不能带 + 前缀,必须写 n;写错时 configtest 会报告错误行,服务启动受影响。
  3. 注释符 # 截断参数值:配置中 # 起始注释,AllowedChannelTypes = # 这样把值写在注释符后面会让该行变成空值——本文实测中该行曾被意外改坏,正是靠 ngircd --configtest 的 dump 对照发现并修复。
  4. MotdPhrase 与 MotdFile 共存:MotdPhrase 优先生效、MotdFile 被忽略(configtest dump 中显示为空),不要指望两者叠加。
  5. 改配置后端口消失:用 SIGHUP/REHASH 重读配置偶发监听套接字重绑失败,进程在但端口没了;用 systemctl restart ngircd 代替。

八、卸载与升级

# 卸载仓库版
sudo apt purge ngircd

# 卸载源码版:删除二进制、配置、文档与单元
sudo rm -f /usr/local/sbin/ngircd /usr/local/etc/ngircd.conf /usr/local/etc/ngircd.motd
sudo rm -rf /usr/local/share/doc/ngircd /usr/local/share/man/*/ngircd* /etc/systemd/system/ngircd.service
sudo userdel irc

升级到新版本:重复第四节步骤(下载新 tarball、configure、make、sudo make install 后 systemctl restart ngircd);升级前阅读源码 NEWS 确认配置项是否有行为变化。

九、参考链接