Platon Technologies
neprihlásený Prihlásiť Registrácia
SlovakEnglish
open source software development oslavujeme 10 rokov vývoja otvoreného softvéru! Štvrtok, 18. apríl 2024

Rozdiely pre scripts/shell/firewall/fw-universal.sh medzi verziami 2.79 a 2.84

verzia 2.79, 2011/07/20 19:05:12 verzia 2.84, 2011/11/18 23:58:33
Riadok 18 
Riadok 18 
 # 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.78 2011-07-14 13:13:22 nepto Exp $  # $Platon: scripts/shell/firewall/fw-universal.sh,v 2.83 2011-11-18 23:49:00 rajo Exp $
 #  #
 # Changelog:  # Changelog:
 # 2003-10-24 - created  # 2003-10-24 - created
Riadok 171  load_cache()
Riadok 171  load_cache()
   
         if [ ! -d "$DEFAULT_CACHE_DIR" ]; then          if [ ! -d "$DEFAULT_CACHE_DIR" ]; then
                 mkdir -p "$DEFAULT_CACHE_DIR";                  mkdir -p "$DEFAULT_CACHE_DIR";
                   if [ "$?" -ne "0" ]; then
                           print_info "ERROR: unable to create cache dir in load_cache()";
                           return;
                   fi
         fi          fi
   
         config=`cat $DEFAULT_FIREWALL_CONFIG $0 $DEFAULT_FIREWALL_CONFIG_DIR/deploy-servers.list $DEFAULT_FIREWALL_CONFIG_DIR/BANNED_IP.conf `; # config file and firewalling script          config="";
         md5key=`echo "config = '$config' parsed_interfaces ='$parsed_interfaces' parsed_routes='$parsed_routes'" | md5sum | $AWK '{ print $1; }'`;          if [ -r "$DEFAULT_FIREWALL_CONFIG" ]; then
                   config="$config ` cat \"$DEFAULT_FIREWALL_CONFIG\" `";
           fi
           if [ -r "$0" ]; then
                   config="$config ` cat \"$0\" `";
           fi
           if [ -r "$DEFAULT_FIREWALL_CONFIG_DIR/deploy-servers.list" ]; then
                   config="$config ` cat \"$DEFAULT_FIREWALL_CONFIG_DIR/deploy-servers.list\" `";
           fi
           if [ -r "$DEFAULT_FIREWALL_CONFIG_DIR/BANNED_IP.conf" ]; then
                   config="$config ` cat \"$DEFAULT_FIREWALL_CONFIG_DIR/BANNED_IP.conf\" `";
           fi
           md5key=`echo "config='$config' parsed_interfaces='$parsed_interfaces' parsed_routes='$parsed_routes'" | md5sum | $AWK '{print $1;}'`;
         CACHE_FILE="$DEFAULT_CACHE_DIR/$md5key"          CACHE_FILE="$DEFAULT_CACHE_DIR/$md5key"
   
         #echo "CACHE_FILE=$CACHE_FILE"          #echo "CACHE_FILE=$CACHE_FILE"
Riadok 755  drop_input()
Riadok 771  drop_input()
         if [ ! -z "$ALL_DROP_INPUT_TCP" ]; then          if [ ! -z "$ALL_DROP_INPUT_TCP" ]; then
                 print_info -en "Drop ALL INPUT TCP connections on ports:"                  print_info -en "Drop ALL INPUT TCP connections on ports:"
                 for port in $ALL_DROP_INPUT_TCP; do                  for port in $ALL_DROP_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 DROP                                  $IPTABLES -A INPUT -i $riface -p TCP $port_rule -j DROP
                         done                          done
                 done                  done
                 print_info " done."                  print_info " done."
Riadok 765  drop_input()
Riadok 788  drop_input()
         if [ ! -z "$ALL_DROP_INPUT_UDP" ]; then          if [ ! -z "$ALL_DROP_INPUT_UDP" ]; then
                 print_info -en "Drop ALL INPUT UDP connections on ports:"                  print_info -en "Drop ALL INPUT UDP connections on ports:"
                 for port in $ALL_DROP_INPUT_UDP; do                  for port in $ALL_DROP_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 DROP                                  $IPTABLES -A INPUT -i $riface -p UDP $port_rule -j DROP
                         done                          done
                 done                  done
                 print_info " done."                  print_info " done."
Riadok 775  drop_input()
Riadok 805  drop_input()
         if [ ! -z "$REAL_DROP_INPUT_TCP" ]; then          if [ ! -z "$REAL_DROP_INPUT_TCP" ]; then
                 print_info -en "Drop REAL all INPUT TCP connections for ALL interfaces on ports:"                  print_info -en "Drop REAL all INPUT TCP connections for ALL interfaces on ports:"
                 for port in $REAL_DROP_INPUT_TCP; do                  for port in $REAL_DROP_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 DROP                          $IPTABLES -A INPUT -p TCP $port_rule -j DROP
                 done                  done
                 print_info " done."                  print_info " done."
         fi          fi
         if [ ! -z "$REAL_DROP_INPUT_UDP" ]; then          if [ ! -z "$REAL_DROP_INPUT_UDP" ]; then
                 print_info -en "Drop REAL all INPUT UDP connections for ALL interfaces on ports:"                  print_info -en "Drop REAL all INPUT UDP connections for ALL interfaces on ports:"
                 for port in $REAL_DROP_INPUT_UDP; do                  for port in $REAL_DROP_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
                         print_info -en " $port(ALL)"                          print_info -en " $port(ALL)"
                         $IPTABLES -A INPUT -p UDP --dport $port -j DROP                          $IPTABLES -A INPUT -p UDP $port_rule -j DROP
                 done                  done
                 print_info " done."                  print_info " done."
         fi          fi
Riadok 839  allow_input()
Riadok 883  allow_input()
                 for port in $ALL_ACCEPT_INPUT_TCP; do                  for port in $ALL_ACCEPT_INPUT_TCP; do
                         src_ip=""                          src_ip=""
                         eval `echo $port | awk -v FS=: '/:/ { printf "src_ip=\"%s\"; port=\"%s\";", $1, $2; }'`                          eval `echo $port | awk -v FS=: '/:/ { printf "src_ip=\"%s\"; port=\"%s\";", $1, $2; }'`
                           echo $port | grep -q ,
                           multiport="$?";
                           if [ "$multiport" -eq 0 ]; then
                                   port_rule="--match multiport --dports $port"
                           else
                                   port_rule="--dport $port"
                           fi
                         for iface in $INTERFACES; do                          for iface in $INTERFACES; do
                                 riface="IFname_$iface";                                  riface="IFname_$iface";
                                 print_info -en " $port($iface)"`[ ! -z $src_ip ] && echo "[$src_ip]"`                                  print_info -en " $port($iface)"`[ ! -z $src_ip ] && echo "[$src_ip]"`
                                 IPS="IP_$iface";                                  IPS="IP_$iface";
                                 for ip in ${!IPS}; do                                  for ip in ${!IPS}; do
                                         if [ -z "$src_ip" ]; then                                          if [ -z "$src_ip" ]; then
                                                 $IPTABLES -A INPUT -i ${!riface} -d $ip -p TCP --dport $port -j ACCEPT                                                  $IPTABLES -A INPUT -i ${!riface} -d $ip -p TCP $port_rule -j ACCEPT
                                         else                                          else
                                                 $IPTABLES -A INPUT -i ${!riface} -s $src_ip -d $ip -p TCP --dport $port -j ACCEPT                                                  $IPTABLES -A INPUT -i ${!riface} -s $src_ip -d $ip -p TCP $port_rule -j ACCEPT
                                         fi                                          fi
                                 done                                  done
                         done                          done
Riadok 859  allow_input()
Riadok 910  allow_input()
                 for port in $ALL_ACCEPT_INPUT_UDP; do                  for port in $ALL_ACCEPT_INPUT_UDP; do
                         src_ip=""                          src_ip=""
                         eval `echo $port | awk -v FS=: '/:/ { printf "src_ip=\"%s\"; port=\"%s\";", $1, $2; }'`                          eval `echo $port | awk -v FS=: '/:/ { printf "src_ip=\"%s\"; port=\"%s\";", $1, $2; }'`
                           echo $port | grep -q ,
                           multiport="$?";
                           if [ "$multiport" -eq 0 ]; then
                                   port_rule="--match multiport --dports $port"
                           else
                                   port_rule="--dport $port"
                           fi
                         for iface in $INTERFACES; do                          for iface in $INTERFACES; do
                                 riface="IFname_$iface";                                  riface="IFname_$iface";
                                 print_info -en " $port($iface)"`[ ! -z $src_ip ] && echo "[$src_ip]"`                                  print_info -en " $port($iface)"`[ ! -z $src_ip ] && echo "[$src_ip]"`
                                 IPS="IP_$iface";                                  IPS="IP_$iface";
                                 if [ "$port" -eq 67 ]; then # DHCP requests doesn't have destination IP specified                                  if [ "x$port" = "x67" ]; then # DHCP requests doesn't have destination IP specified
                                         $IPTABLES -A INPUT -i ${!riface} -p UDP --dport $port -j ACCEPT                                          $IPTABLES -A INPUT -i ${!riface} -p UDP --dport $port -j ACCEPT
                                 else                                  else
                                         for ip in ${!IPS}; do                                          for ip in ${!IPS}; do
                                                 if [ -z "$src_ip" ]; then                                                  if [ -z "$src_ip" ]; then
                                                         $IPTABLES -A INPUT -i ${!riface} -d $ip -p UDP --dport $port -j ACCEPT                                                          $IPTABLES -A INPUT -i ${!riface} -d $ip -p UDP $port_rule -j ACCEPT
                                                 else                                                  else
                                                         $IPTABLES -A INPUT -i ${!riface} -s $src_ip -d $ip -p UDP --dport $port -j ACCEPT                                                          $IPTABLES -A INPUT -i ${!riface} -s $src_ip -d $ip -p UDP $port_rule -j ACCEPT
                                                 fi                                                  fi
                                         done                                          done
                                 fi                                  fi
Riadok 885  allow_input()
Riadok 943  allow_input()
                         src_ip=""                          src_ip=""
                         eval `echo $port | awk -v FS=: '/:/ { printf "src_ip=\"%s\"; port=\"%s\";", $1, $2; }'`                          eval `echo $port | awk -v FS=: '/:/ { printf "src_ip=\"%s\"; port=\"%s\";", $1, $2; }'`
                         print_info -en " $port(ALL)"`[ ! -z $src_ip ] && echo "[$src_ip]"`                          print_info -en " $port(ALL)"`[ ! -z $src_ip ] && echo "[$src_ip]"`
                           echo $port | grep -q ,
                           multiport="$?";
                           if [ "$multiport" -eq 0 ]; then
                                   port_rule="--match multiport --dports $port"
                           else
                                   port_rule="--dport $port"
                           fi
                         if [ -z "$src_ip" ]; then                          if [ -z "$src_ip" ]; then
                                 $IPTABLES -A INPUT -p TCP --dport $port -j ACCEPT                                  $IPTABLES -A INPUT -p TCP $port_rule -j ACCEPT
                         else                          else
                                 $IPTABLES -A INPUT -s $src_ip -p TCP --dport $port -j ACCEPT                                  $IPTABLES -A INPUT -s $src_ip -p TCP $port_rule -j ACCEPT
                         fi                          fi
                 done                  done
                 print_info " done."                  print_info " done."
Riadok 899  allow_input()
Riadok 964  allow_input()
                         src_ip=""                          src_ip=""
                         eval `echo $port | awk -v FS=: '/:/ { printf "src_ip=\"%s\"; port=\"%s\";", $1, $2; }'`                          eval `echo $port | awk -v FS=: '/:/ { printf "src_ip=\"%s\"; port=\"%s\";", $1, $2; }'`
                         print_info -en " $port(ALL)"`[ ! -z $src_ip ] && echo "[$src_ip]"`                          print_info -en " $port(ALL)"`[ ! -z $src_ip ] && echo "[$src_ip]"`
                           echo $port | grep -q ,
                           multiport="$?";
                           if [ "$multiport" -eq 0 ]; then
                                   port_rule="--match multiport --dports $port"
                           else
                                   port_rule="--dport $port"
                           fi
                         if [ -z "$src_ip" ]; then                          if [ -z "$src_ip" ]; then
                                 $IPTABLES -A INPUT -p UDP --dport $port -j ACCEPT                                  $IPTABLES -A INPUT -p UDP $port_rule -j ACCEPT
                         else                          else
                                 $IPTABLES -A INPUT -s $src_ip -p UDP --dport $port -j ACCEPT                                  $IPTABLES -A INPUT -s $src_ip -p UDP $port_rule -j ACCEPT
                         fi                          fi
                 done                  done
                 print_info " done."                  print_info " done."
Riadok 962  allow_input()
Riadok 1034  allow_input()
                                 src_ip=""                                  src_ip=""
                                 eval `echo $port | awk -v FS=: '/:/ { printf "src_ip=\"%s\"; port=\"%s\";", $1, $2; }'`                                  eval `echo $port | awk -v FS=: '/:/ { printf "src_ip=\"%s\"; port=\"%s\";", $1, $2; }'`
                                 print_info -en " $port"`[ ! -z $src_ip ] && echo "[$src_ip]"`                                  print_info -en " $port"`[ ! -z $src_ip ] && echo "[$src_ip]"`
                                   echo $port | grep -q ,
                                   multiport="$?";
                                   if [ "$multiport" -eq 0 ]; then
                                           port_rule="--match multiport --dports $port"
                                   else
                                           port_rule="--dport $port"
                                   fi
                                 for ip in ${!IPS}; do                                  for ip in ${!IPS}; do
                                         if [ -z $src_ip ]; then                                          if [ -z $src_ip ]; then
                                                 $IPTABLES -A INPUT -i ${!riface} -d $ip -p TCP --dport $port -j REJECT --reject-with $REJECT_WITH                                                  $IPTABLES -A INPUT -i ${!riface} -d $ip -p TCP $port_rule -j REJECT --reject-with $REJECT_WITH
                                         else                                          else
                                                 $IPTABLES -A INPUT -i ${!riface} -s $src_ip -d $ip -p TCP --dport $port -j REJECT --reject-with $REJECT_WITH                                                  $IPTABLES -A INPUT -i ${!riface} -s $src_ip -d $ip -p TCP $port_rule -j REJECT --reject-with $REJECT_WITH
                                         fi                                          fi
                                 done                                  done
                         done                          done
Riadok 979  allow_input()
Riadok 1058  allow_input()
                                 src_ip=""                                  src_ip=""
                                 eval `echo $port | awk -v FS=: '/:/ { printf "src_ip=\"%s\"; port=\"%s\";", $1, $2; }'`                                  eval `echo $port | awk -v FS=: '/:/ { printf "src_ip=\"%s\"; port=\"%s\";", $1, $2; }'`
                                 print_info -en " $port"`[ ! -z $src_ip ] && echo "[$src_ip]"`                                  print_info -en " $port"`[ ! -z $src_ip ] && echo "[$src_ip]"`
                                   echo $port | grep -q ,
                                   multiport="$?";
                                   if [ "$multiport" -eq 0 ]; then
                                           port_rule="--match multiport --dports $port"
                                   else
                                           port_rule="--dport $port"
                                   fi
                                 for ip in ${!IPS}; do                                  for ip in ${!IPS}; do
                                         if [ -z $src_ip ]; then                                          if [ -z $src_ip ]; then
                                                 $IPTABLES -A INPUT -i ${!riface} -d $ip -p UDP --dport $port -j REJECT --reject-with $REJECT_WITH                                                  $IPTABLES -A INPUT -i ${!riface} -d $ip -p UDP $port_rule -j REJECT --reject-with $REJECT_WITH
                                         else                                          else
                                                 $IPTABLES -A INPUT -i ${!riface} -s $src_ip -d $ip -p UDP --dport $port -j REJECT --reject-with $REJECT_WITH                                                  $IPTABLES -A INPUT -i ${!riface} -s $src_ip -d $ip -p UDP $port_rule -j REJECT --reject-with $REJECT_WITH
                                         fi                                          fi
                                 done                                  done
                         done                          done
Riadok 1001  allow_input()
Riadok 1087  allow_input()
                                         port="ALL";                                          port="ALL";
                                 fi                                  fi
                                 print_info -en " $port"`[ ! -z $src_ip ] && echo "[$src_ip]"`                                  print_info -en " $port"`[ ! -z $src_ip ] && echo "[$src_ip]"`
                                   echo $port | grep -q ,
                                   multiport="$?";
                                   if [ "$multiport" -eq 0 ]; then
                                           port_rule="--match multiport --dports $port"
                                   else
                                           port_rule="--dport $port"
                                   fi
                                 for ip in ${!IPS}; do                                  for ip in ${!IPS}; do
                                         if [ -z $src_ip ]; then                                          if [ -z $src_ip ]; then
                                                 $IPTABLES -A INPUT -i ${!riface} -d $ip -p TCP --dport $port -j ACCEPT                                                  $IPTABLES -A INPUT -i ${!riface} -d $ip -p TCP $port_rule -j ACCEPT
                                         else                                          else
                                                 if [ "$port" = "ALL" ]; then                                                  if [ "$port" = "ALL" ]; then
                                                         $IPTABLES -A INPUT -i ${!riface} -s $src_ip -d $ip -p TCP -j ACCEPT                                                          $IPTABLES -A INPUT -i ${!riface} -s $src_ip -d $ip -p TCP -j ACCEPT
                                                 else                                                  else
                                                         $IPTABLES -A INPUT -i ${!riface} -s $src_ip -d $ip -p TCP --dport $port -j ACCEPT                                                          $IPTABLES -A INPUT -i ${!riface} -s $src_ip -d $ip -p TCP $port_rule -j ACCEPT
                                                 fi                                                  fi
                                         fi                                          fi
                                 done                                  done
Riadok 1024  allow_input()
Riadok 1117  allow_input()
                                 if [ -n "$src_ip" -a "$port" = "0" ]; then                                  if [ -n "$src_ip" -a "$port" = "0" ]; then
                                         port="ALL";                                          port="ALL";
                                 fi                                  fi
                                   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"`[ ! -z $src_ip ] && echo "[$src_ip]"`                                  print_info -en " $port"`[ ! -z $src_ip ] && echo "[$src_ip]"`
                                 #$IPTABLES -A INPUT -i $iface -d ${!INET_IP} -p UDP --dport $port -j ACCEPT                                  #$IPTABLES -A INPUT -i $iface -d ${!INET_IP} -p UDP --dport $port -j ACCEPT
                                 #$IPTABLES -A INPUT -i $iface --source 192.168.1.0/16 -p UDP --dport $port -j ACCEPT                                  #$IPTABLES -A INPUT -i $iface --source 192.168.1.0/16 -p UDP --dport $port -j ACCEPT
                                 if [ "$port" -eq 67 ]; then # DHCP requests doesn't have destination IP specified                                  if [ "x$port" = "x67" ]; then # DHCP requests doesn't have destination IP specified
                                         $IPTABLES -A INPUT -i ${!riface} -p UDP --dport $port -j ACCEPT                                          $IPTABLES -A INPUT -i ${!riface} -p UDP --dport $port -j ACCEPT
                                 else                                  else
                                         for ip in ${!IPS}; do                                          for ip in ${!IPS}; do
                                                 if [ -z $src_ip ]; then                                                  if [ -z $src_ip ]; then
                                                         $IPTABLES -A INPUT -i ${!riface} -d $ip -p UDP --dport $port -j ACCEPT                                                          $IPTABLES -A INPUT -i ${!riface} -d $ip -p UDP $port_rule -j ACCEPT
                                                 else                                                  else
                                                         if [ "$port" = "ALL" ]; then                                                          if [ "$port" = "ALL" ]; then
                                                                 $IPTABLES -A INPUT -i ${!riface} -s $src_ip -d $ip -p UDP -j ACCEPT                                                                  $IPTABLES -A INPUT -i ${!riface} -s $src_ip -d $ip -p UDP -j ACCEPT
                                                         else                                                          else
                                                                 $IPTABLES -A INPUT -i ${!riface} -s $src_ip -d $ip -p UDP --dport $port -j ACCEPT                                                                  $IPTABLES -A INPUT -i ${!riface} -s $src_ip -d $ip -p UDP $port_rule -j ACCEPT
                                                         fi                                                          fi
                                                 fi                                                  fi
                                         done                                          done

Legend:
Odstranené z verzie2.79  
zmenené riadky
  Pridané vo verzii2.84

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