Postfix – subject, from and to log

This is a little trick for Postfix, it lets you log the subject, from and to of all the emails postfix sends (or which pass through it if you run it as a relay). It comes in handy when you need to debug an email issue and need to confirm your mailserver has sent the message.

First create the file /etc/postfix/header_checks and insert this into it:

/^subject:/      WARN
/^to:/           WARN
/^from:/         WARN
/^Subject:/      WARN
/^To:/           WARN
/^From:/         WARN
Read More

Diplaying Logs with journalctl [CentOS7]

To simply view the logs on your system, you can execute the following command:
journalctl
This will display the logs with the oldest entries first. Although this is simple, it is not very useful since we do not tend to read logs like a book.
By default journalctl displays the logs in a pager. It shows you one page of logs requiring you to hit the space bar to proceed.
Diplaying Logs by Date Read More

Iptables log connection

Here is an example to log new tcp connections (port 22):
-A INPUT -m state –state NEW -m tcp -p tcp –dport 22 -j LOG –log-prefix “New Connection: ” –log-level 4
Here is an example to log any tcp connections:

iptables -A INPUT -m state --state NEW -j LOG --log-prefix "New Connection: "
iptables -A OUTPUT -m state --state NEW -j LOG --log-prefix "New Connection: "