I made a following script that check every 5 minutes to check firewall is running or not, if firewall down that raise an alert only once, but following script generate an alert every 5 minutes according to cronjob:
Code:
FILE="/var/log/fwstatus"
CHK="/tmp/fwstatus"
service iptables status | if grep ESTABLISHED 1> /dev/null 2> /dev/null
then
rm -f $CHK
echo "Firewall Running on Server"
if test -f $CHK
then
echo "Not Sending an Email"
exit
fi
else
echo `date` | tee $FILE
echo | tee -a $FILE
echo "Firewall not Running" | tee -a $FILE
echo | tee -a $FILE
echo "Starting a Firewall Service" | tee -a $FILE
echo | tee -a $FILE
/scripts/fw-scripts/fw | tee -a $FILE (This is IPTABLES Script)
if test $? = 0
then
echo "FW Run" | tee -a $FILE
else
echo "FW Stop" | tee -a $FILE
fi
echo "Now sending mail"
$MAILPROG -s "$SUBJECT" "$EMAIL" < $FILE
echo "Creating Tmp File"
touch $CHK
fi
Last edited by pludi; 03-17-2010 at 03:55 AM..
Reason: code tags, please...
If I am understanding your issue correctly, you are getting an email alert that the firewall is down each time cron runs the job (every five minutes).
This reason you are getting an email each time is due to 2 factors:
1. Firewall is still down, even though your script is suppose to start it
2. You never check to see if $CHK, your /tmp/fwstatus file, exist before sending the email.
if test -f $CHK
then
# do nothing - it's existence means you sent an email already
# and hopefully that email made it to you :)
else
echo "Now sending mail"
$MAILPROG -s "$SUBJECT" "$EMAIL" < $FILE
echo "Creating Tmp File"
touch $CHK
fi
Also, I noticed this and don't believe these lines are required - you remove $CHK, and then do a test to see if it's there.
Code:
service iptables status | if grep ESTABLISHED 1> /dev/null 2> /dev/null
then
rm -f $CHK
echo "Firewall Running on Server"
line not needed ----> if test -f $CHK
line not needed ----> then
echo "Not Sending an Email"
exit
line not needed ----> fi
I have my firewall process running
# ps -ef | grep firewall
root 21169 1 0 08:50 ? 00:00:00 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid
I wish to know what ip : port number it is using. Can you please tell me how can i find out ?
I tried the below command... (4 Replies)
Hi,
I need to know what kind of firewall settings does the linux box have? Is port 25 blocked in any way?
Linux techx 3.10.0-514.10.2.el7.x86_64 #1 SMP Fri Mar 3 00:04:05 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
I'm coming from this thread. (1 Reply)
Hi,
i have a scripts which transfer a file from source to dest server. It uses the firewall information like IP, USERNAME, PASSWORD.
I wanted to know it belongs to source system firewall or the destination firewall info. How to check that firewall connection is working or no without running... (1 Reply)
Dear all
I am writing a shell script to use telnet for the connection test
There are 3 cases to test and detail as:
/* Case 1 - The port can be connected */
# telnet host_a 20101 < /dev/null 2>&1 | grep -q Connected
# echo $? return 0
/* Case 2 - The port cannot be connected */
#... (1 Reply)
startup script displays a message:
# /etc/init.d/firewall start
Starting firewall: iptables
iptables v1.4.2: Can't use -i with OUTPUT
Try `iptables -h' or 'iptables --help' for more information.
iptables v1.4.2: Can't use -i with OUTPUT
not to understand what is wrong in the... (2 Replies)
UTIN Firewall script for Linux 2.4.x and iptables
==============================================
#!/bin/sh
#
# rc.firewall - UTIN Firewall script for Linux 2.4.x and iptables
#
# Copyright (C) 2001 Oskar Andreasson <bluefluxATkoffeinDOTnet>
#
# This program is free software; you can... (5 Replies)