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.6 a 2.0

verzia 2.6, 2005/01/02 02:37:12 verzia 2.0, 2004/11/14 15:23:09
Riadok 9 
Riadok 9 
 # 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.5 2005/01/02 01:49:01 rajo Exp $  # $Platon: scripts/shell/firewall/fw-universal.sh,v 1.1 2003/10/24 15:40:44 rajo Exp $
 #  #
 # Changelog:  # Changelog:
 # 2004-11-14 - created  # 2004-11-14 - created
Riadok 116  antispoof_on()
Riadok 116  antispoof_on()
 # clear status of iptable chains  # clear status of iptable chains
 remove_chains()  remove_chains()
 { # {{{  { # {{{
           $IPTABLES -F # clear all chains
         for table in filter nat mangle; do          $IPTABLES -X # remove all chains
                 $IPTABLES -t $table -F # clear all chains  
                 $IPTABLES -t $table -X # remove all chains  
         done  
   
 } # }}}  } # }}}
   
 # all packets on loopback are accpted  # all packets on loopback are accpted
Riadok 200  syn_flood()
Riadok 196  syn_flood()
 anti_spoof_filter()  anti_spoof_filter()
 { # {{{  { # {{{
   
         #   http://www.iana.com/assignments/ipv4-address-space  #   http://www.iana.com/assignments/ipv4-address-space
   
         if [ ! -z "$ANTISPOOF_IFACE" ]; then          INET_IFACE=$1
   
                 echo -en "Turning on antispoof filter for interfaces: "          $IPTABLES -N spoof
                 $IPTABLES -N spoof  
   
                 # Ochrana proti Spoogingu zo spatnej slucky          echo "Turning on antispoof filter for interface $INET_IFACE "
                 $IPTABLES -A spoof -s 127.0.0.0/8 $LOG_LIMIT -j LOG --log-prefix "RESERVED:127.0.0.0/8 src"          # Ochrana proti Spoogingu zo spatnej slucky
                 $IPTABLES -A spoof -s 127.0.0.0/8 -j DROP          $IPTABLES -A spoof -i $INET_IFACE -s 127.0.0.0/8 $LOG_LIMIT -j LOG --log-prefix "Reserved IP:127.0.0.0/8 src"
                 $IPTABLES -A spoof -d 127.0.0.0/8 $LOG_LIMIT -j LOG --log-prefix "RESERVED:127.0.0.0/8 dest"          $IPTABLES -A spoof -i $INET_IFACE -s 127.0.0.0/8 -j DROP
                 $IPTABLES -A spoof -d 127.0.0.0/8 -j DROP          $IPTABLES -A spoof -i $INET_IFACE -d 127.0.0.0/8 $LOG_LIMIT -j LOG --log-prefix "Reserved IP:127.0.0.0/8 dest"
                 # Ochrana proti Spoofingu Internetu z adries urcenych pre lokalne siete          $IPTABLES -A spoof -i $INET_IFACE -d 127.0.0.0/8 -j DROP
                 $IPTABLES -A spoof -s 192.168.0.0/16 $LOG_LIMIT -j LOG --log-prefix "RESERVED:192.168.0.0/16 src"          # Ochrana proti Spoofingu Internetu z adries urcenych pre lokalne siete
                 $IPTABLES -A spoof -s 192.168.0.0/16 -j DROP            # RFC1918          $IPTABLES -A spoof -i $INET_IFACE -s 192.168.0.0/16 $LOG_LIMIT -j LOG --log-prefix "Reserved IP:192.168.0.0/16 src"
                 $IPTABLES -A spoof -s 172.16.0.0/12 $LOG_LIMIT -j LOG --log-prefix "RESERVED:172.16.0.0/12 src"          $IPTABLES -A spoof -i $INET_IFACE -s 192.168.0.0/16 -j DROP             # RFC1918
                 $IPTABLES -A spoof -s 172.16.0.0/12 -j DROP             # RFC1918          $IPTABLES -A spoof -i $INET_IFACE -s 172.16.0.0/12 $LOG_LIMIT -j LOG --log-prefix "Reserved IP:172.16.0.0/12 src"
                 $IPTABLES -A spoof -s 10.0.0.0/8  $LOG_LIMIT -j LOG --log-prefix "RESERVED:10.0.0.0/8 src"          $IPTABLES -A spoof -i $INET_IFACE -s 172.16.0.0/12 -j DROP              # RFC1918
                 $IPTABLES -A spoof -s 10.0.0.0/8 -j DROP  # RFC1918 len pre sietovy interface do Internetu, kedze 10.0.0.0 je adresa LAN          $IPTABLES -A spoof -i $INET_IFACE -s 10.0.0.0/8  $LOG_LIMIT -j LOG --log-prefix "Reserved IP:10.0.0.0/8 src"
                 $IPTABLES -A spoof -s 96.0.0.0/4 $LOG_LIMIT -j LOG --log-prefix "RESERVED:96.0.0.0/4 src"          $IPTABLES -A spoof -i $INET_IFACE -s 10.0.0.0/8 -j DROP  # RFC1918 len pre sietovy interface do Internetu, kedze 10.0.0.0 je adresa LAN
                 $IPTABLES -A spoof -s 96.0.0.0/4 -j DROP                        # IANA          $IPTABLES -A spoof -i $INET_IFACE -s 96.0.0.0/4 $LOG_LIMIT -j LOG --log-prefix "Reserved IP:96.0.0.0/4 src"
           $IPTABLES -A spoof -i $INET_IFACE -s 96.0.0.0/4 -j DROP                         # IANA
                 for iface in $ANTISPOOF_IFACE; do          echo " done."
                         echo -en " $iface"  
                         $IPTABLES -A FORWARD -i $iface -j spoof  
                         $IPTABLES -A INPUT   -i $iface -j spoof  
                 done  
                 echo " done."  
         fi  
 } # }}}  } # }}}
   
 mangle_prerouting()  mangle_prerouting()
Riadok 272  mangle_output()
Riadok 261  mangle_output()
   
 } # }}}  } # }}}
   
 # Masquerade local subnet  
 masquerade()  
 { # {{{  
         if [ ! -z "$NAT_LAN_IFACE" ]; then  
                 echo -en "Masquerading local subnet: $NAT_SUBNET_IFACE --> $NAT_LAN_IFACE"  
   
                 ip="IP_$NAT_SUBNET_IFACE";  
                 netmask="Mask_$NAT_SUBNET_IFACE"  
                 localnet="${!ip}/${!netmask}"  
   
                 lan_ip="IP_$NAT_LAN_IFACE"  
   
                 # alow packets from private subnet  
                 $IPTABLES -A FORWARD -s ! $localnet -i $NAT_SUBNET_IFACE -j DROP  
   
                 for redirect in $NAT_TCP_PORT_REDIRECT; do  
                         eval `echo $redirect | awk -v FS=: '{ printf "remote_port=%s; local_port=%s;", $1, $2; }'`  
                         echo -en " $remote_port:$local_port"  
                         $IPTABLES -t nat -A PREROUTING -p TCP \  
                                 -i ! $NAT_LAN_IFACE -d ! ${!lan_ip} \  
                                 --dport $remote_port -j REDIRECT --to-port $local_port  
                 done  
   
                 $IPTABLES -t nat -A POSTROUTING -s $localnet -o $NAT_LAN_IFACE -j MASQUERADE  
   
                 # don't forward Miscrosoft protocols - NOT RFC compliant packets  
                 if [ ! -z "$NAT_FORWARD_MICROSOFT" ]; then  
                         if [ "x$NAT_FORWARD_MICROSOFT" = "xno" ]; then  
                                 $IPTABLES -A FORWARD -p TCP ! --syn -m state --state NEW -j DROP  
   
                                 for port in 69 135 445 1434 6667; do  
                                         $IPTABLES -A FORWARD -p TCP --dport $port -j DROP  
                                         $IPTABLES -A FORWARD -p UDP --dport $port -j DROP  
                                 done  
                         fi  
                 fi  
   
                 if [ ! -z "$NAT_FORWARD_TCP_PORTS" ]; then  
                         echo -en "Accepting FORWARD TCP ports:"  
                         for port in $NAT_FORWARD_TCP_PORTS; do  
                                 echo -en " $port"  
                                 $IPTABLES -A FORWARD -p TCP --dport $port -m state --state NEW -j ACCEPT  
                         done  
                         echo " done."  
                 fi  
   
                 if [ ! -z "$NAT_FORWARD_UDP_PORTS" ]; then  
                         echo -en "Accepting FORWARD UDP ports:"  
                         for port in $NAT_FORWARD_UDP_PORTS; do  
                                 echo -en " $port"  
                                 $IPTABLES -A FORWARD -p UDP --dport $port -m state --state NEW -j ACCEPT  
                         done  
                         echo " done."  
                 fi  
   
                 # Keep state of connections from private subnets  
                 $IPTABLES -A OUTPUT  -m state --state NEW -o $NAT_LAN_IFACE -j ACCEPT  
                 #$IPTABLES -A FORWARD -m state --state NEW -o $NAT_LAN_IFACE -j ACCEPT  
                 $IPTABLES -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT  
   
                 echo " done."  
   
         fi  
 } # }}}  
   
 log_new_connections()  
 { # {{{  
         if [ ! -z "$NAT_LOG_NEW_CONNECTIONS" ]; then  
                 if [ "x$NAT_LOG_NEW_CONNECTIONS" = "xyes" ]; then  
                         echo -en "Logging new connections:"  
                         $IPTABLES -A INPUT   -m state --state NEW -j LOG --log-prefix "IN  connection: "  
                         $IPTABLES -A OUTPUT  -m state --state NEW -j LOG --log-prefix "OUT connection: "  
                         $IPTABLES -A FORWARD -m state --state NEW -j LOG --log-prefix "FWD connection: "  
                         echo " done."  
                 fi  
         fi  
 } # }}}  
   
 drop_output()  
 { # {{{  
   
         for iface in $INTERFACES; do  
                 ip="IP_$iface";  
                 drop_output_tcp="${iface}_DROP_OUTPUT_TCP"  
                 DROP_OUTPUT_TCP="${!drop_output_tcp}"  
                 drop_output_udp="${iface}_DROP_OUTPUT_UDP"  
                 DROP_OUTPUT_UDP="${!drop_output_udp}"  
   
                 if [ ! -z "$DROP_OUTPUT_TCP" ]; then  
                         echo -en "$iface: Dropping outgoing packets from ports:"  
                         for port in $DROP_OUTPUT_TCP; do  
                                 echo -en " $port"  
                                 $IPTABLES -A FORWARD -p TCP --sport $port -o $iface -j DROP  
                                 $IPTABLES -A OUTPUT  -p TCP --sport $port -o $iface -j DROP  
                         done  
                         echo " done."  
                 fi  
   
                 if [ ! -z "$DROP_OUTPUT_UDP" ]; then  
                         echo -en "$iface: Dropping outgoing packets from ports:"  
                         for port in $DROP_OUTPUT_UDP; do  
                                 echo -en " $port"  
                                 $IPTABLES -A FORWARD -p UDP --sport $port -o $iface -j DROP  
                                 $IPTABLES -A OUTPUT  -p UDP --sport $port -o $iface -j DROP  
                         done  
                         echo " done."  
                 fi  
         done  
   
 } # }}}  
   
 allow_input()  allow_input()
 { # {{{  { # {{{
   
         if [ ! -z "$IFACE_ACCEPT_ALL" ]; then  
                 echo -en "Accepting ALL packets on interfaces:"  
                 for iface in $IFACE_ACCEPT_ALL; do  
                         echo -en " $iface"  
                         $IPTABLES -A INPUT   -i $iface -j ACCEPT  
                         $IPTABLES -A FORWARD -i $iface -j ACCEPT  
                 done  
                 echo " done."  
         fi  
   
         if [ ! -z "$ALL_ACCEPT_INPUT_TCP" ]; then          if [ ! -z "$ALL_ACCEPT_INPUT_TCP" ]; then
                 echo -en "Accepting ALL INPUT TCP connections on ports:"                  echo -en "Accepting ALL INPUT TCP connections on ports:"
                 for port in $ALL_ACCEPT_INPUT_TCP; do                  for port in $ALL_ACCEPT_INPUT_TCP; do
Riadok 416  allow_input()
Riadok 283  allow_input()
                 ACCEPT_INPUT_UDP="${!accept_input_udp}"                  ACCEPT_INPUT_UDP="${!accept_input_udp}"
   
                 if [ ! -z "$ACCEPT_INPUT_TCP" ]; then                  if [ ! -z "$ACCEPT_INPUT_TCP" ]; then
                         echo -en "$iface: Accepting INPUT TCP connections on ports:"                          echo -en "$iface: Accepting INPUT TCP connections on ports: "
                         for port in $ACCEPT_INPUT_TCP; do                          for port in $ACCEPT_INPUT_TCP; do
                                 echo -en " $port"                                  echo -en " $port"
                                 $IPTABLES -A INPUT -i $iface -d ${!ip} -p TCP --dport $port -j ACCEPT                                  $IPTABLES -A INPUT -i $iface -d ${!ip} -p TCP --dport $port -j ACCEPT
Riadok 425  allow_input()
Riadok 292  allow_input()
                 fi                  fi
   
                 if [ ! -z "$ACCEPT_INPUT_UDP" ]; then                  if [ ! -z "$ACCEPT_INPUT_UDP" ]; then
                         echo -en "$iface: Accepting INPUT UDP connections on ports:"                          echo -en "$iface: Accepting INPUT UDP connections on ports: "
                         for port in $ACCEPT_INPUT_UDP; do                          for port in $ACCEPT_INPUT_UDP; do
                                 echo -en " $port"                                  echo -en " $port"
                                 #$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
Riadok 488  log_output_drop()
Riadok 355  log_output_drop()
   
         prefix="output drop: "          prefix="output drop: "
         echo "Output drop is logged with prefix '$prefix'"          echo "Output drop is logged with prefix '$prefix'"
           # Ostatní pakety logujeme (neměly by být žádné takové)
         $IPTABLES -A OUTPUT $LOG_LIMIT -j LOG --log-prefix "$prefix"          $IPTABLES -A OUTPUT $LOG_LIMIT -j LOG --log-prefix "$prefix"
   
 } # }}}  } # }}}
   
 log_forward_drop()  
 { # {{{  
   
         prefix="forward drop: "  
         echo "Forward drop is logged with prefix '$prefix'"  
         $IPTABLES -A FORWARD $LOG_LIMIT -j LOG --log-prefix "$prefix"  
   
 } # }}}  
   
 accept_related()  accept_related()
 { # {{{  { # {{{
   
Riadok 508  accept_related()
Riadok 367  accept_related()
         for iface in $INTERFACES; do          for iface in $INTERFACES; do
                 ip="IP_$iface";                  ip="IP_$iface";
                 echo -en " ${!ip}($iface)"                  echo -en " ${!ip}($iface)"
                 $IPTABLES -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT                  $IPTABLES -A INPUT -i $iface -d ${!ip} -m state --state ESTABLISHED,RELATED -j ACCEPT
         done          done
         echo " done."          echo " done."
   
Riadok 586  case "$1" in
Riadok 445  case "$1" in
                 # Inicialize modules                  # Inicialize modules
                 $DEPMOD -a                  $DEPMOD -a
                 load_modules                  load_modules
                 set_default_policy  
                 remove_chains                  remove_chains
                 #                  #
                 # (un)commnet next lines as needed                  # (un)commnet next lines as needed
                 #                  #
                   set_default_policy
                 set_loopback                  set_loopback
                 nmap_scan_filter                  nmap_scan_filter
                 invalid_packet_filter                  invalid_packet_filter
                 anti_spoof_filter                  #anti_spoof_filter eth0
                 syn_flood                  syn_flood
                 mangle_prerouting                  mangle_prerouting
                 mangle_output                  mangle_output
                 log_new_connections  
                 drop_output  
                 allow_input                  allow_input
                 allow_output                  allow_output
                 allow_icmp                  allow_icmp
                 accept_related                  accept_related
                 accept_loopback                  accept_loopback
                 masquerade  
                 log_input_drop                  log_input_drop
                 log_output_drop                  log_output_drop
                 log_forward_drop  
                 ;;                  ;;
   
         stop)          stop)
                 echo -n "Stopping $DESC: "                  echo -n "Stopping $DESC: "
                 set_default_policy  
                 remove_chains                  remove_chains
                   set_default_policy
                 unload_modules                  unload_modules
                 ;;                  ;;
   

Legend:
Odstranené z verzie2.6  
zmenené riadky
  Pridané vo verzii2.0

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