大网数据广告活动
服务器运维问答

Rsyslog forward using original source IP over TLS

· 52CE 我爱测

I'm trying to forward all syslog messages over TLS from our enviroment to an external syslog server ( dest.syslog.example.com ) using rsyslog. Unfortunately the source IP is changed to that of the relay host ( fwd.syslog.example.…

问题原文

原帖链接 · Roald Nefs · CC BY-SA 4.0

I'm trying to forward all syslog messages over TLS from our enviroment to an external syslog server (dest.syslog.example.com) using rsyslog. Unfortunately the source IP is changed to that of the relay host (fwd.syslog.example.com). I would like it to send the original source IP instead of the IP of the relay host while adhering to the RSYSLOG_SyslogProtocol23Format format.

Current rsyslog configuration relevant for forwarding the syslog messages over TLS:

$DefaultNetstreamDriverCAFile /etc/pki/tls/private/ca.crt
# Run driver in TLS mode
$DefaultNetstreamDriver gtls
$ActionSendStreamDriverMode 1
$ActionSendStreamDriverAuthMode x509/name

$ActionSendStreamDriverPermittedPeer dest.syslog.example.com
$LocalHostName fwd.syslog.example.com
# Forward logging
*.* @@(o)dest.syslog.example.com:6514;RSYSLOG_SyslogProtocol23Format

Would it be possible to modify the fromhost-ip to the original source IP?

已采纳解答

原帖链接 · meuh · CC BY-SA 4.0

I'm not sure if this is sufficient, but the built-in template RSYSLOG_SyslogProtocol23Format is defined as

"<%PRI%>1 %TIMESTAMP:::date-rfc3339% %HOSTNAME% %APP-NAME% 
 %PROCID% %MSGID% %STRUCTURED-DATA% %msg%\n"

and you can replace HOSTNAME by fromhost or fromhost-ip:

template(name="myFormat" type="string"
   string="<%PRI%>1 %TIMESTAMP:::date-rfc3339% %fromhost% %APP-NAME% %PROCID% %MSGID% %STRUCTURED-DATA% %msg%\n")
*.* @@(o)dest.syslog.example.com:6514;myFormat

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2020-11-02)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。