March 10, 2008
Commands, Firewall, Mail
2 Comments
Prerouting can be very useful if you need a quick fix and do not want to mess with the application itself. For example, if you need to have your MTA listen on port 587 and do not want to alter the configuration files (the daemon will not actually listen on port 587, iptables will redirect the traffic), you can use the following iptables rule to preroute traffic going to port 587 to port 25.
/sbin/iptables -t nat -I PREROUTING -p tcp --dport 587 -j REDIRECT --to-ports 25
March 2, 2008
Commands, Scripting
No Comments
The ‘find’ command is a very powerful search tool in UNIX systems. The mtime option comes in very handy when I am trying to troubleshoot a problem, automate tasks or do forensics. Below are some examples:
Finding all files owned by apache modified in the last 3 days within /var/www/html:
find /var/www/html -type f -user apache -mtime -3
Finding all files that were modified 3 days ago or before in the current directory:
find . -type f -mtime +3
Deleting all files in the current directory older than (modified before) 100 days:
find . -type f -mtime +100 -exec rm -f '{}' \;