IP 记账

来自 Alpine Linux
此材料正在制作中...

在移除此通知之前,请勿遵循此处的说明。
(上次由 Nergal 于 2022 年 1 月 13 日编辑。)

本文档将展示如何配置 pmacct 以进行 IP 记账。Pmacct 将配置为 NetFlow 和 sFlow 收集器,使用 PostgreSQL 作为数据库后端。

以下软件已在本文档编写时使用

* pmacct-0.12.4-r3
* postgresql 8.4

安装和配置 pmacct

apk add pmacct pmacct-doc

在 postgreSQL 服务器上启动以下脚本,这些脚本位于 /usr/share/doc/pmacct/sql 中(请确保在 pmacct-create-db.pgsql 中更改用户“pmacct”的默认密码)

postgres$ psql -d template1 -f pmacct-create-db.pgsql
postgres$ psql -d pmacct -f pmacct-create-table_v1.pgsql

NetFlow 收集器守护进程

编辑 /etc/nfmacctd.conf,将“<HOSTNAME>”和“<PASSWORD>”更改为正确的值

daemonize: true
pidfile: /var/run/nfacctd.pid
syslog: daemon

sql_host: <HOSTNAME>
sql_passwd: <PASSWORD>
sql_table_version: 1

plugins: pgsql

sql_optimize_clauses: true
sql_history: 1m
sql_history_roundoff: m
sql_dont_try_update: true

aggregate: src_host,dst_host,src_port,dst_port,proto

nfacctd_sql_log: true

有关上述关键字的解释以及 pmacct 支持的完整选项列表,请参阅此处