#!/bin/sh
#	testfw 0.03
#
#	Copyright (C) 2002:	Manel Marin <manel3@wanadoo.es>
#	Licence:		GNU GPL version >= 2
#
#
#	Test the firewall without safety risks
#
#	Use:	testfirewall
#

echo ""
echo "TESTING FIREWALL"
echo ""

# NO ALIAS PRESENT
if [ "`grep \"lo:0\" /etc/network/interfaces`" = "" ]
then
    echo "Test IP alias lo:0 does not exist -> authomatic test not possible"
    echo "Please read /usr/share/doc/firewall-easy/offline-testing"
    echo ""
    exit
fi

# OPEN ALIAS lo:0
ifup lo:0


# THIS WAS TESTED WITH POTATO AND WOODY nmap 2.12 & 2.54BETA31
# All test are in background and echoing nothing (stderr/stdout)

#like ping 1.1.1.1 -c 4 (only can root)
nmap -S 1.1.1.1 -sP -PI 1.1.1.1 > /dev/null 2>&1 &

#like telnet 1.1.1.1 &
nmap -S 1.1.1.1 -P0 -sT -p 23 1.1.1.1 > /dev/null 2>&1 &

# high tcp/udp test
nmap -S 1.1.1.1 -P0 -sT -sU -p 20022 1.1.1.1 > /dev/null 2>&1 &


# CLOSE lo:0 AFTER SOME TIME
sleep 180 && ifdown lo:0 &	# NOTE: sleep counts in seconds
