<div dir="ltr">On 11 April 2013 21:46, SebA <span dir="ltr"><<a href="mailto:spah@syntec.co.uk" target="_blank">spah@syntec.co.uk</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

<u></u>



<div>
<div><font face="Arial"><span>Is there any code 
out there to monitor that</span></font></div>
<div><font face="Arial"><span>(a) iptables is 
running (not just set to everything allowed)</span></font></div>
<div><font face="Arial"><span>(b) SELinux is 
enabled</span></font></div></div></blockquote><div><br></div><div style>For the second one, you can add this to client-local.cfg:</div><div style><br></div><div style>file:/selinux/enforce:md5</div><div style><br></div><div style>

then in analysis.cfg:</div><div style><br></div><div>FILE /selinux/enforce MD5=cfcd208495d565ef66e7dff9f98764da red "TEXT=SELinux is not enforcing"</div><div><br></div><div style>This will warn if the contents of /selinux/enforce is not zero.  This also warns if the file does not exist (such as when selinux is disabled).</div>

<div style><br></div><div style><div style>You can't really do the same thing with iptables, because you need to be root to dump the rules.  There's only so much the xymon user can do.  You could check that the ip_tables kernel module is loaded with lsmod, or you could check a file that a root cron job dumps to every 5 minutes.  You also might want to be a bit careful that you're not transmitting iptables rules in-the-clear to the Xymon server.  Perhaps something like this:</div>

<div style><br></div><div style>Create /etc/cron.d/dump-iptables with:</div><div style><br></div><div style># analyse and report on iptables rules, for xymon to read</div><div style>*/5 * * * * root { /usr/bin/iptables-save | grep "^:INPUT REJECT" >/dev/null && echo "green: iptables default is reject" || echo "red: iptables problem"; } | logger</div>

<div style><br></div><div style>This will put a messages in your syslog, which you can then match using standard Xymon log monitoring.</div><div style><br></div><div style>One problem with this technique is that when someone stops the cronjob, you'll simply stop getting log messages through.  There are ways to detect or work around this.</div>

<div style><br></div><div style>J</div><div style><br></div></div></div></div></div>