I have configured the below filter for rsyslog to direct a few SSH messages to a specific TCP port 5000 on the local system, so that the service running on the 5000 will process the SSH messages further.
if $fromhost-ip == '127.0.0.1' and ( ($msg contains 'SSH') and ($msg contains 'Test') ) then @@127.0.0.1:5000
Everything seems fine, but the messages are not redirected to the port 5000 and if we direct the messages to UDP port it is working fine.
Below is the filter for messages directing to UDP port.
if $fromhost-ip == '127.0.0.1' and ( ($msg contains 'SSH') and ($msg contains 'Test') ) then @127.0.0.1:5000
Could you please let me know, why TCP port do not work and UDP port works.
telnet 127.0.0.1 5000
connect successfully or give an error? – Morbihannetstat -tnlp | grep rsyslog
? Then make sure that firewall is configured too (i.e., in fedora):firewall-cmd --zone=zone --add-port=5000/tcp
– Oligoclase