2007-07-03 01:34:29 +02:00
|
|
|
#!/bin/sh
|
2007-03-11 21:35:38 +01:00
|
|
|
#
|
|
|
|
# Clear Proxy Arp
|
|
|
|
#
|
|
|
|
delete_proxyarp() {
|
|
|
|
if [ -f ${VARDIR}/proxyarp ]; then
|
|
|
|
while read address interface external haveroute; do
|
|
|
|
qt arp -i $external -d $address pub
|
|
|
|
[ -z "${haveroute}${NOROUTES}" ] && qt ip route del $address dev $interface
|
|
|
|
done < ${VARDIR}/proxyarp
|
|
|
|
|
|
|
|
for f in /proc/sys/net/ipv4/conf/*; do
|
|
|
|
[ -f $f/proxy_arp ] && echo 0 > $f/proxy_arp
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
|
|
|
rm -f ${VARDIR}/proxyarp
|
|
|
|
}
|
|
|
|
|
|
|
|
#
|
|
|
|
# Remove all Shorewall-added rules
|
|
|
|
#
|
|
|
|
clear_firewall() {
|
|
|
|
stop_firewall
|
|
|
|
|
|
|
|
setpolicy INPUT ACCEPT
|
|
|
|
setpolicy FORWARD ACCEPT
|
|
|
|
setpolicy OUTPUT ACCEPT
|
|
|
|
|
|
|
|
run_iptables -F
|
|
|
|
|
|
|
|
echo 1 > /proc/sys/net/ipv4/ip_forward
|
|
|
|
|
|
|
|
if [ -n "$DISABLE_IPV6" ]; then
|
|
|
|
if qt mywhich ip6tables; then
|
|
|
|
ip6tables -P INPUT ACCEPT 2> /dev/null
|
|
|
|
ip6tables -P OUTPUT ACCEPT 2> /dev/null
|
|
|
|
ip6tables -P FORWARD ACCEPT 2> /dev/null
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
run_clear_exit
|
|
|
|
|
|
|
|
set_state "Cleared"
|
|
|
|
|
|
|
|
logger -p kern.info "$PRODUCT Cleared"
|
|
|
|
}
|
|
|
|
|
|
|
|
#
|
|
|
|
# Issue a message and stop/restore the firewall
|
|
|
|
#
|
|
|
|
fatal_error()
|
|
|
|
{
|
|
|
|
echo " ERROR: $@" >&2
|
|
|
|
stop_firewall
|
2007-03-22 19:24:33 +01:00
|
|
|
[ -n "$TEMPFILE" ] && rm -f $TEMPFILE
|
2007-03-11 21:35:38 +01:00
|
|
|
exit 2
|
|
|
|
}
|
|
|
|
|
|
|
|
#
|
|
|
|
# Issue a message and stop
|
|
|
|
#
|
|
|
|
startup_error() # $* = Error Message
|
|
|
|
{
|
|
|
|
echo " ERROR: $@" >&2
|
|
|
|
case $COMMAND in
|
|
|
|
start)
|
|
|
|
logger -p kern.err "ERROR:$PRODUCT start failed"
|
|
|
|
;;
|
|
|
|
restart)
|
|
|
|
logger -p kern.err "ERROR:$PRODUCT restart failed"
|
|
|
|
;;
|
|
|
|
restore)
|
|
|
|
logger -p kern.err "ERROR:$PRODUCT restore failed"
|
|
|
|
;;
|
|
|
|
esac
|
2007-04-08 16:42:26 +02:00
|
|
|
|
2007-03-11 21:35:38 +01:00
|
|
|
kill $$
|
|
|
|
exit 2
|
|
|
|
}
|
|
|
|
|
|
|
|
#
|
|
|
|
# Run iptables and if an error occurs, stop/restore the firewall
|
|
|
|
#
|
|
|
|
run_iptables()
|
|
|
|
{
|
|
|
|
if [ -n "$COMMENT" ]; then
|
|
|
|
$IPTABLES $@ -m comment --comment "$COMMENT"
|
|
|
|
else
|
|
|
|
$IPTABLES $@
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
error_message "ERROR: Command \"$IPTABLES $@\" Failed"
|
|
|
|
stop_firewall
|
|
|
|
exit 2
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
#
|
|
|
|
# Run iptables and if an error occurs, stop/restore the firewall
|
|
|
|
#
|
|
|
|
run_ip()
|
|
|
|
{
|
|
|
|
if ! ip $@; then
|
|
|
|
error_message "ERROR: Command \"ip $@\" Failed"
|
|
|
|
stop_firewall
|
|
|
|
exit 2
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
#
|
|
|
|
# Run tc and if an error occurs, stop/restore the firewall
|
|
|
|
#
|
|
|
|
run_tc() {
|
|
|
|
if ! tc $@ ; then
|
|
|
|
error_message "ERROR: Command \"tc $@\" Failed"
|
|
|
|
stop_firewall
|
|
|
|
exit 2
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2007-03-12 03:59:12 +01:00
|
|
|
restore_dynamic_rules() {
|
|
|
|
if [ -f ${VARDIR}/save ]; then
|
|
|
|
progress_message2 "Setting up dynamic rules..."
|
|
|
|
rangematch='source IP range'
|
|
|
|
while read target ignore1 ignore2 address ignore3 rest; do
|
|
|
|
case $target in
|
|
|
|
DROP|reject|logdrop|logreject)
|
|
|
|
case $rest in
|
|
|
|
$rangematch*)
|
|
|
|
run_iptables -A dynamic -m iprange --src-range ${rest#source IP range} -j $target
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
if [ -z "$rest" ]; then
|
|
|
|
run_iptables -A dynamic -s $address -j $target
|
|
|
|
else
|
|
|
|
error_message "WARNING: Unable to restore dynamic rule \"$target $ignore1 $ignore2 $address $ignore3 $rest\""
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done < ${VARDIR}/save
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2007-04-11 22:51:36 +02:00
|
|
|
#
|
|
|
|
# The following functions also appear in lib.base. They are duplicated here so that
|
|
|
|
# restore scripts from prior versions continue to work.
|
|
|
|
#
|
2007-04-11 19:55:18 +02:00
|
|
|
get_device_mtu1() # $1 = device
|
|
|
|
{
|
2007-07-22 17:23:16 +02:00
|
|
|
local output="$(ip link list dev $1 2> /dev/null)" # quotes required for /bin/ash
|
2007-04-11 19:55:18 +02:00
|
|
|
local mtu
|
|
|
|
|
|
|
|
if [ -n "$output" ]; then
|
|
|
|
mtu=$(find_mtu $output)
|
2007-04-11 22:51:36 +02:00
|
|
|
if [ -n "$mtu" ]; then
|
|
|
|
[ $mtu = 1500 ] || echo mtu $(($mtu + 100))
|
|
|
|
fi
|
2007-04-11 19:55:18 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
}
|
2007-07-26 01:15:37 +02:00
|
|
|
|
|
|
|
#
|
|
|
|
# Get a list of all configured broadcast addresses on the system
|
|
|
|
#
|
|
|
|
get_all_bcasts()
|
|
|
|
{
|
|
|
|
ip -f inet addr show 2> /dev/null | grep 'inet.*brd' | sed 's/inet.*brd //; s/scope.*//;' | sort -u
|
|
|
|
}
|
|
|
|
|