Platon Technologies
neprihlásený Prihlásiť Registrácia
SlovakEnglish
open source software development oslavujeme 10 rokov vývoja otvoreného softvéru! Piatok, 29. marec 2024

Rozdiely pre scripts/shell/firewall/fw-universal.sh medzi verziami 2.86 a 2.88

verzia 2.86, 2011/12/10 19:46:02 verzia 2.88, 2012/02/11 18:59:55
Riadok 22 
Riadok 22 
 # Licensed under terms of GNU General Public License.  # Licensed under terms of GNU General Public License.
 # All rights reserved.  # All rights reserved.
 #  #
 # $Platon: scripts/shell/firewall/fw-universal.sh,v 2.85 2011-12-03 19:28:30 rajo Exp $  # $Platon: scripts/shell/firewall/fw-universal.sh,v 2.87 2012-02-10 23:01:58 rajo Exp $
 #  #
 # Changelog:  # Changelog:
 # 2003-10-24 - created  # 2003-10-24 - created
Riadok 91  PERL="${PERL:=/usr/bin/perl}"
Riadok 91  PERL="${PERL:=/usr/bin/perl}"
 # shaping  # shaping
 TC="${TC:=/sbin/tc}"  TC="${TC:=/sbin/tc}"
   
   # update script
   UPDATE_SCRIPT="${UPDATE_SCRIPT:=update_from_cvs}"
   
 # loopback interface  # loopback interface
 LO_IFACE="${LO_IFACE:=lo}"  LO_IFACE="${LO_IFACE:=lo}"
 # Hide NAT clients behind firewall  # Hide NAT clients behind firewall
Riadok 831  reject_input()
Riadok 834  reject_input()
         if [ ! -z "$ALL_REJECT_INPUT_TCP" ]; then          if [ ! -z "$ALL_REJECT_INPUT_TCP" ]; then
                 print_info -en "Reject ALL INPUT TCP connections on ports:"                  print_info -en "Reject ALL INPUT TCP connections on ports:"
                 for port in $ALL_REJECT_INPUT_TCP; do                  for port in $ALL_REJECT_INPUT_TCP; do
                           echo $port | grep -q ,
                           multiport="$?";
                           if [ "$multiport" -eq 0 ]; then
                                   port_rule="--match multiport --dports $port"
                           else
                                   port_rule="--dport $port"
                           fi
                         for riface in $REAL_INTERFACES; do                          for riface in $REAL_INTERFACES; do
                                 print_info -en " $port($riface)"                                  print_info -en " $port($riface)"
                                 $IPTABLES -A INPUT -i $riface -p TCP --dport $port -j REJECT --reject-with $REJECT_WITH                                  $IPTABLES -A INPUT -i $riface -p TCP $port_rule -j REJECT --reject-with $REJECT_WITH
                         done                          done
                 done                  done
                 print_info " done."                  print_info " done."
Riadok 841  reject_input()
Riadok 851  reject_input()
         if [ ! -z "$ALL_REJECT_INPUT_UDP" ]; then          if [ ! -z "$ALL_REJECT_INPUT_UDP" ]; then
                 print_info -en "Reject ALL INPUT UDP connections on ports:"                  print_info -en "Reject ALL INPUT UDP connections on ports:"
                 for port in $ALL_REJECT_INPUT_UDP; do                  for port in $ALL_REJECT_INPUT_UDP; do
                           echo $port | grep -q ,
                           multiport="$?";
                           if [ "$multiport" -eq 0 ]; then
                                   port_rule="--match multiport --dports $port"
                           else
                                   port_rule="--dport $port"
                           fi
                         for riface in $REAL_INTERFACES; do                          for riface in $REAL_INTERFACES; do
                                 print_info -en " $port($riface)"                                  print_info -en " $port($riface)"
                                 $IPTABLES -A INPUT -i $riface -p UDP --dport $port -j REJECT --reject-with $REJECT_WITH                                  $IPTABLES -A INPUT -i $riface -p UDP $port_rule -j REJECT --reject-with $REJECT_WITH
                         done                          done
                 done                  done
                 print_info " done."                  print_info " done."
Riadok 851  reject_input()
Riadok 868  reject_input()
         if [ ! -z "$REAL_REJECT_INPUT_TCP" ]; then          if [ ! -z "$REAL_REJECT_INPUT_TCP" ]; then
                 print_info -en "Reject REAL all INPUT TCP connections for ALL interfaces on ports:"                  print_info -en "Reject REAL all INPUT TCP connections for ALL interfaces on ports:"
                 for port in $REAL_REJECT_INPUT_TCP; do                  for port in $REAL_REJECT_INPUT_TCP; do
                           echo $port | grep -q ,
                           multiport="$?";
                           if [ "$multiport" -eq 0 ]; then
                                   port_rule="--match multiport --dports $port"
                           else
                                   port_rule="--dport $port"
                           fi
                         print_info -en " $port(ALL)"                          print_info -en " $port(ALL)"
                         $IPTABLES -A INPUT -p TCP --dport $port -j REJECT --reject-with $REJECT_WITH                          $IPTABLES -A INPUT -p TCP $port_rule -j REJECT --reject-with $REJECT_WITH
                 done                  done
                 print_info " done."                  print_info " done."
         fi          fi
         if [ ! -z "$REAL_REJECT_INPUT_UDP" ]; then          if [ ! -z "$REAL_REJECT_INPUT_UDP" ]; then
                 print_info -en "Reject REAL all INPUT UDP connections for ALL interfaces on ports:"                  print_info -en "Reject REAL all INPUT UDP connections for ALL interfaces on ports:"
                 for port in $REAL_REJECT_INPUT_UDP; do                  for port in $REAL_REJECT_INPUT_UDP; do
                           echo $port | grep -q ,
                           multiport="$?";
                           if [ "$multiport" -eq 0 ]; then
                                   port_rule="--match multiport --dports $port"
                           else
                                   port_rule="--dport $port"
                           fi
                         for riface in $REAL_INTERFACES; do                          for riface in $REAL_INTERFACES; do
                                 print_info -en " $port(ALL)"                                  print_info -en " $port(ALL)"
                                 $IPTABLES -A INPUT -p UDP --dport $port -j REJECT --reject-with $REJECT_WITH                                  $IPTABLES -A INPUT -p UDP $port_rule -j REJECT --reject-with $REJECT_WITH
                         done                          done
                 done                  done
                 print_info " done."                  print_info " done."
Riadok 1427  add_banned_ip()
Riadok 1458  add_banned_ip()
         TMPFILE=`mktemp -t fw-universal.sh-XXXXXX` || exit 1          TMPFILE=`mktemp -t fw-universal.sh-XXXXXX` || exit 1
         trap 'rm -f $TMPFILE' 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15          trap 'rm -f $TMPFILE' 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
         if [ -z "$*" ]; then          if [ -z "$*" ]; then
                 print_info "Reading banned IP's from STDIN:"                  #print_info "Reading banned IP's from STDIN:"
                 cat >> $TMPFILE                  cat >> $TMPFILE
         else          else
                 for IP in $*; do                  for IP in $*; do
Riadok 1446  deploy_block()
Riadok 1477  deploy_block()
         fi          fi
         print_info "Deploying to local rules ..."          print_info "Deploying to local rules ..."
         add_banned_ip $*          add_banned_ip $*
         # start the some script twice to refresh rules (new blocked IP's)          # start the same script twice to refresh rules (new blocked IP's)
         QUIET=yes $0 start          QUIET=yes $0 start
         TMPFILE=`mktemp -t fw-universal.sh-XXXXXX` || exit 1          TMPFILE=`mktemp -t fw-universal.sh-XXXXXX` || exit 1
         trap 'rm -f $TMPFILE' 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15          trap 'rm -f $TMPFILE' 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
         for i in $*; do          for i in $*; do
                 echo $i >> $TMPFILE;                  echo "block $i" >> $TMPFILE;
         done          done
         while read conn keyfile          while read conn keyfile
         do          do
Riadok 1461  deploy_block()
Riadok 1492  deploy_block()
                            ;;                             ;;
            esac             esac
            print_info "Deploying to $conn ...";             print_info "Deploying to $conn ...";
            cat $TMPFILE | ssh -i $keyfile $conn $0 block             cat $TMPFILE | ssh -i $keyfile $conn $0 remote
         done < $DEFAULT_FIREWALL_CONFIG_DIR/deploy-servers.list          done < $DEFAULT_FIREWALL_CONFIG_DIR/deploy-servers.list
         rm -f $TMPFILE          rm -f $TMPFILE
 } # }}}  } # }}}
   
   update_from_cvs()
   { # {{{
           cd /etc/firewall && cvs up -d
   } # }}}
   
   update()
   { # {{{
           $UPDATE_SCRIPT
   } # }}}
   
   deploy_update()
   { # {{{
           print_info "Updating local firewall ..."
           $0 update
   
           # start the same script twice to refresh rules (updated scripts and configs)
           QUIET=yes $0 start
           while read conn keyfile
           do
                   case "$conn" in
                           ""|\#*)
                                   continue
                                   ;;
                   esac
              print_info "Updating $conn ...";
              echo "update" | ssh -i $keyfile $conn $0 remote
           done < $DEFAULT_FIREWALL_CONFIG_DIR/deploy-servers.list
   } # }}}
   
   remote()
   { # {{{
           while read comnd par
           do
                   case "$comnd" in
                           block)
                                   echo "Blocking '$par'..."
                                   add_banned_ip $par
                                   ;;
                           update)
                                   echo "Updating..."
                                   update
                                   ;;
                           ""|\#*)
                                   echo "Line '$comnd $par' ignored"
                                   continue
                                   ;;
                   esac
           done
   } # }}}
   
 # Parse output from ifconfig: - tested on Linux and FreeBSD  # Parse output from ifconfig: - tested on Linux and FreeBSD
 # http://platon.sk/cvs/cvs.php/scripts/shell/firewall/ifconfig-parse.sh  # http://platon.sk/cvs/cvs.php/scripts/shell/firewall/ifconfig-parse.sh
 parse_ifconfig()  parse_ifconfig()
Riadok 1704  case "$1" in
Riadok 1785  case "$1" in
                 # start the some script twice to refresh rules (new blocked IP's)                  # start the some script twice to refresh rules (new blocked IP's)
                 QUIET=yes $0 start;                  QUIET=yes $0 start;
                 ;;                  ;;
           update)
                   update;
                   ;;
         deploy-block)          deploy-block)
                 shift;                  shift;
                 deploy_block $*;                  deploy_block $*;
                 ;;                  ;;
           deploy-update)
                   deploy_update;
                   ;;
           remote)
                   remote;
                   ;;
         *)          *)
                 echo "Usage: $0 {start|stop|really-off|status|purge|block|deploy-block}" >&2                  echo "Usage: $0 {start|stop|really-off|status|purge|block|deploy-block|deploy-update|update}" >&2
                 exit 1                  exit 1
                 ;;                  ;;
 esac  esac

Legend:
Odstranené z verzie2.86  
zmenené riadky
  Pridané vo verzii2.88

Platon Group <platon@platon.sk> http://platon.sk/
Copyright © 2002-2006 Platon Group
Stránka používa redakčný systém Metafox
Na začiatok