#!/bin/sh # # configure-fw-universal.sh - IPtables rules configurator # create configuration file for fw-universal # # Developed by Lubomir Host 'rajo' # Copyright (c) 2005 Platon SDG, http://platon.sk/ # Licensed under terms of GNU General Public License. # All rights reserved. # # Changelog: # 2005-11-01 - created # # $Platon: scripts/shell/firewall/configure-fw-universal.sh,v 1.1 2005/11/01 02:16:56 rajo Exp $ DESC="firewall" TITLE="Firewall configurator" PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin if [ $# -lt 1 ]; then echo "Usage: $0 " exit 1; fi EDIT_CONFIG="$1" DEFAULT_FIREWALL_CONFIG="${DEFAULT_FIREWALL_CONFIG:=$EDIT_CONFIG}" DEFAULT_CACHE_DIR="${DEFAULT_CACHE_DIR:=/var/cache/firewall}" if [ -f "$DEFAULT_FIREWALL_CONFIG" ]; then echo "Reading config file $DEFAULT_FIREWALL_CONFIG" . "$DEFAULT_FIREWALL_CONFIG" fi # # Default configuration values: # # {{{ DEFAULT_POLICY="${DEFAULT_POLICY:=DROP}" # which modules to load MODULES="${MODULES:=}" MODULES_LOADING="${MODULES_LOADING:=yes}" MODULES_REMOVING="${MODULES_REMOVING:=no}" LOG_LIMIT="${LOG_LIMIT:=-m limit --limit 12/h --limit-burst 10 -j LOG --log-level notice --log-prefix}" # Paths: #IPTABLES=":" # for testing only - does nothing IPTABLES="${IPTABLES:=$DEBUG/sbin/iptables}" IPTABLES_SAVE="${IPTABLES_SAVE:=$DEBUG/sbin/iptables-save}" IPTABLES_RESTORE="${IPTABLES_RESTORE:=$DEBUG/sbin/iptables-restore}" if [ "x$LOGGING" = "xoff" ]; then IPTABLES_LOG=": log turned off" else IPTABLES_LOG="${IPTABLES_LOG:=$DEBUG/sbin/iptables}" fi IFCONFIG="${IFCONFIG:=/sbin/ifconfig}" DEPMOD="${DEPMOD:=/sbin/depmod}" MODPROBE="${MODPROBE:=/sbin/modprobe}" RMMOD="${RMMOD:=/sbin/rmmod}" AWK="${AWK:=/usr/bin/awk}" # loopback interface LO_IFACE="${LO_IFACE:=lo}" LO_IP="IP_$LO_IFACE" # # CONSTANTS - Do not edit # ANYWHERE="0.0.0.0/0" # Match any IP address BROADCAST_SRC="0.0.0.0" # Broadcast Source Address BROADCAST_DEST="255.255.255.255" # Broadcast Destination Address CLASS_A="10.0.0.0/8" # Class-A Private (RFC-1918) Networks CLASS_B="172.16.0.0/12" # Class-B Private (RFC-1918) Networks CLASS_C="192.168.0.0/16" # Class-C Private (RFC-1918) Networks CLASS_D_MULTICAST="224.0.0.0/4" # Class-D Multicast Addresses CLASS_E_RESERVED_NET="240.0.0.0/5" # Class-E Reserved Addresses PRIVPORTS="0:1023" # Well-Known, Privileged Port Range UNPRIVPORTS="1024:65535" # Unprivileged Port Range TRACEROUTE_SRC_PORTS="32769:65535" # Traceroute Source Ports TRACEROUTE_DEST_PORTS="33434:33523" # Traceroute Destination Ports # allow some ICMP packets - needed for ping etc. ACCEPT_ICMP_PACKETS="${ACCEPT_ICMP_PACKETS:=echo-reply destination-unreachable echo-request time-exceeded}" # }}} save_config() { # {{{ # header {{{ cat > $EDIT_CONFIG <> $EDIT_CONFIG <> $EDIT_CONFIG <
> $EDIT_CONFIG < $tempfile eval $end_user_input # }}} varname=ANTISPOOF_IFACE # {{{ eval $start_user_input conf_title="Interface protected to spoofing. Do NOT add LAN interface here. If you are directly connected to internet, type 'eth0'" dialog --clear --title "$TITLE" --inputbox -- "$varname\n\n$conf_title" $dialog_height $dialog_width "${!varname}" 2> $tempfile eval $end_user_input # }}} varname=TRACEROUTE_IFACE # {{{ eval $start_user_input conf_title="Usefull with NAT and for power users. Keep empty or type 'eth1'" dialog --clear --title "$TITLE" --inputbox -- "$varname\n\n$conf_title" $dialog_height $dialog_width "${!varname}" 2> $tempfile eval $end_user_input # }}} varname=BANNED_IP # {{{ eval $start_user_input conf_title="Banned IP addresses - packets from this hosts are DROPPED. Multiple items in form 146.48.97.0/24 are allowed" dialog --clear --title "$TITLE" --inputbox -- "$varname\n\n$conf_title" $dialog_height $dialog_width "${!varname}" 2> $tempfile eval $end_user_input # }}} varname=IFACE_ACCEPT_ALL # {{{ eval $start_user_input conf_title="ALL packets from these interfaces are accepted. Add only 'lo' interface here. If you know, what you are doing and do you have VPN interfaces, add 'tun+' and 'tap+' interfaces too." dialog --clear --title "$TITLE" --inputbox -- "$varname\n\n$conf_title" $dialog_height $dialog_width "${!varname}" 2> $tempfile eval $end_user_input # }}} # # Now save config file # save_config # vim600: fdm=marker fdl=0 fdc=3