You are here

howto: log tcp_wrappers

back in april 2010 when i was studying for my RHCE i had a hard time deducing what tcp wrappers was letting through and what it was denying. so some research here and there showed there was a way to log tcp_wrappers. what i found was the deny bit and although i havent tried it, since i had no reason to, i am assuming a similar method is also available for the allow bit.

so to enable logging we edit the /etc/hosts.deny file and add the following:

ALL: ALL : spawn /bin/echo "`date` Host address = %a; Client Information = %c; Host Name = %h; Client Hostname = %n; Daemon PID = %p; Server Info = %s; Client Username = %u" >> /var/log/tcp_wrapper.log

if you do use  the command and not just for debugging purpose, it might also be a good idea to enable log rotate on the log file. also, there are other expansions available from the man page for hosts.deny