2004-01-31 17:11:22 +01:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
2005-05-02 22:54:43 +02:00
|
|
|
# Shorewall Packet Filtering Firewall Control Program - V2.3
|
2004-01-31 17:11:22 +01:00
|
|
|
#
|
|
|
|
# This program is under GPL [http://www.gnu.org/copyleft/gpl.htm]
|
|
|
|
#
|
2005-01-17 19:07:55 +01:00
|
|
|
# (c) 1999,2000,2001,2002,2003,2004,2005 - Tom Eastep (teastep@shorewall.net)
|
2004-01-31 17:11:22 +01:00
|
|
|
#
|
|
|
|
# This file should be placed in /sbin/shorewall.
|
|
|
|
#
|
|
|
|
# Shorewall documentation is available at http://shorewall.sourceforge.net
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of Version 2 of the GNU General Public License
|
|
|
|
# as published by the Free Software Foundation.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA
|
|
|
|
#
|
|
|
|
# If an error occurs while starting or restarting the firewall, the
|
|
|
|
# firewall is automatically stopped.
|
|
|
|
#
|
2004-02-10 00:52:01 +01:00
|
|
|
# The firewall uses configuration files in /etc/shorewall/ - skeleton
|
2004-01-31 17:11:22 +01:00
|
|
|
# files is included with the firewall.
|
|
|
|
#
|
|
|
|
# Commands are:
|
|
|
|
#
|
|
|
|
# shorewall add <iface>[:<host>] zone Adds a host or subnet to a zone
|
|
|
|
# shorewall delete <iface>[:<host>] zone Deletes a host or subnet from a zone
|
2004-08-20 00:22:49 +02:00
|
|
|
# shorewall start Starts the firewall
|
2004-01-31 17:11:22 +01:00
|
|
|
# shorewall restart Restarts the firewall
|
|
|
|
# shorewall stop Stops the firewall
|
|
|
|
# shorewall monitor [ refresh-interval ] Repeatedly Displays firewall status
|
|
|
|
# plus the last 20 "interesting"
|
|
|
|
# packets
|
|
|
|
# shorewall status Displays firewall status
|
|
|
|
# shorewall reset Resets iptables packet and
|
|
|
|
# byte counts
|
|
|
|
# shorewall clear Open the floodgates by
|
|
|
|
# removing all iptables rules
|
|
|
|
# and setting the three permanent
|
|
|
|
# chain policies to ACCEPT
|
|
|
|
# shorewall refresh Rebuild the common chain to
|
|
|
|
# compensate for a change of
|
|
|
|
# broadcast address on any "detect"
|
|
|
|
# interface.
|
|
|
|
# shorewall show <chain> [ <chain> ... ] Display the rules in each <chain> listed
|
|
|
|
# shorewall show log Print the last 20 log messages
|
|
|
|
# shorewall show connections Show the kernel's connection
|
|
|
|
# tracking table
|
|
|
|
# shorewall show nat Display the rules in the nat table
|
|
|
|
# shorewall show {mangle|tos} Display the rules in the mangle table
|
|
|
|
# shorewall show tc Display traffic control info
|
|
|
|
# shorewall show classifiers Display classifiers
|
2005-04-15 16:22:08 +02:00
|
|
|
# shorewall show capabilities Display iptables/kernel capabilities
|
2004-01-31 17:11:22 +01:00
|
|
|
# shorewall version Display the installed version id
|
|
|
|
# shorewall check Verify the more heavily-used
|
|
|
|
# configuration files.
|
|
|
|
# shorewall try <directory> [ <timeout> ] Try a new configuration and if
|
|
|
|
# it doesn't work, revert to the
|
|
|
|
# standard one. If a timeout is supplied
|
|
|
|
# the command reverts back to the
|
|
|
|
# standard configuration after that many
|
|
|
|
# seconds have elapsed after successfully
|
|
|
|
# starting the new configuration.
|
|
|
|
# shorewall logwatch [ refresh-interval ] Monitor the local log for Shorewall
|
|
|
|
# messages.
|
|
|
|
# shorewall drop <address> ... Temporarily drop all packets from the
|
|
|
|
# listed address(es)
|
|
|
|
# shorewall reject <address> ... Temporarily reject all packets from the
|
|
|
|
# listed address(es)
|
|
|
|
# shorewall allow <address> ... Reenable address(es) previously
|
|
|
|
# disabled with "drop" or "reject"
|
2004-06-07 19:38:31 +02:00
|
|
|
# shorewall save [ <file> ] Save the list of "rejected" and
|
2004-01-31 17:11:22 +01:00
|
|
|
# "dropped" addresses so that it will
|
|
|
|
# be automatically reinstated the
|
|
|
|
# next time that Shorewall starts.
|
2004-04-30 05:29:07 +02:00
|
|
|
# Save the current state so that 'shorewall
|
|
|
|
# restore' can be used.
|
|
|
|
#
|
2004-06-07 19:38:31 +02:00
|
|
|
# shorewall forget [ <file> ] Discard the data saved by 'shorewall save'
|
|
|
|
#
|
|
|
|
# shorewall restore [ <file> ] Restore the state of the firewall from
|
|
|
|
# previously saved information.
|
2004-01-31 17:11:22 +01:00
|
|
|
#
|
|
|
|
# shorewall ipaddr [ <address>/<cidr> | <address> <netmask> ]
|
|
|
|
#
|
|
|
|
# Displays information about the network
|
|
|
|
# defined by the argument[s]
|
|
|
|
#
|
|
|
|
# shorewall iprange <address>-<address> Decomposes a range of IP addresses into
|
|
|
|
# a list of network/host addresses.
|
|
|
|
#
|
|
|
|
# Fatal Error
|
|
|
|
#
|
|
|
|
fatal_error() # $@ = Message
|
|
|
|
{
|
|
|
|
echo " $@" >&2
|
|
|
|
exit 2
|
|
|
|
}
|
|
|
|
|
|
|
|
# Display a chain if it exists
|
|
|
|
#
|
|
|
|
|
|
|
|
showfirstchain() # $1 = name of chain
|
|
|
|
{
|
|
|
|
awk \
|
|
|
|
'BEGIN {prnt=0; rslt=1; }; \
|
|
|
|
/^$/ { next; };\
|
|
|
|
/^Chain/ {if ( prnt == 1 ) { rslt=0; exit 0; }; };\
|
|
|
|
/Chain '$1'/ { prnt=1; }; \
|
|
|
|
{ if (prnt == 1) print; };\
|
2004-06-28 19:47:15 +02:00
|
|
|
END { exit rslt; }' $TMPFILE
|
2004-01-31 17:11:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
showchain() # $1 = name of chain
|
|
|
|
{
|
|
|
|
if [ "$firstchain" = "Yes" ]; then
|
|
|
|
if showfirstchain $1; then
|
|
|
|
firstchain=
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
awk \
|
|
|
|
'BEGIN {prnt=0;};\
|
|
|
|
/^$|^ pkts/ { next; };\
|
|
|
|
/^Chain/ {if ( prnt == 1 ) exit; };\
|
|
|
|
/Chain '$1'/ { prnt=1; };\
|
2004-06-28 19:47:15 +02:00
|
|
|
{ if (prnt == 1) print; }' $TMPFILE
|
2004-01-31 17:11:22 +01:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2004-08-25 00:55:59 +02:00
|
|
|
#
|
|
|
|
# The 'awk' hack that compensates for a bug in iptables-save (actually in libipt_policy.so) and can be removed when that bug is fixed.
|
|
|
|
#
|
|
|
|
|
|
|
|
iptablesbug()
|
|
|
|
{
|
|
|
|
if qt which awk ; then
|
|
|
|
awk 'BEGIN {sline=""; };\
|
|
|
|
/^-j/ { print sline $0; next };\
|
|
|
|
/-m policy.*-j/ { print $0; next };\
|
|
|
|
/-m policy/ { sline=$0; next };\
|
|
|
|
{print ; sline="" }'
|
|
|
|
else
|
|
|
|
echo " Warning: You don't have 'awk' on this system so the output of the save command may be unusable" >&2
|
|
|
|
cat
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2004-06-12 18:26:26 +02:00
|
|
|
#
|
|
|
|
# Validate the value of RESTOREFILE
|
|
|
|
#
|
|
|
|
validate_restorefile() # $* = label
|
|
|
|
{
|
|
|
|
case $RESTOREFILE in
|
|
|
|
*/*)
|
|
|
|
echo " ERROR: $@ must specify a simple file name: $RESTOREFILE" >&2
|
|
|
|
exit 2
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
2004-01-31 17:11:22 +01:00
|
|
|
#
|
|
|
|
# Set the configuration variables from shorewall.conf
|
|
|
|
#
|
|
|
|
get_config() {
|
|
|
|
|
|
|
|
[ -z "$LOGFILE" ] && LOGFILE=/var/log/messages
|
|
|
|
|
|
|
|
if [ ! -f $LOGFILE ]; then
|
|
|
|
echo "LOGFILE ($LOGFILE) does not exist!" >&2
|
|
|
|
exit 2
|
|
|
|
fi
|
|
|
|
#
|
|
|
|
# See if we have a real version of "tail" -- use separate redirection so
|
|
|
|
# that ash (aka /bin/sh on LRP) doesn't crap
|
|
|
|
#
|
|
|
|
if ( tail -n5 $LOGFILE > /dev/null 2> /dev/null ) ; then
|
|
|
|
realtail="Yes"
|
|
|
|
else
|
|
|
|
realtail=""
|
|
|
|
fi
|
|
|
|
|
|
|
|
[ -n "$FW" ] || FW=fw
|
|
|
|
|
|
|
|
[ -n "LOGFORMAT" ] && LOGFORMAT="${LOGFORMAT%%%*}"
|
|
|
|
|
|
|
|
[ -n "$LOGFORMAT" ] || LOGFORMAT="Shorewall:"
|
|
|
|
|
2004-11-26 19:44:42 +01:00
|
|
|
if [ -n "$IPTABLES" ]; then
|
|
|
|
if [ ! -e "$IPTABLES" ]; then
|
|
|
|
echo " ERROR: The program specified in IPTABLES does not exist or is not executable" >&2
|
|
|
|
exit 2
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
IPTABLES=$(which iptables 2> /dev/null)
|
|
|
|
if [ -z "$IPTABLES" ] ; then
|
|
|
|
echo " ERROR: Can't find iptables executable" >&2
|
|
|
|
exit 2
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2004-01-31 17:11:22 +01:00
|
|
|
if [ -n "$SHOREWALL_SHELL" ]; then
|
|
|
|
if [ ! -e "$SHOREWALL_SHELL" ]; then
|
2004-06-12 18:26:26 +02:00
|
|
|
echo " ERROR: The program specified in SHOREWALL_SHELL does not exist or is not executable" >&2
|
2004-01-31 17:11:22 +01:00
|
|
|
exit 2
|
|
|
|
fi
|
|
|
|
fi
|
2004-04-10 04:47:04 +02:00
|
|
|
|
2004-06-07 19:38:31 +02:00
|
|
|
[ -n "$RESTOREFILE" ] || RESTOREFILE=restore
|
|
|
|
|
2004-06-12 18:26:26 +02:00
|
|
|
validate_restorefile RESTOREFILE
|
|
|
|
|
|
|
|
export RESTOREFILE
|
|
|
|
|
2004-01-31 17:11:22 +01:00
|
|
|
}
|
|
|
|
|
2005-02-23 19:11:45 +01:00
|
|
|
#
|
|
|
|
# Clear descriptor 1 if it is a terminal
|
|
|
|
#
|
|
|
|
clear_term() {
|
|
|
|
[ -t 1 ] && clear
|
|
|
|
}
|
|
|
|
|
2004-01-31 17:11:22 +01:00
|
|
|
#
|
|
|
|
# Display IPTABLES rules -- we used to store them in a variable but ash
|
|
|
|
# dies when trying to display large sets of rules
|
|
|
|
#
|
|
|
|
display_chains()
|
|
|
|
{
|
|
|
|
trap "rm -f /tmp/chains-$$; exit 1" 1 2 3 4 5 6 9
|
|
|
|
|
|
|
|
if [ "$haveawk" = "Yes" ]; then
|
|
|
|
#
|
|
|
|
# Send the output to a temporary file since ash craps if we try to store
|
|
|
|
# the output in a variable.
|
|
|
|
#
|
2004-06-28 19:47:15 +02:00
|
|
|
TMPFILE=$(mktempfile)
|
|
|
|
[ -n "$TMPFILE" ] || { echo " ERROR:Cannot create temporary file" >&2; exit 1; }
|
|
|
|
|
2004-11-26 19:44:42 +01:00
|
|
|
$IPTABLES -L $IPT_OPTIONS >> $TMPFILE
|
2004-01-31 17:11:22 +01:00
|
|
|
|
2005-02-23 19:11:45 +01:00
|
|
|
clear_term
|
2004-02-02 21:15:44 +01:00
|
|
|
echo "$banner $(date)"
|
2004-01-31 17:11:22 +01:00
|
|
|
echo
|
|
|
|
echo "Standard Chains"
|
|
|
|
echo
|
|
|
|
firstchain="Yes"
|
|
|
|
showchain INPUT
|
|
|
|
showchain OUTPUT
|
|
|
|
showchain FORWARD
|
|
|
|
|
|
|
|
timed_read
|
|
|
|
|
2005-02-23 19:11:45 +01:00
|
|
|
clear_term
|
2004-02-02 21:15:44 +01:00
|
|
|
echo "$banner $(date)"
|
2004-01-31 17:11:22 +01:00
|
|
|
echo
|
|
|
|
firstchain=Yes
|
|
|
|
echo "Input Chains"
|
|
|
|
echo
|
|
|
|
|
2004-06-28 19:47:15 +02:00
|
|
|
chains=$(grep '^Chain.*_[in|fwd]' $TMPFILE | cut -d' ' -f 2)
|
2004-01-31 17:11:22 +01:00
|
|
|
|
|
|
|
for chain in $chains; do
|
|
|
|
showchain $chain
|
|
|
|
done
|
|
|
|
|
|
|
|
timed_read
|
|
|
|
|
|
|
|
for zone in $zones; do
|
|
|
|
|
2004-06-28 19:47:15 +02:00
|
|
|
if [ -n "$(grep "^Chain \.*${zone}" $TMPFILE)" ] ; then
|
2005-02-23 19:11:45 +01:00
|
|
|
clear_term
|
2004-02-02 21:15:44 +01:00
|
|
|
echo "$banner $(date)"
|
2004-01-31 17:11:22 +01:00
|
|
|
echo
|
|
|
|
firstchain=Yes
|
|
|
|
eval display=\$${zone}_display
|
|
|
|
echo "$display Chains"
|
|
|
|
echo
|
|
|
|
for zone1 in $FW $zones; do
|
|
|
|
showchain ${zone}2$zone1
|
|
|
|
showchain @${zone}2$zone1
|
|
|
|
[ "$zone" != "$zone1" ] && \
|
|
|
|
showchain ${zone1}2${zone} && \
|
|
|
|
showchain @${zone1}2${zone}
|
|
|
|
done
|
|
|
|
|
|
|
|
timed_read
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2005-02-23 19:11:45 +01:00
|
|
|
clear_term
|
2004-02-02 21:15:44 +01:00
|
|
|
echo "$banner $(date)"
|
2004-01-31 17:11:22 +01:00
|
|
|
echo
|
|
|
|
firstchain=Yes
|
|
|
|
echo "Policy Chains"
|
|
|
|
echo
|
|
|
|
showchain common
|
|
|
|
showchain badpkt
|
|
|
|
showchain icmpdef
|
|
|
|
showchain rfc1918
|
|
|
|
showchain blacklst
|
|
|
|
showchain reject
|
|
|
|
showchain newnotsyn
|
|
|
|
for zone in $zones all; do
|
|
|
|
showchain ${zone}2all
|
|
|
|
showchain @${zone}2all
|
|
|
|
[ "$zone" = "all" ] || { showchain all2${zone}; showchain @all2${zone}; }
|
|
|
|
done
|
|
|
|
|
|
|
|
timed_read
|
|
|
|
|
2005-02-23 19:11:45 +01:00
|
|
|
clear_term
|
2004-02-02 21:15:44 +01:00
|
|
|
echo "$banner $(date)"
|
2004-01-31 17:11:22 +01:00
|
|
|
echo
|
|
|
|
firstchain=Yes
|
|
|
|
echo "Dynamic Chain"
|
|
|
|
echo
|
|
|
|
showchain dynamic
|
|
|
|
timed_read
|
|
|
|
|
2004-06-28 19:47:15 +02:00
|
|
|
qt rm -f $TMPFILE
|
2004-01-31 17:11:22 +01:00
|
|
|
else
|
2004-11-26 19:44:42 +01:00
|
|
|
$IPTABLES -L -n -v
|
2004-01-31 17:11:22 +01:00
|
|
|
timed_read
|
|
|
|
fi
|
|
|
|
trap - 1 2 3 4 5 6 9
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#
|
|
|
|
# Delay $timeout seconds -- if we're running on a recent bash2 then allow
|
|
|
|
# <enter> to terminate the delay
|
|
|
|
#
|
|
|
|
timed_read ()
|
|
|
|
{
|
|
|
|
read -t $timeout foo 2> /dev/null
|
|
|
|
|
|
|
|
test $? -eq 2 && sleep $timeout
|
|
|
|
}
|
|
|
|
|
|
|
|
#
|
|
|
|
# Display the last $1 packets logged
|
|
|
|
#
|
|
|
|
packet_log() # $1 = number of messages
|
|
|
|
{
|
|
|
|
local options
|
|
|
|
|
|
|
|
[ -n "$realtail" ] && options="-n$1"
|
|
|
|
|
2005-04-15 16:35:54 +02:00
|
|
|
if [ -n "$VERBOSE" ]; then
|
|
|
|
grep "${LOGFORMAT}" $LOGFILE | \
|
|
|
|
sed s/" kernel:"// | \
|
|
|
|
sed s/" $host $LOGFORMAT"/" "/ | \
|
|
|
|
tail $options
|
|
|
|
else
|
|
|
|
grep "${LOGFORMAT}" $LOGFILE | \
|
|
|
|
sed s/" kernel:"// | \
|
|
|
|
sed s/" $host $LOGFORMAT"/" "/ | \
|
|
|
|
sed 's/MAC=.* SRC=/SRC=/' | \
|
|
|
|
tail $options
|
|
|
|
fi
|
2004-01-31 17:11:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#
|
|
|
|
# Show traffic control information
|
|
|
|
#
|
|
|
|
show_tc() {
|
|
|
|
|
|
|
|
show_one_tc() {
|
|
|
|
local device=${1%@*}
|
2004-02-02 21:15:44 +01:00
|
|
|
qdisc=$(tc qdisc list dev $device)
|
2004-01-31 17:11:22 +01:00
|
|
|
|
|
|
|
if [ -n "$qdisc" ]; then
|
|
|
|
echo Device $device:
|
|
|
|
tc -s -d qdisc show dev $device
|
|
|
|
tc -s -d class show dev $device
|
|
|
|
echo
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
ip link list | \
|
|
|
|
while read inx interface details; do
|
|
|
|
case $inx in
|
|
|
|
[0-9]*)
|
|
|
|
show_one_tc ${interface%:}
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#
|
|
|
|
# Show classifier information
|
|
|
|
#
|
|
|
|
show_classifiers() {
|
|
|
|
|
|
|
|
show_one_classifier() {
|
|
|
|
local device=${1%@*}
|
2004-02-02 21:15:44 +01:00
|
|
|
qdisc=$(tc qdisc list dev $device)
|
2004-01-31 17:11:22 +01:00
|
|
|
|
|
|
|
if [ -n "$qdisc" ]; then
|
|
|
|
echo Device $device:
|
|
|
|
tc -s filter ls dev $device
|
|
|
|
echo
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
ip link list | \
|
|
|
|
while read inx interface details; do
|
|
|
|
case $inx in
|
|
|
|
[0-9]*)
|
|
|
|
show_one_classifier ${interface%:}
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
}
|
|
|
|
#
|
|
|
|
# Monitor the Firewall
|
|
|
|
#
|
|
|
|
monitor_firewall() # $1 = timeout -- if negative, prompt each time that
|
|
|
|
# an 'interesting' packet count changes
|
|
|
|
{
|
|
|
|
|
2004-02-02 21:15:44 +01:00
|
|
|
host=$(echo $HOSTNAME | sed 's/\..*$//')
|
2004-11-26 19:44:42 +01:00
|
|
|
oldrejects=$($IPTABLES -L -v -n | grep 'LOG')
|
2004-01-31 17:11:22 +01:00
|
|
|
|
|
|
|
if [ $1 -lt 0 ]; then
|
|
|
|
let "timeout=- $1"
|
|
|
|
pause="Yes"
|
|
|
|
else
|
|
|
|
pause="No"
|
|
|
|
timeout=$1
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
if qt which awk; then
|
2004-06-28 19:47:15 +02:00
|
|
|
TMP_DIR=$(mktempdir)
|
|
|
|
[ -n "$TMP_DIR" ] || { echo " ERROR:Cannot create temporary directory" >&2; exit 1; }
|
2004-01-31 17:11:22 +01:00
|
|
|
haveawk=Yes
|
|
|
|
determine_zones
|
|
|
|
rm -rf $TMP_DIR
|
|
|
|
else
|
|
|
|
haveawk=
|
|
|
|
fi
|
|
|
|
|
|
|
|
while true; do
|
|
|
|
display_chains
|
|
|
|
|
2005-02-23 19:11:45 +01:00
|
|
|
clear_term
|
2004-02-02 21:15:44 +01:00
|
|
|
echo "$banner $(date)"
|
2004-01-31 17:11:22 +01:00
|
|
|
echo
|
|
|
|
|
|
|
|
echo "Dropped/Rejected Packet Log"
|
|
|
|
echo
|
|
|
|
|
|
|
|
show_reset
|
|
|
|
|
2004-11-26 19:44:42 +01:00
|
|
|
rejects=$($IPTABLES -L -v -n | grep 'LOG')
|
2004-01-31 17:11:22 +01:00
|
|
|
|
|
|
|
if [ "$rejects" != "$oldrejects" ]; then
|
|
|
|
oldrejects="$rejects"
|
|
|
|
|
|
|
|
$RING_BELL
|
|
|
|
|
|
|
|
packet_log 20
|
|
|
|
|
|
|
|
if [ "$pause" = "Yes" ]; then
|
|
|
|
echo
|
|
|
|
echo $ECHO_N 'Enter any character to continue: '
|
|
|
|
read foo
|
|
|
|
else
|
|
|
|
timed_read
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo
|
|
|
|
packet_log 20
|
|
|
|
timed_read
|
|
|
|
fi
|
|
|
|
|
2005-02-23 19:11:45 +01:00
|
|
|
clear_term
|
2004-02-02 21:15:44 +01:00
|
|
|
echo "$banner $(date)"
|
2004-01-31 17:11:22 +01:00
|
|
|
echo
|
|
|
|
echo "NAT Status"
|
|
|
|
echo
|
2004-11-26 19:44:42 +01:00
|
|
|
$IPTABLES -t nat -L $IPT_OPTIONS
|
2004-01-31 17:11:22 +01:00
|
|
|
timed_read
|
|
|
|
|
2005-02-23 19:11:45 +01:00
|
|
|
clear_term
|
2004-02-02 21:15:44 +01:00
|
|
|
echo "$banner $(date)"
|
2004-01-31 17:11:22 +01:00
|
|
|
echo
|
|
|
|
echo
|
|
|
|
echo "TOS/MARK Status"
|
|
|
|
echo
|
2004-11-26 19:44:42 +01:00
|
|
|
$IPTABLES -t mangle -L $IPT_OPTIONS
|
2004-01-31 17:11:22 +01:00
|
|
|
timed_read
|
|
|
|
|
2005-02-23 19:11:45 +01:00
|
|
|
clear_term
|
2004-02-02 21:15:44 +01:00
|
|
|
echo "$banner $(date)"
|
2004-01-31 17:11:22 +01:00
|
|
|
echo
|
|
|
|
echo
|
|
|
|
echo "Tracked Connections"
|
|
|
|
echo
|
|
|
|
cat /proc/net/ip_conntrack
|
|
|
|
timed_read
|
|
|
|
|
2005-02-23 19:11:45 +01:00
|
|
|
clear_term
|
2004-02-02 21:15:44 +01:00
|
|
|
echo "$banner $(date)"
|
2004-01-31 17:11:22 +01:00
|
|
|
echo
|
|
|
|
echo
|
|
|
|
echo "Traffic Shaping/Control"
|
|
|
|
echo
|
|
|
|
show_tc
|
|
|
|
timed_read
|
|
|
|
|
2005-02-23 19:11:45 +01:00
|
|
|
clear_term
|
2004-02-02 21:15:44 +01:00
|
|
|
echo "$banner $(date)"
|
2004-01-31 17:11:22 +01:00
|
|
|
echo
|
|
|
|
echo
|
|
|
|
echo "Packet Classifiers"
|
|
|
|
echo
|
|
|
|
show_classifiers
|
|
|
|
timed_read
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
#
|
|
|
|
# Watch the Firewall Log
|
|
|
|
#
|
|
|
|
logwatch() # $1 = timeout -- if negative, prompt each time that
|
|
|
|
# an 'interesting' packet count changes
|
|
|
|
{
|
|
|
|
|
2004-02-02 21:15:44 +01:00
|
|
|
host=$(echo $HOSTNAME | sed 's/\..*$//')
|
2004-11-26 19:44:42 +01:00
|
|
|
oldrejects=$($IPTABLES -L -v -n | grep 'LOG')
|
2004-01-31 17:11:22 +01:00
|
|
|
|
2005-04-16 17:19:22 +02:00
|
|
|
if [ $1 -lt 0 ]; then
|
2004-01-31 17:11:22 +01:00
|
|
|
timeout=$((- $1))
|
|
|
|
pause="Yes"
|
|
|
|
else
|
|
|
|
pause="No"
|
|
|
|
timeout=$1
|
|
|
|
fi
|
|
|
|
|
|
|
|
qt which awk && haveawk=Yes || haveawk=
|
|
|
|
|
|
|
|
while true; do
|
2005-02-23 19:11:45 +01:00
|
|
|
clear_term
|
2004-02-02 21:15:44 +01:00
|
|
|
echo "$banner $(date)"
|
2004-01-31 17:11:22 +01:00
|
|
|
echo
|
|
|
|
|
|
|
|
echo "Dropped/Rejected Packet Log"
|
|
|
|
echo
|
|
|
|
|
|
|
|
show_reset
|
|
|
|
|
2004-11-26 19:44:42 +01:00
|
|
|
rejects=$($IPTABLES -L -v -n | grep 'LOG')
|
2004-01-31 17:11:22 +01:00
|
|
|
|
|
|
|
if [ "$rejects" != "$oldrejects" ]; then
|
|
|
|
oldrejects="$rejects"
|
|
|
|
|
|
|
|
$RING_BELL
|
|
|
|
|
|
|
|
packet_log 40
|
|
|
|
|
|
|
|
if [ "$pause" = "Yes" ]; then
|
|
|
|
echo
|
|
|
|
echo $ECHO_N 'Enter any character to continue: '
|
|
|
|
read foo
|
|
|
|
else
|
|
|
|
timed_read
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo
|
|
|
|
packet_log 40
|
|
|
|
timed_read
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
#
|
|
|
|
# Help information
|
|
|
|
#
|
|
|
|
help()
|
|
|
|
{
|
|
|
|
[ -x $HELP ] && { export version; exec $HELP $*; }
|
|
|
|
echo "Help subsystem is not installed at $HELP"
|
|
|
|
}
|
|
|
|
|
|
|
|
#
|
|
|
|
# Give Usage Information
|
|
|
|
#
|
|
|
|
usage() # $1 = exit status
|
|
|
|
{
|
2005-04-15 16:35:54 +02:00
|
|
|
echo "Usage: $(basename $0) [debug|trace] [nolock] [ -x ] [ -q ] [ -f ] [ -v ] <command>"
|
2004-01-31 17:11:22 +01:00
|
|
|
echo "where <command> is one of:"
|
2004-12-13 19:51:00 +01:00
|
|
|
echo " add <interface>[:{<bridge-port>[:<host>]|<host>}[,...]] ... <zone>"
|
2004-01-31 17:11:22 +01:00
|
|
|
echo " allow <address> ..."
|
2004-08-20 00:22:49 +02:00
|
|
|
echo " check [ <directory> ]"
|
2004-01-31 17:11:22 +01:00
|
|
|
echo " clear"
|
2004-12-13 19:51:00 +01:00
|
|
|
echo " delete <interface>[:{<bridge-port>[:<host>]|<host>}[,...]] ... <zone>"
|
2004-01-31 17:11:22 +01:00
|
|
|
echo " drop <address> ..."
|
2004-06-07 19:38:31 +02:00
|
|
|
echo " forget [ <file name> ]"
|
2004-01-31 17:11:22 +01:00
|
|
|
echo " help [ <command > | host | address ]"
|
|
|
|
echo " hits"
|
|
|
|
echo " ipcalc [ <address>/<vlsm> | <address> <netmask> ]"
|
|
|
|
echo " iprange <address>-<address>"
|
|
|
|
echo " logwatch [<refresh interval>]"
|
|
|
|
echo " monitor [<refresh interval>]"
|
|
|
|
echo " refresh"
|
|
|
|
echo " reject <address> ..."
|
|
|
|
echo " reset"
|
2004-08-20 00:22:49 +02:00
|
|
|
echo " restart [ <directory> ]"
|
2004-06-07 19:38:31 +02:00
|
|
|
echo " restore [ <file name> ]"
|
|
|
|
echo " save [ <file name> ]"
|
2005-04-15 16:22:08 +02:00
|
|
|
echo " show [<chain> [ <chain> ... ]|capabilities|classifiers|connections|log|nat|tc|tos|zones]"
|
2004-08-20 00:22:49 +02:00
|
|
|
echo " start [ <directory> ]"
|
2004-01-31 17:11:22 +01:00
|
|
|
echo " stop"
|
|
|
|
echo " status"
|
|
|
|
echo " try <directory> [ <timeout> ]"
|
|
|
|
echo " version"
|
2004-08-20 00:22:49 +02:00
|
|
|
echo
|
2004-01-31 17:11:22 +01:00
|
|
|
exit $1
|
|
|
|
}
|
|
|
|
|
|
|
|
#
|
|
|
|
# Display the time that the counters were last reset
|
|
|
|
#
|
|
|
|
show_reset() {
|
|
|
|
[ -f $STATEDIR/restarted ] && \
|
2004-02-02 21:15:44 +01:00
|
|
|
echo "Counters reset $(cat $STATEDIR/restarted)" && \
|
2004-01-31 17:11:22 +01:00
|
|
|
echo
|
|
|
|
}
|
2004-09-26 22:13:56 +02:00
|
|
|
#
|
|
|
|
# Display's the passed file name followed by "=" and the file's contents.
|
|
|
|
#
|
|
|
|
show_proc() # $1 = name of a file
|
|
|
|
{
|
|
|
|
[ -f $1 ] && echo " $1 = $(cat $1)"
|
2004-09-25 00:07:08 +02:00
|
|
|
}
|
|
|
|
|
2004-01-31 17:11:22 +01:00
|
|
|
#
|
|
|
|
# Execution begins here
|
|
|
|
#
|
|
|
|
debugging=
|
|
|
|
|
2004-02-11 00:30:20 +01:00
|
|
|
if [ $# -gt 0 ] && [ "$1" = "debug" -o "$1" = "trace" ]; then
|
2004-01-31 17:11:22 +01:00
|
|
|
debugging=debug
|
|
|
|
shift
|
|
|
|
fi
|
|
|
|
|
|
|
|
nolock=
|
|
|
|
|
|
|
|
if [ $# -gt 0 ] && [ "$1" = "nolock" ]; then
|
|
|
|
nolock=nolock
|
|
|
|
shift
|
|
|
|
fi
|
|
|
|
|
|
|
|
SHOREWALL_DIR=
|
2004-04-21 23:44:22 +02:00
|
|
|
QUIET=
|
2004-03-20 16:10:17 +01:00
|
|
|
IPT_OPTIONS="-nv"
|
2004-04-29 05:27:47 +02:00
|
|
|
FAST=
|
2005-04-15 16:35:54 +02:00
|
|
|
VERBOSE=
|
2004-04-29 05:27:47 +02:00
|
|
|
|
2004-01-31 17:11:22 +01:00
|
|
|
done=0
|
|
|
|
|
|
|
|
while [ $done -eq 0 ]; do
|
|
|
|
[ $# -eq 0 ] && usage 1
|
2004-04-22 22:57:36 +02:00
|
|
|
option=$1
|
|
|
|
case $option in
|
|
|
|
-*)
|
|
|
|
option=${option#-}
|
|
|
|
|
2004-04-23 04:53:27 +02:00
|
|
|
[ -z "$option" ] && usage 1
|
2004-04-22 22:57:36 +02:00
|
|
|
|
2004-04-23 04:53:27 +02:00
|
|
|
while [ -n "$option" ]; do
|
2004-04-22 22:57:36 +02:00
|
|
|
case $option in
|
|
|
|
c)
|
|
|
|
[ $# -eq 1 ] && usage 1
|
|
|
|
|
|
|
|
if [ ! -d $2 ]; then
|
|
|
|
if [ -e $2 ]; then
|
|
|
|
echo "$2 is not a directory" >&2 && exit 2
|
|
|
|
else
|
|
|
|
echo "Directory $2 does not exist" >&2 && exit 2
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
SHOREWALL_DIR=$2
|
|
|
|
option=
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
x*)
|
|
|
|
IPT_OPTIONS="-xnv"
|
|
|
|
option=${option#x}
|
|
|
|
;;
|
|
|
|
q*)
|
|
|
|
QUIET=Yes
|
|
|
|
option=${option#q}
|
|
|
|
;;
|
2004-04-29 05:27:47 +02:00
|
|
|
f*)
|
|
|
|
FAST=Yes
|
|
|
|
option=${option#f}
|
|
|
|
;;
|
2005-04-15 16:35:54 +02:00
|
|
|
v*)
|
|
|
|
VERBOSE=Yes
|
|
|
|
option=${option#v}
|
|
|
|
;;
|
2004-04-22 22:57:36 +02:00
|
|
|
*)
|
|
|
|
usage 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
done=1
|
|
|
|
;;
|
2004-01-31 17:11:22 +01:00
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ $# -eq 0 ]; then
|
|
|
|
usage 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
[ -n "$SHOREWALL_DIR" ] && export SHOREWALL_DIR
|
2004-04-21 23:44:22 +02:00
|
|
|
[ -n "$QUIET" ] && export QUIET
|
2004-01-31 17:11:22 +01:00
|
|
|
|
|
|
|
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/local/sbin
|
|
|
|
MUTEX_TIMEOUT=
|
|
|
|
|
2004-02-10 00:52:01 +01:00
|
|
|
SHARED_DIR=/usr/share/shorewall
|
2004-01-31 17:11:22 +01:00
|
|
|
FIREWALL=$SHARED_DIR/firewall
|
|
|
|
FUNCTIONS=$SHARED_DIR/functions
|
|
|
|
VERSION_FILE=$SHARED_DIR/version
|
|
|
|
HELP=$SHARED_DIR/help
|
|
|
|
|
|
|
|
if [ -f $FUNCTIONS ]; then
|
|
|
|
. $FUNCTIONS
|
|
|
|
else
|
|
|
|
echo "$FUNCTIONS does not exist!" >&2
|
|
|
|
exit 2
|
|
|
|
fi
|
|
|
|
|
2004-04-15 15:51:55 +02:00
|
|
|
ensure_config_path
|
|
|
|
|
2004-02-02 21:15:44 +01:00
|
|
|
config=$(find_file shorewall.conf)
|
2004-01-31 17:11:22 +01:00
|
|
|
|
|
|
|
if [ -f $config ]; then
|
2004-06-28 19:47:15 +02:00
|
|
|
if [ -r $config ]; then
|
|
|
|
. $config
|
|
|
|
else
|
|
|
|
echo "Cannot read $config! (Hint: Are you root?)" >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
2004-01-31 17:11:22 +01:00
|
|
|
else
|
|
|
|
echo "$config does not exist!" >&2
|
|
|
|
exit 2
|
|
|
|
fi
|
|
|
|
|
2004-04-15 15:51:55 +02:00
|
|
|
ensure_config_path
|
2004-04-13 19:15:15 +02:00
|
|
|
|
|
|
|
export CONFIG_PATH
|
2004-04-10 04:47:04 +02:00
|
|
|
|
2004-11-27 00:24:50 +01:00
|
|
|
get_config
|
|
|
|
|
2004-01-31 17:11:22 +01:00
|
|
|
[ -z "${STATEDIR}" ] && STATEDIR=/var/state/shorewall
|
|
|
|
|
|
|
|
if [ ! -f $FIREWALL ]; then
|
|
|
|
echo "ERROR: Shorewall is not properly installed"
|
|
|
|
if [ -L $FIREWALL ]; then
|
|
|
|
echo " $FIREWALL is a symbolic link to a"
|
|
|
|
echo " non-existant file"
|
|
|
|
else
|
|
|
|
echo " The file $FIREWALL does not exist"
|
|
|
|
fi
|
|
|
|
|
|
|
|
exit 2
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -f $VERSION_FILE ]; then
|
2004-02-02 21:15:44 +01:00
|
|
|
version=$(cat $VERSION_FILE)
|
2004-01-31 17:11:22 +01:00
|
|
|
else
|
|
|
|
echo "ERROR: Shorewall is not properly installed"
|
|
|
|
echo " The file $VERSION_FILE does not exist"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
banner="Shorewall-$version Status at $HOSTNAME -"
|
|
|
|
|
2004-02-02 21:15:44 +01:00
|
|
|
case $(echo -e) in
|
2004-01-31 17:11:22 +01:00
|
|
|
-e*)
|
|
|
|
RING_BELL="echo \a"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
RING_BELL="echo -e \a"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2004-02-02 21:15:44 +01:00
|
|
|
case $(echo -n "Testing") in
|
2004-01-31 17:11:22 +01:00
|
|
|
-n*)
|
|
|
|
ECHO_N=
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
ECHO_N=-n
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
case "$1" in
|
2004-04-29 05:27:47 +02:00
|
|
|
start)
|
2004-08-20 00:22:49 +02:00
|
|
|
case $# in
|
|
|
|
1)
|
|
|
|
;;
|
|
|
|
2)
|
|
|
|
[ -n "$SHOREWALL_DIR" -o -n "$FAST" ] && usage 2
|
|
|
|
|
|
|
|
if [ ! -d $2 ]; then
|
|
|
|
if [ -e $2 ]; then
|
|
|
|
echo "$2 is not a directory" >&2 && exit 2
|
|
|
|
else
|
|
|
|
echo "Directory $2 does not exist" >&2 && exit 2
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
SHOREWALL_DIR=$2
|
|
|
|
export SHOREWALL_DIR
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
usage 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2004-04-29 16:09:41 +02:00
|
|
|
if [ -n "$FAST" ]; then
|
2004-06-12 18:26:26 +02:00
|
|
|
|
|
|
|
RESTOREPATH=/var/lib/shorewall/$RESTOREFILE
|
|
|
|
|
|
|
|
if [ -x $RESTOREPATH ]; then
|
2005-05-06 00:35:17 +02:00
|
|
|
if [ -x ${RESTOREPATH}-ipsets ]; then
|
|
|
|
echo Restoring Ipsets...
|
|
|
|
#
|
|
|
|
# We must purge iptables to be sure that there are no
|
|
|
|
# references to ipsets
|
|
|
|
#
|
|
|
|
iptables -F
|
|
|
|
iptables -X
|
|
|
|
${RESTOREPATH}-ipsets
|
|
|
|
fi
|
|
|
|
|
2004-04-29 16:09:41 +02:00
|
|
|
echo Restoring Shorewall...
|
2004-06-12 18:26:26 +02:00
|
|
|
$RESTOREPATH
|
2004-04-29 16:09:41 +02:00
|
|
|
date > $STATEDIR/restarted
|
2004-06-12 18:26:26 +02:00
|
|
|
echo Shorewall restored from $RESTOREPATH
|
2004-04-29 16:09:41 +02:00
|
|
|
else
|
|
|
|
exec $SHOREWALL_SHELL $FIREWALL $debugging $nolock start
|
|
|
|
fi
|
|
|
|
else
|
2004-04-29 05:27:47 +02:00
|
|
|
exec $SHOREWALL_SHELL $FIREWALL $debugging $nolock start
|
|
|
|
fi
|
|
|
|
;;
|
2004-08-20 00:22:49 +02:00
|
|
|
stop|reset|clear|refresh)
|
2004-01-31 17:11:22 +01:00
|
|
|
[ $# -ne 1 ] && usage 1
|
|
|
|
exec $SHOREWALL_SHELL $FIREWALL $debugging $nolock $1
|
|
|
|
;;
|
2004-08-20 00:22:49 +02:00
|
|
|
check|restart)
|
|
|
|
case $# in
|
|
|
|
1)
|
|
|
|
;;
|
|
|
|
2)
|
|
|
|
[ -n "$SHOREWALL_DIR" ] && usage 2
|
|
|
|
|
|
|
|
if [ ! -d $2 ]; then
|
|
|
|
if [ -e $2 ]; then
|
|
|
|
echo "$2 is not a directory" >&2 && exit 2
|
|
|
|
else
|
|
|
|
echo "Directory $2 does not exist" >&2 && exit 2
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
SHOREWALL_DIR=$2
|
|
|
|
export SHOREWALL_DIR
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
usage 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
exec $SHOREWALL_SHELL $FIREWALL $debugging $nolock $1
|
|
|
|
;;
|
2004-01-31 17:11:22 +01:00
|
|
|
add|delete)
|
2004-12-08 21:00:03 +01:00
|
|
|
[ $# -lt 3 ] && usage 1
|
|
|
|
exec $SHOREWALL_SHELL $FIREWALL $debugging $nolock $@
|
2004-01-31 17:11:22 +01:00
|
|
|
;;
|
|
|
|
show|list)
|
2004-02-11 00:30:20 +01:00
|
|
|
[ -n "$debugging" ] && set -x
|
2004-01-31 17:11:22 +01:00
|
|
|
case "$2" in
|
|
|
|
connections)
|
|
|
|
[ $# -gt 2 ] && usage 1
|
2004-02-02 21:15:44 +01:00
|
|
|
echo "Shorewall-$version Connections at $HOSTNAME - $(date)"
|
2004-01-31 17:11:22 +01:00
|
|
|
echo
|
2004-10-10 23:54:14 +02:00
|
|
|
cat /proc/net/ip_conntrack
|
2004-01-31 17:11:22 +01:00
|
|
|
;;
|
|
|
|
nat)
|
|
|
|
[ $# -gt 2 ] && usage 1
|
2004-02-02 21:15:44 +01:00
|
|
|
echo "Shorewall-$version NAT at $HOSTNAME - $(date)"
|
2004-01-31 17:11:22 +01:00
|
|
|
echo
|
|
|
|
show_reset
|
2004-11-26 19:44:42 +01:00
|
|
|
$IPTABLES -t nat -L $IPT_OPTIONS
|
2004-01-31 17:11:22 +01:00
|
|
|
;;
|
|
|
|
tos|mangle)
|
|
|
|
[ $# -gt 2 ] && usage 1
|
2004-02-02 21:15:44 +01:00
|
|
|
echo "Shorewall-$version TOS at $HOSTNAME - $(date)"
|
2004-01-31 17:11:22 +01:00
|
|
|
echo
|
|
|
|
show_reset
|
2004-11-26 19:44:42 +01:00
|
|
|
$IPTABLES -t mangle -L $IPT_OPTIONS
|
2004-01-31 17:11:22 +01:00
|
|
|
;;
|
|
|
|
log)
|
|
|
|
[ $# -gt 2 ] && usage 1
|
2004-02-02 21:15:44 +01:00
|
|
|
echo "Shorewall-$version Log at $HOSTNAME - $(date)"
|
2004-01-31 17:11:22 +01:00
|
|
|
echo
|
|
|
|
show_reset
|
2004-02-02 21:15:44 +01:00
|
|
|
host=$(echo $HOSTNAME | sed 's/\..*$//')
|
2004-01-31 17:11:22 +01:00
|
|
|
packet_log 20
|
|
|
|
;;
|
|
|
|
tc)
|
|
|
|
[ $# -gt 2 ] && usage 1
|
2004-02-02 21:15:44 +01:00
|
|
|
echo "Shorewall-$version Traffic Control at $HOSTNAME - $(date)"
|
2004-01-31 17:11:22 +01:00
|
|
|
echo
|
|
|
|
show_tc
|
|
|
|
;;
|
|
|
|
classifiers)
|
|
|
|
[ $# -gt 2 ] && usage 1
|
2004-02-02 21:15:44 +01:00
|
|
|
echo "Shorewall-$version Clasifiers at $HOSTNAME - $(date)"
|
2004-01-31 17:11:22 +01:00
|
|
|
echo
|
|
|
|
show_classifiers
|
|
|
|
;;
|
2004-11-27 20:44:32 +01:00
|
|
|
zones)
|
|
|
|
[ $# -gt 2 ] && usage 1
|
|
|
|
[ -z "${STATEDIR}" ] && STATEDIR=/var/state/shorewall
|
|
|
|
if [ -f $STATEDIR/zones ]; then
|
|
|
|
echo "Shorewall-$version Zones at $HOSTNAME - $(date)"
|
|
|
|
echo
|
|
|
|
while read zone hosts; do
|
|
|
|
echo $zone
|
|
|
|
for host in $hosts; do
|
|
|
|
echo " $host"
|
|
|
|
done
|
|
|
|
done < $STATEDIR/zones
|
|
|
|
echo
|
|
|
|
else
|
2004-11-28 18:32:00 +01:00
|
|
|
echo " ERROR: $STATEDIR/zones does not exist" >&2
|
2004-11-27 20:44:32 +01:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
;;
|
2005-04-15 16:22:08 +02:00
|
|
|
capabilities)
|
|
|
|
exec $SHOREWALL_SHELL $FIREWALL $debugging $nolock capabilities
|
|
|
|
;;
|
2004-01-31 17:11:22 +01:00
|
|
|
*)
|
|
|
|
shift
|
|
|
|
|
2004-02-02 21:15:44 +01:00
|
|
|
echo "Shorewall-$version $([ $# -gt 1 ] && echo Chains || echo Chain) $* at $HOSTNAME - $(date)"
|
2004-01-31 17:11:22 +01:00
|
|
|
echo
|
|
|
|
show_reset
|
|
|
|
if [ $# -gt 0 ]; then
|
|
|
|
for chain in $*; do
|
2004-11-26 19:44:42 +01:00
|
|
|
$IPTABLES -L $chain $IPT_OPTIONS
|
2004-01-31 17:11:22 +01:00
|
|
|
done
|
|
|
|
else
|
2004-11-26 19:44:42 +01:00
|
|
|
$IPTABLES -L $IPT_OPTIONS
|
2004-01-31 17:11:22 +01:00
|
|
|
fi
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
;;
|
|
|
|
monitor)
|
2004-02-11 00:30:20 +01:00
|
|
|
[ -n "$debugging" ] && set -x
|
2004-01-31 17:11:22 +01:00
|
|
|
if [ $# -eq 2 ]; then
|
|
|
|
monitor_firewall $2
|
|
|
|
elif [ $# -eq 1 ]; then
|
|
|
|
monitor_firewall 30
|
|
|
|
else
|
|
|
|
usage 1
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
status)
|
2004-02-11 00:30:20 +01:00
|
|
|
[ -n "$debugging" ] && set -x
|
2004-01-31 17:11:22 +01:00
|
|
|
[ $# -eq 1 ] || usage 1
|
2005-02-23 19:11:45 +01:00
|
|
|
clear_term
|
2004-02-02 21:15:44 +01:00
|
|
|
echo "Shorewall-$version Status at $HOSTNAME - $(date)"
|
2004-01-31 17:11:22 +01:00
|
|
|
echo
|
|
|
|
show_reset
|
2004-02-02 21:15:44 +01:00
|
|
|
host=$(echo $HOSTNAME | sed 's/\..*$//')
|
2004-11-26 19:44:42 +01:00
|
|
|
$IPTABLES -L $IPT_OPTIONS
|
2004-01-31 17:11:22 +01:00
|
|
|
echo
|
|
|
|
packet_log 20
|
|
|
|
echo
|
|
|
|
echo "NAT Table"
|
|
|
|
echo
|
2004-11-26 19:44:42 +01:00
|
|
|
$IPTABLES -t nat -L $IPT_OPTIONS
|
2004-01-31 17:11:22 +01:00
|
|
|
echo
|
|
|
|
echo "Mangle Table"
|
|
|
|
echo
|
2004-11-26 19:44:42 +01:00
|
|
|
$IPTABLES -t mangle -L $IPT_OPTIONS
|
2004-01-31 17:11:22 +01:00
|
|
|
echo
|
|
|
|
cat /proc/net/ip_conntrack
|
2004-07-18 03:30:32 +02:00
|
|
|
echo
|
|
|
|
echo "IP Configuration"
|
|
|
|
echo
|
|
|
|
ip addr ls
|
2004-12-03 21:35:21 +01:00
|
|
|
echo
|
|
|
|
echo "IP Stats"
|
|
|
|
echo
|
|
|
|
ip -stat link ls
|
2004-09-24 00:11:10 +02:00
|
|
|
|
|
|
|
if qt which brctl; then
|
|
|
|
echo
|
|
|
|
echo "Bridges"
|
|
|
|
echo
|
|
|
|
brctl show
|
|
|
|
fi
|
|
|
|
|
2004-09-25 00:07:08 +02:00
|
|
|
echo
|
|
|
|
echo "/proc"
|
|
|
|
echo
|
|
|
|
|
|
|
|
show_proc /proc/sys/net/ipv4/ip_forward
|
2004-11-26 19:44:42 +01:00
|
|
|
show_proc /proc/sys/net/ipv4/icmp_echo_ignore_all
|
2004-09-25 00:07:08 +02:00
|
|
|
|
|
|
|
for directory in /proc/sys/net/ipv4/conf/*; do
|
2004-09-25 00:10:05 +02:00
|
|
|
for file in proxy_arp arp_filter rp_filter log_martians; do
|
2004-09-25 00:07:08 +02:00
|
|
|
show_proc $directory/$file
|
|
|
|
done
|
|
|
|
done
|
|
|
|
|
2005-04-02 00:30:38 +02:00
|
|
|
if [ -n "$(ip rule ls)" ]; then
|
2004-07-21 20:57:45 +02:00
|
|
|
echo
|
2005-04-02 00:30:38 +02:00
|
|
|
echo "Routing Rules"
|
2004-07-21 20:57:45 +02:00
|
|
|
echo
|
2005-04-02 00:30:38 +02:00
|
|
|
ip rule ls
|
|
|
|
ip rule ls | while read rule; do
|
|
|
|
table=${rule##* }
|
|
|
|
echo
|
|
|
|
echo "Table $table:"
|
|
|
|
echo
|
|
|
|
ip route ls table $table
|
|
|
|
done
|
|
|
|
else
|
|
|
|
echo
|
|
|
|
echo "Routing Table"
|
|
|
|
echo
|
|
|
|
ip route ls
|
|
|
|
fi
|
2005-01-03 18:27:46 +01:00
|
|
|
|
2005-03-04 17:28:58 +01:00
|
|
|
echo
|
|
|
|
echo "ARP"
|
|
|
|
echo
|
|
|
|
arp -na
|
|
|
|
|
2005-01-03 18:27:46 +01:00
|
|
|
if qt which lsmod; then
|
|
|
|
echo
|
|
|
|
echo "Modules"
|
|
|
|
echo
|
|
|
|
lsmod | grep -E '^ip_|^ipt_'
|
|
|
|
fi
|
2004-01-31 17:11:22 +01:00
|
|
|
;;
|
|
|
|
hits)
|
2004-02-11 00:30:20 +01:00
|
|
|
[ -n "$debugging" ] && set -x
|
2004-01-31 17:11:22 +01:00
|
|
|
[ $# -eq 1 ] || usage 1
|
2005-02-23 19:11:45 +01:00
|
|
|
clear_term
|
2004-02-02 21:15:44 +01:00
|
|
|
echo "Shorewall-$version Hits at $HOSTNAME - $(date)"
|
2004-01-31 17:11:22 +01:00
|
|
|
echo
|
|
|
|
|
|
|
|
timeout=30
|
|
|
|
|
2004-02-02 21:15:44 +01:00
|
|
|
if [ $(grep -c "$LOGFORMAT" $LOGFILE ) -gt 0 ] ; then
|
2004-01-31 17:11:22 +01:00
|
|
|
echo " HITS IP DATE"
|
|
|
|
echo " ---- --------------- ------"
|
|
|
|
grep "$LOGFORMAT" $LOGFILE | sed 's/\(.\{6\}\)\(.*SRC=\)\(.*\)\( DST=.*\)/\3 \1/' | sort | uniq -c | sort -rn
|
|
|
|
echo ""
|
|
|
|
|
|
|
|
echo " HITS IP PORT"
|
|
|
|
echo " ---- --------------- -----"
|
|
|
|
grep "$LOGFORMAT" $LOGFILE | sed 's/\(.*SRC=\)\(.*\)\( DST=.*DPT=\)\([0-9]\{1,5\}\)\(.*\)/\2 \4/
|
|
|
|
t
|
|
|
|
s/\(.*SRC=\)\(.*\)\( DST=.*\)/\2/' | sort | uniq -c | sort -rn
|
|
|
|
echo ""
|
|
|
|
|
|
|
|
echo " HITS DATE"
|
|
|
|
echo " ---- ------"
|
|
|
|
grep "$LOGFORMAT" $LOGFILE | sed 's/\(.\{6\}\)\(.*\)/\1/' | sort | uniq -c | sort -rn
|
|
|
|
echo ""
|
|
|
|
|
|
|
|
echo " HITS PORT SERVICE(S)"
|
|
|
|
echo " ---- ----- ----------"
|
|
|
|
grep "$LOGFORMAT.*DPT" $LOGFILE | sed 's/\(.*DPT=\)\([0-9]\{1,5\}\)\(.*\)/\2/' | sort | uniq -c | sort -rn | \
|
|
|
|
while read count port ; do
|
|
|
|
# List all services defined for the given port
|
2004-02-02 21:15:44 +01:00
|
|
|
srv=$(grep "^[^#].*\\b$port/" /etc/services | cut -f 1 | sort -u)
|
|
|
|
srv=$(echo $srv | sed 's/ /,/g')
|
2004-01-31 17:11:22 +01:00
|
|
|
|
|
|
|
if [ -n "$srv" ] ; then
|
|
|
|
printf '%7d %5d %s\n' $count $port $srv
|
|
|
|
else
|
|
|
|
printf '%7d %5d\n' $count $port
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
version)
|
|
|
|
echo $version
|
|
|
|
;;
|
|
|
|
try)
|
|
|
|
[ -n "$SHOREWALL_DIR" ] && startup_error "Error: -c option may not be used with \"try\""
|
|
|
|
[ $# -lt 2 -o $# -gt 3 ] && usage 1
|
|
|
|
if ! $0 $debugging -c $2 restart; then
|
2004-11-26 19:44:42 +01:00
|
|
|
if ! $IPTABLES -L shorewall > /dev/null 2> /dev/null; then
|
2004-01-31 17:11:22 +01:00
|
|
|
$0 start
|
|
|
|
fi
|
2004-11-26 19:44:42 +01:00
|
|
|
elif ! $IPTABLES -L shorewall > /dev/null 2> /dev/null; then
|
2004-01-31 17:11:22 +01:00
|
|
|
$0 start
|
|
|
|
elif [ $# -eq 3 ]; then
|
|
|
|
sleep $3
|
|
|
|
$0 restart
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
logwatch)
|
2004-02-11 00:30:20 +01:00
|
|
|
[ -n "$debugging" ] && set -x
|
2004-01-31 17:11:22 +01:00
|
|
|
if [ $# -eq 2 ]; then
|
|
|
|
logwatch $2
|
|
|
|
elif [ $# -eq 1 ]; then
|
|
|
|
logwatch 30
|
|
|
|
else
|
|
|
|
usage 1
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
drop)
|
2004-02-11 00:30:20 +01:00
|
|
|
[ -n "$debugging" ] && set -x
|
2004-01-31 17:11:22 +01:00
|
|
|
[ $# -eq 1 ] && usage 1
|
|
|
|
mutex_on
|
|
|
|
while [ $# -gt 1 ]; do
|
|
|
|
shift
|
2004-11-26 19:44:42 +01:00
|
|
|
qt $IPTABLES -D dynamic -s $1 -j reject
|
|
|
|
qt $IPTABLES -D dynamic -s $1 -j DROP
|
|
|
|
$IPTABLES -A dynamic -s $1 -j DROP || break 1
|
2004-01-31 17:11:22 +01:00
|
|
|
echo "$1 Dropped"
|
|
|
|
done
|
|
|
|
mutex_off
|
|
|
|
;;
|
|
|
|
reject)
|
2004-02-11 00:30:20 +01:00
|
|
|
[ -n "$debugging" ] && set -x
|
2004-01-31 17:11:22 +01:00
|
|
|
[ $# -eq 1 ] && usage 1
|
|
|
|
mutex_on
|
|
|
|
while [ $# -gt 1 ]; do
|
|
|
|
shift
|
2004-11-26 19:44:42 +01:00
|
|
|
qt $IPTABLES -D dynamic -s $1 -j reject
|
|
|
|
qt $IPTABLES -D dynamic -s $1 -j DROP
|
|
|
|
$IPTABLES -A dynamic -s $1 -j reject || break 1
|
2004-01-31 17:11:22 +01:00
|
|
|
echo "$1 Rejected"
|
|
|
|
done
|
|
|
|
mutex_off
|
|
|
|
;;
|
|
|
|
allow)
|
2004-02-11 00:30:20 +01:00
|
|
|
[ -n "$debugging" ] && set -x
|
2004-01-31 17:11:22 +01:00
|
|
|
[ $# -eq 1 ] && usage 1
|
|
|
|
mutex_on
|
|
|
|
while [ $# -gt 1 ]; do
|
|
|
|
shift
|
2004-11-26 19:44:42 +01:00
|
|
|
if qt $IPTABLES -D dynamic -s $1 -j reject || qt $IPTABLES -D dynamic -s $1 -j DROP; then
|
2004-01-31 17:11:22 +01:00
|
|
|
echo "$1 Allowed"
|
|
|
|
else
|
|
|
|
echo "$1 Not Dropped or Rejected"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
mutex_off
|
|
|
|
;;
|
|
|
|
save)
|
2004-02-11 00:30:20 +01:00
|
|
|
[ -n "$debugging" ] && set -x
|
2004-06-07 04:23:37 +02:00
|
|
|
|
|
|
|
case $# in
|
|
|
|
1)
|
|
|
|
;;
|
|
|
|
2)
|
|
|
|
RESTOREFILE="$2"
|
2004-06-12 18:26:26 +02:00
|
|
|
validate_restorefile '<restore file>'
|
2004-06-07 04:23:37 +02:00
|
|
|
;;
|
|
|
|
*)
|
|
|
|
usage 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2004-06-12 18:26:26 +02:00
|
|
|
RESTOREPATH=/var/lib/shorewall/$RESTOREFILE
|
|
|
|
|
2004-01-31 17:11:22 +01:00
|
|
|
mutex_on
|
2004-04-29 05:27:47 +02:00
|
|
|
|
2004-11-26 19:44:42 +01:00
|
|
|
if qt $IPTABLES -L shorewall -n; then
|
2004-06-11 20:21:04 +02:00
|
|
|
[ -d /var/lib/shorewall ] || mkdir -p /var/lib/shorewall
|
|
|
|
|
2004-06-12 18:26:26 +02:00
|
|
|
if [ -f $RESTOREPATH -a ! -x $RESTOREPATH ]; then
|
|
|
|
echo " ERROR: $RESTOREPATH exists and is not a saved Shorewall configuration"
|
2004-01-31 17:11:22 +01:00
|
|
|
else
|
2004-06-11 20:21:04 +02:00
|
|
|
case $RESTOREFILE in
|
|
|
|
save|restore-base)
|
2004-10-04 01:39:46 +02:00
|
|
|
echo " ERROR: Reserved file name: $RESTOREFILE"
|
2004-06-11 20:21:04 +02:00
|
|
|
;;
|
|
|
|
*)
|
2004-11-26 19:44:42 +01:00
|
|
|
if $IPTABLES -L dynamic -n > /var/lib/shorewall/save; then
|
2004-06-11 20:21:04 +02:00
|
|
|
echo " Dynamic Rules Saved"
|
|
|
|
if [ -f /var/lib/shorewall/restore-base ]; then
|
|
|
|
cp -f /var/lib/shorewall/restore-base /var/lib/shorewall/restore-$$
|
2004-08-25 00:55:59 +02:00
|
|
|
if iptables-save | iptablesbug >> /var/lib/shorewall/restore-$$ ; then
|
2004-06-11 20:21:04 +02:00
|
|
|
echo __EOF__ >> /var/lib/shorewall/restore-$$
|
2004-11-30 22:57:36 +01:00
|
|
|
[ -f /var/lib/shorewall/restore-tail ] && \
|
|
|
|
cat /var/lib/shorewall/restore-tail >> /var/lib/shorewall/restore-$$
|
|
|
|
mv -f /var/lib/shorewall/restore-$$ $RESTOREPATH
|
2004-06-12 18:26:26 +02:00
|
|
|
chmod +x $RESTOREPATH
|
|
|
|
echo " Currently-running Configuration Saved to $RESTOREPATH"
|
2005-05-06 00:35:17 +02:00
|
|
|
|
|
|
|
case $SAVE_IPSETS in
|
|
|
|
[Yy]es)
|
|
|
|
RESTOREPATH=${RESTOREPATH}-ipsets
|
|
|
|
echo "#!/bin/sh" >> /var/lib/shorewall/restore-$$
|
|
|
|
echo "ipset -U :all: :all:" >> /var/lib/shorewall/restore-$$
|
|
|
|
echo "ipset -F" >> /var/lib/shorewall/restore-$$
|
|
|
|
echo "ipset -X" >> /var/lib/shorewall/restore-$$
|
|
|
|
echo "ipset -R << __EOF__" >> /var/lib/shorewall/restore-$$
|
|
|
|
ipset -S >> /var/lib/shorewall/restore-$$
|
|
|
|
echo "__EOF__" >> /var/lib/shorewall/restore-$$
|
|
|
|
mv -f /var/lib/shorewall/restore-$$ $RESTOREPATH
|
|
|
|
chmod +x $RESTOREPATH
|
|
|
|
echo " Current Ipset Contents Saved to $RESTOREPATH"
|
|
|
|
;;
|
|
|
|
esac
|
2004-06-11 20:21:04 +02:00
|
|
|
else
|
|
|
|
rm -f /var/lib/shorewall/restore-$$
|
|
|
|
echo " ERROR: Currently-running Configuration Not Saved"
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo " ERROR: /var/lib/shorewall/restore-base does not exist"
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo "Error Saving the Dynamic Rules"
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
esac
|
2004-01-31 17:11:22 +01:00
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo "Shorewall isn't started"
|
|
|
|
fi
|
|
|
|
mutex_off
|
|
|
|
;;
|
2004-04-30 05:29:07 +02:00
|
|
|
forget)
|
2004-06-07 04:23:37 +02:00
|
|
|
case $# in
|
|
|
|
1)
|
|
|
|
;;
|
|
|
|
2)
|
|
|
|
RESTOREFILE="$2"
|
2004-06-12 18:26:26 +02:00
|
|
|
validate_restorefile '<restore file>'
|
2004-06-07 04:23:37 +02:00
|
|
|
;;
|
|
|
|
*)
|
|
|
|
usage 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2004-06-12 18:26:26 +02:00
|
|
|
|
|
|
|
RESTOREPATH=/var/lib/shorewall/$RESTOREFILE
|
|
|
|
|
|
|
|
if [ -x $RESTOREPATH ]; then
|
2005-05-06 00:35:17 +02:00
|
|
|
|
|
|
|
if [ -x ${RESTOREPATH}-ipsets ]; then
|
|
|
|
rm -f ${RESTOREPATH}-ipsets
|
|
|
|
echo " ${RESTOREPATH}-ipsets removed"
|
|
|
|
fi
|
|
|
|
|
2004-06-12 18:26:26 +02:00
|
|
|
rm -f $RESTOREPATH
|
|
|
|
echo " $RESTOREPATH removed"
|
|
|
|
elif [ -f $RESTOREPATH ]; then
|
2004-10-04 01:39:46 +02:00
|
|
|
echo " $RESTOREPATH exists and is not a saved Shorewall configuration"
|
2004-06-07 04:23:37 +02:00
|
|
|
fi
|
2004-04-30 05:29:07 +02:00
|
|
|
;;
|
2004-01-31 17:11:22 +01:00
|
|
|
ipcalc)
|
2004-02-11 00:30:20 +01:00
|
|
|
[ -n "$debugging" ] && set -x
|
2004-01-31 17:11:22 +01:00
|
|
|
if [ $# -eq 2 ]; then
|
|
|
|
address=${2%/*}
|
|
|
|
vlsm=${2#*/}
|
|
|
|
elif [ $# -eq 3 ]; then
|
|
|
|
address=$2
|
2004-02-02 21:15:44 +01:00
|
|
|
vlsm=$(ip_vlsm $3)
|
2004-01-31 17:11:22 +01:00
|
|
|
else
|
|
|
|
usage 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
[ -z "$vlsm" ] && exit 2
|
|
|
|
[ "x$address" = "x$vlsm" ] && usage 2
|
|
|
|
[ $vlsm -gt 32 ] && echo "Invalid VLSM: /$vlsm" >&2 && exit 2
|
|
|
|
|
|
|
|
address=$address/$vlsm
|
|
|
|
|
2004-02-02 21:15:44 +01:00
|
|
|
echo " CIDR=$address"
|
|
|
|
temp=$(ip_netmask $address); echo " NETMASK=$(encodeaddr $temp)"
|
|
|
|
temp=$(ip_network $address); echo " NETWORK=$temp"
|
|
|
|
temp=$(broadcastaddress $address); echo " BROADCAST=$temp"
|
2004-01-31 17:11:22 +01:00
|
|
|
;;
|
|
|
|
|
|
|
|
iprange)
|
2004-02-11 00:30:20 +01:00
|
|
|
[ -n "$debugging" ] && set -x
|
2004-01-31 17:11:22 +01:00
|
|
|
case $2 in
|
|
|
|
*.*.*.*-*.*.*.*)
|
|
|
|
ip_range $2
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
usage 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
;;
|
2004-04-29 05:27:47 +02:00
|
|
|
restore)
|
2004-06-07 04:23:37 +02:00
|
|
|
case $# in
|
|
|
|
1)
|
|
|
|
;;
|
|
|
|
2)
|
|
|
|
RESTOREFILE="$2"
|
2004-06-12 18:26:26 +02:00
|
|
|
validate_restorefile '<restore file>'
|
2004-06-07 04:23:37 +02:00
|
|
|
;;
|
|
|
|
*)
|
|
|
|
usage 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2004-06-12 18:26:26 +02:00
|
|
|
RESTOREPATH=/var/lib/shorewall/$RESTOREFILE
|
|
|
|
|
|
|
|
if [ -x $RESTOREPATH ]; then
|
2005-05-06 00:35:17 +02:00
|
|
|
|
|
|
|
if [ -x ${RESTOREPATH}-ipsets ] ; then
|
|
|
|
echo Restoring Ipsets...
|
|
|
|
iptables -F
|
|
|
|
iptables -X
|
|
|
|
${RESTOREPATH}-ipsets
|
|
|
|
fi
|
|
|
|
|
2004-04-29 05:27:47 +02:00
|
|
|
echo Restoring Shorewall...
|
2004-06-12 18:26:26 +02:00
|
|
|
$RESTOREPATH && echo "Shorewall restored from /var/lib/shorewall/$RESTOREFILE"
|
2004-04-29 05:27:47 +02:00
|
|
|
else
|
2004-06-07 04:23:37 +02:00
|
|
|
echo "File /var/lib/shorewall/$RESTOREFILE: file not found"
|
2004-04-29 05:27:47 +02:00
|
|
|
exit 2
|
|
|
|
fi
|
|
|
|
;;
|
2004-01-31 17:11:22 +01:00
|
|
|
call)
|
2004-02-11 00:30:20 +01:00
|
|
|
[ -n "$debugging" ] && set -x
|
2004-01-31 17:11:22 +01:00
|
|
|
#
|
2004-02-10 00:52:01 +01:00
|
|
|
# Undocumented way to call functions in /usr/share/shorewall/functions directly
|
2004-01-31 17:11:22 +01:00
|
|
|
#
|
|
|
|
shift;
|
|
|
|
$@
|
|
|
|
;;
|
|
|
|
help)
|
|
|
|
shift
|
|
|
|
[ $# -ne 1 ] && usage 1
|
|
|
|
help $@
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
usage 1
|
|
|
|
;;
|
|
|
|
|
|
|
|
esac
|