APF firewall. Daily automated email showing firewall status
This is how to get your server to send you a daily email showing the status of your APF firewall. In other words, letting you know if it's running or not!
This is done by setting up a cron job.
A cron job is simply an automated task carried out by the server at regular specified intervals, usually hourly, daily, weekly etc.
We are going to get the server to check your APF firewall log on a daily basis, and output the result to an email address of your choosing. To do this, we are going to create a new file containing the instructions in the relevant cron directory.
Lets do it:
This assumes you are using SSH and are logged on as root.
When I first tried this on a new server, my mail provider rejected the email because the server name (hostname) myserver.mydomain.com was "unroutable". This was because my server name was not in the DNS. You must add it to whatever DNS you are using, pointing it to the IP address of your server, so that you can be sure of getting the mails from your server.
6. You can experiment with different cron jobs, making a new file for each job for simplicity's sake.
The important thing is to include the "shebang" line first:
What follows this is just regular Linux commands. Put each command on a new line.
So you can get the file to do practically anything you can do at the command prompt, then email it to you if desired.
Think of it as the file entering the Linux commands for you!