Edit the rsyslog configuration file to forward logs to the remote syslog server.
Open the rsyslog configuration file:
bash
sudo nano /etc/rsyslog.conf
Add the following line to define the remote syslog server. Replace <REMOTE_SERVER_IP> with the IP address or hostname of your remote syslog server:
plaintext
*.* @<REMOTE_SERVER_IP>:514
The @ symbol indicates UDP transport. If you want to use TCP, use @@ instead.
Port 514 is the default syslog port. Ensure the remote server is configured to listen on this port.
Save and close the file.
3. Configure rsyslog to Handle Audit Logs
By default, auditd writes logs directly to /var/log/audit/audit.log. To forward these logs via rsyslog, you need to configure auditd to write logs to rsyslog instead.
Edit the auditd configuration file:
bash
sudo nano /etc/audit/auditd.conf
Modify the log_file directive to use rsyslog:
plaintext
log_file = /dev/log
Save and close the file.
Restart the auditd service to apply the changes:
bash
sudo systemctl restart auditd
4. Configure rsyslog to Process Audit Logs
You need to ensure that rsyslog can process and forward audit logs correctly.
Create a custom configuration file for audit logs:
bash
sudo nano /etc/rsyslog.d/60-audit.conf
Add the following content to the file:
plaintext
# Load the imfile module to read audit logs
module(load="imfile" PollingInterval="10")
# Define the input file for audit logs
input(type="imfile"
File="/var/log/audit/audit.log"
Tag="audit"
Severity="info"
Facility="local6")
# Forward audit logs to the remote syslog server
local6.* @<REMOTE_SERVER_IP>:514
Replace <REMOTE_SERVER_IP> with the IP address or hostname of your remote syslog server.
The Tag="audit" ensures that all forwarded logs are tagged as "audit" for easy identification on the remote server.
Save and close the file.
5. Restart rsyslog
After making the changes, restart the rsyslog service to apply the new configuration:
bash
sudo systemctl restart rsyslog
6. Verify the Configuration
To verify that logs are being forwarded correctly:
Check the local /var/log/audit/audit.log file for recent entries:
bash
sudo tail -f /var/log/audit/audit.log
On the remote syslog server, check the logs to confirm that the audit logs are being received.
7. Optional: Secure the Connection
If you are using TCP for log forwarding, consider enabling encryption (e.g., TLS) to secure the communication between the client and the remote syslog server. This requires additional configuration on both the client and server.
Summary
You configured auditd to write logs to rsyslog.
You set up rsyslog to forward logs to a remote syslog server.
You verified the configuration to ensure logs are being forwarded correctly.
If you encounter any issues, check the rsyslog logs for errors: