To edit the rsyslog.conf file, open /etc/rsyslog.conf with a text editor (For example, vi or nano) and run the following command:
sudo vi /etc/rsyslog.conf
To uncomment UDP module, locate and uncomment the lines that load the UDP input modules and define their respective ports (typically 514) and run the following command:
To uncomment TCP module, locate and uncomment the lines that load the TCP input modules and define their respective ports (typically 514) and run the following command:
To define a template for remote logs, add a template to organize logs from different hosts into separate files or directories. For example, to store logs for each host in /var/log/syslog/, run the following command:
To route logs based on criteria, add rules to direct logs to specific files based on their source IP address, facility, or priority. For example, to use the PerHostLog template for all incoming logs:
*.* action(type="omfile" template="PerHostLog")
To route logs based on the sending host IP, run the following command:
if $fromhost-ip startswith '192.' then {
action(type="omfile" template="PerHostLog")
stop
}
Configure firewall and SELinux.
To open syslog ports in the firewall, activate the firewall (For example, firewalld), allow incoming traffic on UDP port 514.