Alok's Blog

Firewall checking script

This is a simple script which create a file fwallOP.txt containing different Iptabales related information.
before u run this script u should be a sudo user
#!/bin/bash

echo > fwallOP.txt
echo "Up Time  details" >> fwallOP.txt;
echo "#############################################" >> fwallOP.txt;
sudo /usr/bin/uptime >> fwallOP.txt;
echo "#############################################" >> fwallOP.txt;

echo "interface details" >> fwallOP.txt;
echo "#############################################" >> fwallOP.txt;
sudo /sbin/ifconfig -a >> fwallOP.txt;
echo "#############################################" >> fwallOP.txt;

echo "kernel Module details" >> fwallOP.txt;
echo "#############################################" >> fwallOP.txt;
sudo /bin/lsmod | grep ip_tables >> fwallOP.txt;
echo "#############################################" >> fwallOP.txt;

echo "NATtable  details" >> fwallOP.txt;
echo "#############################################" >> fwallOP.txt;
sudo /sbin/iptables -t nat -S  >> fwallOP.txt;
echo "#############################################" >> fwallOP.txt;

echo "$sudo iptables -t nat -L " >> fwallOP.txt;
echo "#############################################" >> fwallOP.txt;
sudo /sbin/iptables -t nat -L >> fwallOP.txt;
echo "#############################################" >> fwallOP.txt;

echo "IPtables  details" >> fwallOP.txt;
echo "#############################################" >> fwallOP.txt;
sudo /sbin/iptables -S  >> fwallOP.txt;
echo "#############################################" >> fwallOP.txt;

echo "$sudo iptables -L " >> fwallOP.txt;
echo "#############################################" >> fwallOP.txt;
sudo /sbin/iptables -L >> fwallOP.txt;
echo "#############################################" >> fwallOP.txt;
echo "Mangle  details" >> fwallOP.txt;
echo "#############################################" >> fwallOP.txt;
sudo /sbin/iptables -t mangle -S  >> fwallOP.txt;
echo "#############################################" >> fwallOP.txt;

echo "$sudo iptables -t mangle -L " >> fwallOP.txt;
echo "#############################################" >> fwallOP.txt;
sudo /sbin/iptables -t mangle -L >> fwallOP.txt;
echo "#############################################" >> fwallOP.txt;

echo "Filter table  details" >> fwallOP.txt;
echo "#############################################" >> fwallOP.txt;
sudo /sbin/iptables -t filter -S  >> fwallOP.txt;
echo "#############################################" >> fwallOP.txt;

echo "$sudo iptables -t filter -L " >> fwallOP.txt;
echo "#############################################" >> fwallOP.txt;
sudo /sbin/iptables -t filter -L >> fwallOP.txt;
echo "#############################################" >> fwallOP.txt;

Advertisements

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: