Rsyslog使用TCP将日志消息定向到端口5000上的本地syslog主机

时间:2017-02-21 03:40:06

标签: linux syslog rsyslog

我已经为rsyslog配置了以下过滤器,将一些SSH消息定向到本地系统上的特定TCP端口5000,以便5000上运行的服务将进一步处理SSH消息。

if $fromhost-ip == '127.0.0.1' and ( ($msg contains 'SSH') and ($msg contains 'Test') ) then @@127.0.0.1:5000

一切似乎都很好,但是消息没有重定向到端口5000,如果我们将消息定向到UDP端口,它工作正常。

以下是指向UDP端口的消息的过滤器。

if $fromhost-ip == '127.0.0.1' and ( ($msg contains 'SSH') and ($msg contains 'Test') ) then @127.0.0.1:5000

请您告诉我,为什么TCP端口不起作用,UDP端口有效。

2 个答案:

答案 0 :(得分:1)

我认为您可以使用 tunneling 。例如

ssh username@serverAddress -L 5000:11.22.33.44:80

    # username - username on server
    # serverAddress - server address
    # 8080: - port on the local machine that will be opened on loopback interface (127.0.0.1)
    # 11.22.33.44 - IP address of the server that we'll create a tunnel to using SSH

点击此处了解更多信息:https://www.digitalocean.com/community/tutorials/how-to-set-up-ssh-tunneling-on-a-vps

我希望这有帮助!

答案 1 :(得分:1)

您可能决定使用RELP吗? (https://en.wikipedia.org/wiki/Reliable_Event_Logging_Protocol

https://linux.die.net/man/5/rsyslog.conf

所述

你需要更换你的 “那么@ 127.0.0.1:5000” 至 “那么:omrelp:127.0.0.1:5000”

相关问题