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

Rozdiely pre scripts/shell/firewall/fw-universal.sh medzi verziami 2.82 a 2.85

verzia 2.82, 2011/11/18 23:26:18 verzia 2.85, 2011/12/03 19:28:30
Riadok 1 
Riadok 1 
 #!/bin/bash  #!/bin/bash
   
 ### BEGIN INIT INFO  ### BEGIN INIT INFO
 # Provides:             firewall  # Provides:          firewall
 # Required-Start:       networking  # Required-Start:    $network
 # Required-Stop:  # Required-Stop:     $remote_fs
 # Default-Start:        S  # Default-Start:     S
 # Default-Stop:  # Default-Stop:      0 6
 # Short-Description:    firewalling rules  # Short-Description: Starts firewall
   # Description:       Handle universal firewall script by Platon Group
   #                    http://platon.sk/cvs/cvs.php/scripts/shell/firewall/
   # Author:            Lubomir Host <rajo@platon.sk>
   # Copyright:         (c) 2003-2011 Platon Group
 ### END INIT INFO  ### END INIT INFO
   
 #  #
Riadok 18 
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.81 2011-10-03 17:42:56 nepto Exp $  # $Platon: scripts/shell/firewall/fw-universal.sh,v 2.84 2011-11-18 23:58:33 rajo Exp $
 #  #
 # Changelog:  # Changelog:
 # 2003-10-24 - created  # 2003-10-24 - created
 # 2011-07-20 - implemented XEN_MODE  # 2011-07-20 - implemented XEN_MODE
 #  #
   
 ### BEGIN INIT INFO  
 # Provides:          firewall  
 # Required-Start:    $network $remote_fs  
 # Required-Stop:     $network $remote_fs  
 # Default-Start:     2 3 4 5  
 # Default-Stop:      0 1 6  
 # Short-Description: Starts firewall  
 # Description:       Handle universal firewall script by Platon Group  
 #                    http://platon.sk/cvs/cvs.php/scripts/shell/firewall/  
 # Author:            Lubomir Host <rajo@platon.sk>  
 # Copyright:         (c) 2003-2011 Platon Group  
 ### END INIT INFO  
   
 umask 077 # security  umask 077 # security
   
Riadok 771  drop_input()
Riadok 763  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 781  drop_input()
Riadok 780  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 791  drop_input()
Riadok 797  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 864  allow_input()
Riadok 884  allow_input()
                         fi                          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
Riadok 891  allow_input()
Riadok 911  allow_input()
                         fi                          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
Riadok 914  allow_input()
Riadok 934  allow_input()
                 for port in $REAL_ACCEPT_INPUT_TCP; do                  for port in $REAL_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; }'`
                         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 ,                          echo $port | grep -q ,
                         multiport="$?";                          multiport="$?";
                         if [ "$multiport" -eq 0 ]; then                          if [ "$multiport" -eq 0 ]; then
Riadok 935  allow_input()
Riadok 955  allow_input()
                 for port in $REAL_ACCEPT_INPUT_UDP; do                  for port in $REAL_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; }'`
                         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 ,                          echo $port | grep -q ,
                         multiport="$?";                          multiport="$?";
                         if [ "$multiport" -eq 0 ]; then                          if [ "$multiport" -eq 0 ]; then
Riadok 1005  allow_input()
Riadok 1025  allow_input()
                         for port in $REJECT_INPUT_TCP; do                          for port in $REJECT_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; }'`
                                 print_info -en " $port"`[ ! -z $src_ip ] && echo "[$src_ip]"`                                  print_info -en " $port"`[ ! -z "$src_ip" ] && echo "[$src_ip]"`
                                 echo $port | grep -q ,                                  echo $port | grep -q ,
                                 multiport="$?";                                  multiport="$?";
                                 if [ "$multiport" -eq 0 ]; then                                  if [ "$multiport" -eq 0 ]; then
Riadok 1014  allow_input()
Riadok 1034  allow_input()
                                         port_rule="--dport $port"                                          port_rule="--dport $port"
                                 fi                                  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 $port_rule -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 $port_rule -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
Riadok 1029  allow_input()
Riadok 1049  allow_input()
                         for port in $REJECT_INPUT_UDP; do                          for port in $REJECT_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; }'`
                                 print_info -en " $port"`[ ! -z $src_ip ] && echo "[$src_ip]"`                                  print_info -en " $port"`[ ! -z "$src_ip" ] && echo "[$src_ip]"`
                                 echo $port | grep -q ,                                  echo $port | grep -q ,
                                 multiport="$?";                                  multiport="$?";
                                 if [ "$multiport" -eq 0 ]; then                                  if [ "$multiport" -eq 0 ]; then
Riadok 1038  allow_input()
Riadok 1058  allow_input()
                                         port_rule="--dport $port"                                          port_rule="--dport $port"
                                 fi                                  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 $port_rule -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 $port_rule -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
Riadok 1058  allow_input()
Riadok 1078  allow_input()
                                 if [ -n "$src_ip" -a "$port" = "0" ]; then                                  if [ -n "$src_ip" -a "$port" = "0" ]; then
                                         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 ,                                  echo $port | grep -q ,
                                 multiport="$?";                                  multiport="$?";
                                 if [ "$multiport" -eq 0 ]; then                                  if [ "$multiport" -eq 0 ]; then
Riadok 1067  allow_input()
Riadok 1087  allow_input()
                                         port_rule="--dport $port"                                          port_rule="--dport $port"
                                 fi                                  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 $port_rule -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
Riadok 1096  allow_input()
Riadok 1116  allow_input()
                                 else                                  else
                                         port_rule="--dport $port"                                          port_rule="--dport $port"
                                 fi                                  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 $port_rule -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
Riadok 1339  shaping_on()
Riadok 1359  shaping_on()
 { # {{{  { # {{{
   
         mark_idx=1          mark_idx=1
         if [ ! -z $SHAPING_IFACE ]; then          if [ ! -z "$SHAPING_IFACE" ]; then
                 for iface in $SHAPING_IFACE; do                  for iface in $SHAPING_IFACE; do
                         echo "Shaping for interface $iface"                          echo "Shaping for interface $iface"
                         shaping_classes="${iface}_SHAPING_CLASSES"                          shaping_classes="${iface}_SHAPING_CLASSES"
Riadok 1353  shaping_on()
Riadok 1373  shaping_on()
                                 burst="${iface}_SHAPING_BURST_${class}"                                  burst="${iface}_SHAPING_BURST_${class}"
                                 netmask="${iface}_SHAPING_NETMASK_${class}"                                  netmask="${iface}_SHAPING_NETMASK_${class}"
                                 echo -e "\tshaping \"$class\" traffic: rate=${!rate} burst=${!burst} netmask=${!netmask}"                                  echo -e "\tshaping \"$class\" traffic: rate=${!rate} burst=${!burst} netmask=${!netmask}"
                                 if [ -z ${!netmask} ]; then                                  if [ -z "${!netmask}" ]; then
                                         $IPTABLES -t mangle -A OUTPUT -j MARK --set-mark 0x$mark_idx                                          $IPTABLES -t mangle -A OUTPUT -j MARK --set-mark 0x$mark_idx
                                 else                                  else
                                         $IPTABLES -t mangle -A OUTPUT -d ${!netmask} -j MARK --set-mark 0x$mark_idx                                          $IPTABLES -t mangle -A OUTPUT -d ${!netmask} -j MARK --set-mark 0x$mark_idx
                                 fi                                  fi
   
                                 if [ -z ${!rate} ]; then                                  if [ -z "${!rate}" ]; then
                                         # SFQ for local traffic                                          # SFQ for local traffic
                                         $TC qdisc add dev $iface parent 1:$mark_idx handle $((10 + $mark_idx)): sfq perturb 10                                          $TC qdisc add dev $iface parent 1:$mark_idx handle $((10 + $mark_idx)): sfq perturb 10
                                 else                                  else
Riadok 1377  shaping_on()
Riadok 1397  shaping_on()
   
 shaping_off()  shaping_off()
 { # {{{  { # {{{
         if [ ! -z $SHAPING_IFACE ]; then          if [ ! -z "$SHAPING_IFACE" ]; then
                 echo -en "Shaping turned off for interface"                  echo -en "Shaping turned off for interface"
                 for iface in $SHAPING_IFACE; do                  for iface in $SHAPING_IFACE; do
                         echo -en " $iface"                          echo -en " $iface"
Riadok 1389  shaping_off()
Riadok 1409  shaping_off()
   
 shaping_status()  shaping_status()
 { # {{{  { # {{{
         if [ ! -z $SHAPING_IFACE ]; then          if [ ! -z "$SHAPING_IFACE" ]; then
                 echo "# Shaping status: "                  echo "# Shaping status: "
                 $TC qdisc list                  $TC qdisc list
         else          else

Legend:
Odstranené z verzie2.82  
zmenené riadky
  Pridané vo verzii2.85

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