da salbutamolo » ven apr 29, 2005 9:24
Ciao gente
<BR>avevo risposto anche prima ma il mio messaggio si è perso nell´etere....BTW chiedo scisa nel qual caso dovesse arrivare doppio. Dicevo..grazie a tutti per la consulenza siete troooppo i migliori! :-] Ho apportato le modifiche da voi suggerite allo script e questo è il risultato:
<BR>
<BR><!-- BBCode Quote Start --><TABLE BORDER=0 ALIGN=CENTER WIDTH=85%><TR><TD><font size=-1>Quote:</font><HR></TD></TR><TR><TD><FONT SIZE=-1><BLOCKQUOTE> #!/bin/bash
<BR>
<BR>modprobe ip_conntrack_ftp
<BR>
<BR>CONNECTION_TRACKING="1"
<BR>ACCEPT_AUTH="0"
<BR>SSH_SERVER="0"
<BR>FTP_SERVER="0"
<BR>WEB_SERVER="0"
<BR>SSL_SERVER="0"
<BR>DHCP_CLIENT="0"
<BR>
<BR>INTERNET="eth0" # Internet-connected interface
<BR>LOOPBACK_INTERFACE="lo" # however your system names it
<BR>IPADDR="192.168.1.2" # your IP address
<BR>#SUBNET_BASE="" # ISP network segment base address
<BR>#SUBNET_BROADCAST="" # network segment broadcast address
<BR>#MY_ISP="" # ISP server & NOC address range
<BR>
<BR>NAMESERVER="212.216.112.112" # address of a remote name server
<BR>POP_SERVER="any/0" # address of a remote pop server
<BR>MAIL_SERVER="out.aliceposta.it" # address of a remote mail gateway
<BR>NEWS_SERVER="195.31.190.131" # address of a remote news server
<BR>TIME_SERVER="66.206.11.192" # address of a remote time server
<BR>DHCP_SERVER="any/0" # address of your ISP dhcp server
<BR>
<BR>LOOPBACK="127.0.0.0/8" # reserved loopback address range
<BR>CLASS_A="10.0.0.0/8" # class A private networks
<BR>CLASS_B="172.16.0.0/12" # class B private networks
<BR>CLASS_C="192.168.0.0/16" # class C private networks
<BR>CLASS_D_MULTICAST="224.0.0.0/4" # class D multicast addresses
<BR>CLASS_E_RESERVED_NET="240.0.0.0/5" # class E reserved addresses
<BR>BROADCAST_SRC="0.0.0.0" # broadcast source address
<BR>BROADCAST_DEST="255.255.255.255" # broadcast destination address
<BR>
<BR>PRIVPORTS="0:1023" # well-known, privileged port range
<BR>UNPRIVPORTS="1024:65535" # unprivileged port range
<BR>
<BR>SSH_PORTS="1024:65535"
<BR>
<BR>NFS_PORT="2049"
<BR>LOCKD_PORT="4045"
<BR>SOCKS_PORT="1080"
<BR>OPENWINDOWS_PORT="2000"
<BR>XWINDOW_PORTS="6000:6063"
<BR>SQUID_PORT="3128"
<BR>
<BR>###############################################################
<BR>
<BR># WARNING:
<BR>
<BR># The following section is written for dhclient.
<BR># This section demonstrates what needs to be done
<BR># to dynamically modify the IP address and name servers.
<BR>
<BR># See the "dhclient-script" man page
<BR># and the "dhclient.conf" man page for details.
<BR>
<BR>if [ x$reason = xBOUND ] || [ x$reason = xRENEW ] || [ x$reason = xREBIND ]; then
<BR>
<BR> IPADDR=$new_ip_address
<BR>
<BR> # Some ISPs use more than one DHCP server.
<BR> # In that case, you can leave DHCP_SERVER set to any/0,
<BR> # or you can hard-code duplicate DHCP rules that
<BR> # reference the specific server IP addresses.
<BR>
<BR> DHCP_SERVER=$new_dhcp_server_identifier
<BR>
<BR>elif [ x$reason = xPREINIT ] || \
<BR> [ x$reason = xEXPIRE ] || [ x$reason = xFAIL ] || [ x$reason = xTIMEOUT ]; then
<BR>
<BR> IPADDR="any/0"
<BR> DHCP_SERVER="any/0"
<BR>
<BR>fi
<BR>
<BR>###############################################################
<BR>
<BR># Enable broadcast echo Protection
<BR>echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts
<BR>
<BR># Disable Source Routed Packets
<BR>for f in /proc/sys/net/ipv4/conf/*/accept_source_route; do
<BR> echo 0 > $f
<BR>done
<BR>
<BR># Enable TCP SYN Cookie Protection
<BR>echo 1 > /proc/sys/net/ipv4/tcp_syncookies
<BR>
<BR># Disable ICMP Redirect Acceptance
<BR>for f in /proc/sys/net/ipv4/conf/*/accept_redirects; do
<BR> echo 0 > $f
<BR>done
<BR>
<BR># Don¹t send Redirect Messages
<BR>for f in /proc/sys/net/ipv4/conf/*/send_redirects; do
<BR> echo 0 > $f
<BR>done
<BR>
<BR># Drop Spoofed Packets coming in on an interface, which if replied to,
<BR># would result in the reply going out a different interface.
<BR>for f in /proc/sys/net/ipv4/conf/*/rp_filter; do
<BR> echo 1 > $f
<BR>done
<BR>
<BR># Log packets with impossible addresses.
<BR>for f in /proc/sys/net/ipv4/conf/*/log_martians; do
<BR> echo 1 > $f
<BR>done
<BR>
<BR>###############################################################
<BR>
<BR># Remove any existing rules from all chains
<BR>iptables --flush
<BR>iptables -t nat --flush
<BR>iptables -t mangle --flush
<BR>
<BR># Unlimited traffic on the loopback interface
<BR>iptables -A INPUT -i lo -j ACCEPT
<BR>iptables -A OUTPUT -o lo -j ACCEPT
<BR>
<BR># Set the default policy to drop
<BR>iptables --policy INPUT DROP
<BR>iptables --policy OUTPUT DROP
<BR>iptables --policy FORWARD DROP
<BR>
<BR># A bug that showed up as of the Red Hat 7.2 release results
<BR># in the following 5 default policies breaking the firewall
<BR># initialization:
<BR>
<BR># iptables -t nat --policy PREROUTING DROP
<BR># iptables -t nat --policy OUTPUT DROP
<BR># iptables -t nat --policy POSTROUTING DROP
<BR>
<BR># iptables -t mangle --policy PREROUTING DROP
<BR># iptables -t mangle --policy OUTPUT DROP
<BR>
<BR># Remove any pre-existing user-defined chains
<BR>iptables --delete-chain
<BR>iptables -t nat --delete-chain
<BR>iptables -t mangle --delete-chain
<BR>
<BR>###############################################################
<BR># Stealth Scans and TCP State Flags
<BR>
<BR># All of the bits are cleared
<BR>iptables -A INPUT -p tcp --tcp-flags ALL NONE -j DROP
<BR>
<BR># SYN and FIN are both set
<BR>iptables -A INPUT -p tcp --tcp-flags SYN,FIN SYN,FIN -j DROP
<BR>
<BR># SYN and RST are both set
<BR>iptables -A INPUT -p tcp --tcp-flags SYN,RST SYN,RST -j DROP
<BR>
<BR># FIN and RST are both set
<BR>iptables -A INPUT -p tcp --tcp-flags FIN,RST FIN,RST -j DROP
<BR>
<BR># FIN is the only bit set, without the expected accompanying ACK
<BR>iptables -A INPUT -p tcp --tcp-flags ACK,FIN FIN -j DROP
<BR>
<BR># PSH is the only bit set, without the expected accompanying ACK
<BR>iptables -A INPUT -p tcp --tcp-flags ACK,PSH PSH -j DROP
<BR>
<BR># URG is the only bit set, without the expected accompanying ACK
<BR>iptables -A INPUT -p tcp --tcp-flags ACK,URG URG -j DROP
<BR>
<BR>###############################################################
<BR># Using Connection State to By-pass Rule Checking
<BR>
<BR>if [ "$CONNECTION_TRACKING" = "1" ]; then
<BR> iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
<BR> iptables -A OUTPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
<BR>
<BR> # Using the state module alone, INVALID will break protocols that use
<BR> # bi-directional connections or multiple connections or exchanges,
<BR> # unless an ALG is provided for the protocol. At this time, FTP and is
<BR> # IRC are the only protocols with ALG support.
<BR>
<BR> iptables -A INPUT -m state --state INVALID -j LOG \
<BR> --log-prefix "INVALID input: "
<BR> iptables -A INPUT -m state --state INVALID -j DROP
<BR>
<BR> iptables -A OUTPUT -m state --state INVALID -j LOG \
<BR> --log-prefix "INVALID ouput: "
<BR> iptables -A OUTPUT -m state --state INVALID -j DROP
<BR>fi
<BR>
<BR>###############################################################
<BR># Source Address Spoofing and Other Bad Addresses
<BR>
<BR># Refuse spoofed packets pretending to be from
<BR># the external interface´s IP address
<BR>iptables -A INPUT -i $INTERNET -s $IPADDR -j DROP
<BR>
<BR># Refuse packets claiming to be from a Class A private network
<BR>iptables -A INPUT -i $INTERNET -s $CLASS_A -j DROP
<BR>
<BR># Refuse packets claiming to be from a Class B private network
<BR>iptables -A INPUT -i $INTERNET -s $CLASS_B -j DROP
<BR>
<BR># Refuse packets claiming to be from a Class C private network
<BR>iptables -A INPUT -i $INTERNET -s $CLASS_C -j DROP
<BR>
<BR># Refuse packets claiming to be from the loopback interface
<BR>iptables -A INPUT -i $INTERNET -s $LOOPBACK -j DROP
<BR>
<BR># Refuse malformed broadcast packets
<BR>iptables -A INPUT -i $INTERNET -s $BROADCAST_DEST -j LOG
<BR>iptables -A INPUT -i $INTERNET -s $BROADCAST_DEST -j DROP
<BR>
<BR>iptables -A INPUT -i $INTERNET -d $BROADCAST_SRC -j LOG
<BR>iptables -A INPUT -i $INTERNET -d $BROADCAST_SRC -j DROP
<BR>
<BR>#if [ "$DHCP_CLIENT" = "0" ]; then
<BR> # Refuse directed broadcasts
<BR> # Used to map networks and in Denial of Service attacks
<BR> # iptables -A INPUT -i $INTERNET -d $SUBNET_BASE -j DROP
<BR> #iptables -A INPUT -i $INTERNET -d $SUBNET_BROADCAST -j DROP
<BR>
<BR> # Refuse limited broadcasts
<BR> iptables -A INPUT -i $INTERNET -d $BROADCAST_DEST -j DROP
<BR>#fi
<BR>
<BR># Refuse Class D multicast addresses
<BR># illegal as a source address
<BR>iptables -A INPUT -i $INTERNET -s $CLASS_D_MULTICAST -j DROP
<BR>
<BR>iptables -A INPUT -i $INTERNET -p ! udp -d $CLASS_D_MULTICAST -j DROP
<BR>
<BR>iptables -A INPUT -i $INTERNET -p udp -d $CLASS_D_MULTICAST -j ACCEPT
<BR>
<BR># Refuse Class E reserved IP addresses
<BR>iptables -A INPUT -i $INTERNET -s $CLASS_E_RESERVED_NET -j DROP
<BR>
<BR># refuse addresses defined as reserved by the IANA
<BR># 0.*.*.* - Can¹t be blocked unilaterally with DHCP
<BR># 169.254.0.0/16 - Link Local Networks
<BR># 192.0.2.0/24 - TEST-NET
<BR>
<BR>if [ "$DHCP_CLIENT" = "1" ]; then
<BR> iptables -A INPUT -i $INTERNET -p udp \
<BR> -s $BROADCAST_SRC --sport 67 \
<BR> -d $BROADCAST_DEST --dport 68 -j ACCEPT
<BR>fi
<BR>
<BR>iptables -A INPUT -i $INTERNET -s 0.0.0.0/8 -j DROP
<BR>iptables -A INPUT -i $INTERNET -s 169.254.0.0/16 -j DROP
<BR>iptables -A INPUT -i $INTERNET -s 192.0.2.0/24 -j DROP
<BR>
<BR>###############################################################
<BR># Disallowing Connections to Common TCP Unprivileged Server Ports
<BR>
<BR># X Window connection establishment
<BR>iptables -A OUTPUT -o $INTERNET -p tcp --syn \
<BR> --destination-port $XWINDOW_PORTS -j REJECT
<BR>
<BR># X Window: incoming connection attempt
<BR>iptables -A INPUT -i $INTERNET -p tcp --syn \
<BR> --destination-port $XWINDOW_PORTS -j DROP
<BR>
<BR># Establishing a connection over TCP to NFS, OpenWindows, SOCKS or squid
<BR>iptables -A OUTPUT -o $INTERNET -p tcp \
<BR> -m multiport --destination-port \
<BR> $NFS_PORT,$OPENWINDOWS_PORT,$SOCKS_PORT,$SQUID_PORT \
<BR> --syn -j REJECT
<BR>
<BR>iptables -A INPUT -i $INTERNET -p tcp \
<BR> -m multiport --destination-port \
<BR> $NFS_PORT,$OPENWINDOWS_PORT,$SOCKS_PORT,$SQUID_PORT \
<BR> --syn -j DROP
<BR>
<BR>###############################################################
<BR># Disallowing Connections to Common UDP Unprivileged Server Ports
<BR>
<BR># NFS and lockd
<BR>if [ "$CONNECTION_TRACKING" = "1" ]; then
<BR> iptables -A OUTPUT -o $INTERNET -p udp \
<BR> -m multiport --destination-port $NFS_PORT,$LOCKD_PORT \
<BR> -m state --state NEW -j REJECT
<BR>
<BR> iptables -A INPUT -i $INTERNET -p udp \
<BR> -m multiport --destination-port $NFS_PORT,$LOCKD_PORT \
<BR> -m state --state NEW -j DROP
<BR>else
<BR> iptables -A OUTPUT -o $INTERNET -p udp \
<BR> -m multiport --destination-port $NFS_PORT,$LOCKD_PORT \
<BR> -j REJECT
<BR>
<BR> iptables -A INPUT -i $INTERNET -p udp \
<BR> -m multiport --destination-port $NFS_PORT,$LOCKD_PORT \
<BR> -j DROP
<BR>fi
<BR>
<BR>###############################################################
<BR># DNS Name Server
<BR>
<BR># DNS Fowarding Name Server or client requests
<BR>
<BR>if [ "$CONNECTION_TRACKING" = "1" ]; then
<BR> iptables -A OUTPUT -o $INTERNET -p udp \
<BR> -s $IPADDR --sport $UNPRIVPORTS \
<BR> -d $NAMESERVER --dport 53 \
<BR> -m state --state NEW -j ACCEPT
<BR>fi
<BR>
<BR>iptables -A OUTPUT -o $INTERNET -p udp \
<BR> -s $IPADDR --sport $UNPRIVPORTS \
<BR> -d $NAMESERVER --dport 53 -j ACCEPT
<BR>
<BR>iptables -A INPUT -i $INTERNET -p udp \
<BR> -s $NAMESERVER --sport 53 \
<BR> -d $IPADDR --dport $UNPRIVPORTS -j ACCEPT
<BR>
<BR>#...............................................................
<BR># TCP is used for large responses
<BR>
<BR>if [ "$CONNECTION_TRACKING" = "1" ]; then
<BR> iptables -A OUTPUT -o $INTERNET -p tcp \
<BR> -s $IPADDR --sport $UNPRIVPORTS \
<BR> -d $NAMESERVER --dport 53 \
<BR> -m state --state NEW -j ACCEPT
<BR>fi
<BR>
<BR>iptables -A OUTPUT -o $INTERNET -p tcp \
<BR> -s $IPADDR --sport $UNPRIVPORTS \
<BR> -d $NAMESERVER --dport 53 -j ACCEPT
<BR>
<BR>iptables -A INPUT -i $INTERNET -p tcp ! --syn \
<BR> -s $NAMESERVER --sport 53 \
<BR> -d $IPADDR --dport $UNPRIVPORTS -j ACCEPT
<BR>
<BR>#...............................................................
<BR># DNS Caching Name Server (local server to primary server)
<BR>
<BR>if [ "$CONNECTION_TRACKING" = "1" ]; then
<BR> iptables -A OUTPUT -o $INTERNET -p udp \
<BR> -s $IPADDR --sport 53 \
<BR> -d $NAMESERVER --dport 53 \
<BR> -m state --state NEW -j ACCEPT
<BR>fi
<BR>
<BR>iptables -A OUTPUT -o $INTERNET -p udp \
<BR> -s $IPADDR --sport 53 \
<BR> -d $NAMESERVER --dport 53 -j ACCEPT
<BR>
<BR>iptables -A INPUT -i $INTERNET -p udp \
<BR> -s $NAMESERVER --sport 53 \
<BR> -d $IPADDR --dport 53 -j ACCEPT
<BR>
<BR>###############################################################
<BR># Filtering the AUTH User Identification Service (TCP Port 113)
<BR>
<BR># Outgoing Local Client Requests to Remote Servers
<BR>
<BR>if [ "$CONNECTION_TRACKING" = "1" ]; then
<BR> iptables -A OUTPUT -o $INTERNET -p tcp \
<BR> -s $IPADDR --sport $UNPRIVPORTS \
<BR> --dport 113 -m state --state NEW -j ACCEPT
<BR>fi
<BR>
<BR>iptables -A OUTPUT -o $INTERNET -p tcp \
<BR> -s $IPADDR --sport $UNPRIVPORTS \
<BR> --dport 113 -j ACCEPT
<BR>
<BR>iptables -A INPUT -i $INTERNET -p tcp ! --syn \
<BR> --sport 113 \
<BR> -d $IPADDR --dport $UNPRIVPORTS -j ACCEPT
<BR>
<BR>#...............................................................
<BR># Incoming Remote Client Requests to Local Servers
<BR>
<BR>if [ "$CONNECTION_TRACKING" = "1" ]; then
<BR> iptables -A INPUT -i $INTERNET -p tcp \
<BR> --sport $UNPRIVPORTS \
<BR> -d $IPADDR --dport 113 \
<BR> -m state --state NEW -j ACCEPT
<BR>fi
<BR>
<BR>if [ "$ACCEPT_AUTH" = "1" ]; then
<BR> if [ "$CONNECTION_TRACKING" = "1" ]; then
<BR> iptables -A INPUT -i $INTERNET -p tcp \
<BR> --sport $UNPRIVPORTS \
<BR> -d $IPADDR --dport 113 \
<BR> -m state --state NEW -j ACCEPT
<BR> fi
<BR>
<BR> iptables -A INPUT -i $INTERNET -p tcp \
<BR> --sport $UNPRIVPORTS \
<BR> -d $IPADDR --dport 113 -j ACCEPT
<BR>
<BR> iptables -A OUTPUT -o $INTERNET -p tcp ! --syn \
<BR> -s $IPADDR --sport 113 \
<BR> --dport $UNPRIVPORTS -j ACCEPT
<BR>else
<BR> iptables -A INPUT -i $INTERNET -p tcp \
<BR> --sport $UNPRIVPORTS \
<BR> -d $IPADDR --dport 113 -j REJECT --reject-with tcp-reset
<BR>fi
<BR>
<BR>###############################################################
<BR># Sending Mail to Any External Mail Server
<BR># Use "-d $MAIL_SERVER" if an ISP mail gateway is used instead
<BR>
<BR>if [ "$CONNECTION_TRACKING" = "1" ]; then
<BR> iptables -A OUTPUT -o $INTERNET -p tcp \
<BR> -s $IPADDR --sport $UNPRIVPORTS \
<BR> --dport 25 -m state --state NEW -j ACCEPT
<BR>fi
<BR>
<BR>iptables -A OUTPUT -o $INTERNET -p tcp \
<BR> -s $IPADDR --sport $UNPRIVPORTS \
<BR> --dport 25 -j ACCEPT
<BR>
<BR>iptables -A INPUT -i $INTERNET -p tcp ! --syn \
<BR> --sport 25 \
<BR> -d $IPADDR --dport $UNPRIVPORTS -j ACCEPT
<BR>
<BR>###############################################################
<BR># Retrieving Mail as a POP Client (TCP Port 110)
<BR>
<BR>if [ "$CONNECTION_TRACKING" = "1" ]; then
<BR> iptables -A OUTPUT -o $INTERNET -p tcp \
<BR> -s $IPADDR --sport $UNPRIVPORTS \
<BR> -d $POP_SERVER --dport 110 -m state --state NEW -j ACCEPT
<BR>fi
<BR>
<BR>iptables -A OUTPUT -o $INTERNET -p tcp \
<BR> -s $IPADDR --sport $UNPRIVPORTS \
<BR> -d $POP_SERVER --dport 110 -j ACCEPT
<BR>
<BR>iptables -A INPUT -i $INTERNET -p tcp ! --syn \
<BR> -s $POP_SERVER --sport 110 \
<BR> -d $IPADDR --dport $UNPRIVPORTS -j ACCEPT
<BR>
<BR>###############################################################
<BR># Accessing Usenet News Services (TCP NNTP Port 119)
<BR>
<BR>if [ "$CONNECTION_TRACKING" = "1" ]; then
<BR> iptables -A OUTPUT -o $INTERNET -p tcp \
<BR> -s $IPADDR --sport $UNPRIVPORTS \
<BR> -d $NEWS_SERVER --dport 119 -m state --state NEW -j ACCEPT
<BR>fi
<BR>
<BR>iptables -A OUTPUT -o $INTERNET -p tcp \
<BR> -s $IPADDR --sport $UNPRIVPORTS \
<BR> -d $NEWS_SERVER --dport 119 -j ACCEPT
<BR>
<BR>iptables -A INPUT -i $INTERNET -p tcp ! --syn \
<BR> -s $NEWS_SERVER --sport 119 \
<BR> -d $IPADDR --dport $UNPRIVPORTS -j ACCEPT
<BR>
<BR>###############################################################
<BR># ssh (TCP Port 22)
<BR>
<BR># Outgoing Local Client Requests to Remote Servers
<BR>
<BR>if [ "$CONNECTION_TRACKING" = "1" ]; then
<BR> iptables -A OUTPUT -o $INTERNET -p tcp \
<BR> -s $IPADDR --sport $SSH_PORTS \
<BR> --dport 22 -m state --state NEW -j ACCEPT
<BR>fi
<BR>
<BR>iptables -A OUTPUT -o $INTERNET -p tcp \
<BR> -s $IPADDR --sport $SSH_PORTS \
<BR> --dport 22 -j ACCEPT
<BR>
<BR>iptables -A INPUT -i $INTERNET -p tcp ! --syn \
<BR> --source-port 22 \
<BR> -d $IPADDR --dport $SSH_PORTS -j ACCEPT
<BR>
<BR>#...............................................................
<BR># Incoming Remote Client Requests to Local Servers
<BR>
<BR>if [ "$SSH_SERVER" = "1" ]; then
<BR> if [ "$CONNECTION_TRACKING" = "1" ]; then
<BR> iptables -A INPUT -i $INTERNET -p tcp \
<BR> --sport $SSH_PORTS \
<BR> -d $IPADDR --dport 22 \
<BR> -m state --state NEW -j ACCEPT
<BR> fi
<BR>
<BR> iptables -A INPUT -i $INTERNET -p tcp \
<BR> --sport $SSH_PORTS \
<BR> -d $IPADDR --dport 22 -j ACCEPT
<BR>
<BR> iptables -A OUTPUT -o $INTERNET -p tcp ! --syn \
<BR> -s $IPADDR --sport 22 \
<BR> --dport $SSH_PORTS -j ACCEPT
<BR>fi
<BR>
<BR>###############################################################
<BR># ftp (TCP Ports 21, 20)
<BR>
<BR># Outgoing Local Client Requests to Remote Servers
<BR>
<BR># Outgoing Control Connection to Port 21
<BR>if [ "$CONNECTION_TRACKING" = "1" ]; then
<BR> iptables -A OUTPUT -o $INTERNET -p tcp \
<BR> -s $IPADDR --sport $UNPRIVPORTS \
<BR> --dport 21 -m state --state NEW -j ACCEPT
<BR>fi
<BR>
<BR>iptables -A OUTPUT -o $INTERNET -p tcp \
<BR> -s $IPADDR --sport $UNPRIVPORTS \
<BR> --dport 21 -j ACCEPT
<BR>
<BR>iptables -A INPUT -i $INTERNET -p tcp ! --syn \
<BR> --sport 21 \
<BR> -d $IPADDR --dport $UNPRIVPORTS -j ACCEPT
<BR>
<BR># Incoming Port Mode Data Channel Connection from Port 20
<BR>if [ "$CONNECTION_TRACKING" = "1" ]; then
<BR> # This rule is not necessary if the ip_conntrack_ftp
<BR> # module is used.
<BR> iptables -A INPUT -i $INTERNET -p tcp \
<BR> --sport 20 \
<BR> -d $IPADDR --dport $UNPRIVPORTS \
<BR> -m state --state NEW -j ACCEPT
<BR>fi
<BR>
<BR>iptables -A INPUT -i $INTERNET -p tcp \
<BR> --sport 20 \
<BR> -d $IPADDR --dport $UNPRIVPORTS -j ACCEPT
<BR>
<BR>iptables -A OUTPUT -o $INTERNET -p tcp ! --syn \
<BR> -s $IPADDR --sport $UNPRIVPORTS \
<BR> --dport 20 -j ACCEPT
<BR>
<BR># Outgoing Passive Mode Data Channel Connection Between Unprivileveg Ports
<BR>if [ "$CONNECTION_TRACKING" = "1" ]; then
<BR> # This rule is not necessary if the ip_conntrack_ftp
<BR> # module is used.
<BR> iptables -A OUTPUT -o $INTERNET -p tcp \
<BR> -s $IPADDR --sport $UNPRIVPORTS \
<BR> --dport $UNPRIVPORTS -m state --state NEW -j ACCEPT
<BR>fi
<BR>
<BR>iptables -A OUTPUT -o $INTERNET -p tcp \
<BR> -s $IPADDR --sport $UNPRIVPORTS \
<BR> --dport $UNPRIVPORTS -j ACCEPT
<BR>
<BR>iptables -A INPUT -i $INTERNET -p tcp ! --syn \
<BR> --sport $UNPRIVPORTS \
<BR> -d $IPADDR --dport $UNPRIVPORTS -j ACCEPT
<BR>
<BR>#...............................................................
<BR># Incoming Remote Client Requests to Local Servers
<BR>
<BR>if [ "$FTP_SERVER" = "1" ]; then
<BR>
<BR> # Incoming Control Connection to Port 21
<BR> if [ "$CONNECTION_TRACKING" = "1" ]; then
<BR> iptables -A INPUT -i $INTERNET -p tcp \
<BR> --sport $UNPRIVPORTS \
<BR> -d $IPADDR --dport 21 \
<BR> -m state --state NEW -j ACCEPT
<BR> fi
<BR>
<BR> iptables -A INPUT -i $INTERNET -p tcp \
<BR> --sport $UNPRIVPORTS \
<BR> -d $IPADDR --dport 21 -j ACCEPT
<BR>
<BR> iptables -A OUTPUT -o $INTERNET -p tcp ! --syn \
<BR> -s $IPADDR --sport 21 \
<BR> --dport $UNPRIVPORTS -j ACCEPT
<BR>
<BR> # Outgoing Port Mode Data Channel Connection to Port 20
<BR> if [ "$CONNECTION_TRACKING" = "1" ]; then
<BR> iptables -A OUTPUT -o $INTERNET -p tcp \
<BR> -s $IPADDR --sport 20\
<BR> --dport $UNPRIVPORTS -m state --state NEW -j ACCEPT
<BR> fi
<BR>
<BR> iptables -A OUTPUT -o $INTERNET -p tcp \
<BR> -s $IPADDR --sport 20 \
<BR> --dport $UNPRIVPORTS -j ACCEPT
<BR>
<BR> iptables -A INPUT -i $INTERNET -p tcp ! --syn \
<BR> --sport $UNPRIVPORTS \
<BR> -d $IPADDR --dport 20 -j ACCEPT
<BR>
<BR> # Incoming Passive Mode Data Channel Connection Between Unprivileved Ports
<BR> if [ "$CONNECTION_TRACKING" = "1" ]; then
<BR> iptables -A INPUT -i $INTERNET -p tcp \
<BR> --sport $UNPRIVPORTS \
<BR> -d $IPADDR --dport $UNPRIVPORTS \
<BR> -m state --state NEW -j ACCEPT
<BR> fi
<BR>
<BR> iptables -A INPUT -i $INTERNET -p tcp \
<BR> --sport $UNPRIVPORTS \
<BR> -d $IPADDR --dport $UNPRIVPORTS -j ACCEPT
<BR>
<BR> iptables -A OUTPUT -o $INTERNET -p tcp ! --syn \
<BR> -s $IPADDR --sport $UNPRIVPORTS \
<BR> --dport $UNPRIVPORTS -j ACCEPT
<BR>fi
<BR>###############################################################
<BR># HTTP Web Traffic (TCP Port 80)
<BR>
<BR># Outgoing Local Client Requests to Remote Servers
<BR>
<BR>if [ "$CONNECTION_TRACKING" = "1" ]; then
<BR> iptables -A OUTPUT -o $INTERNET -p tcp \
<BR> -s $IPADDR --sport $UNPRIVPORTS \
<BR> --dport 80 -m state --state NEW -j ACCEPT
<BR>fi
<BR>
<BR>iptables -A OUTPUT -o $INTERNET -p tcp \
<BR> -s $IPADDR --sport $UNPRIVPORTS \
<BR> --dport 80 -j ACCEPT
<BR>
<BR>iptables -A INPUT -i $INTERNET -p tcp ! --syn \
<BR> --sport 80 \
<BR> -d $IPADDR --dport $UNPRIVPORTS -j ACCEPT
<BR>
<BR>#...............................................................
<BR># Incoming Remote Client Requests to Local Servers
<BR>
<BR>if [ "$WEB_SERVER" = "1" ]; then
<BR> if [ "$CONNECTION_TRACKING" = "1" ]; then
<BR> iptables -A INPUT -i $INTERNET -p tcp \
<BR> --sport $UNPRIVPORTS \
<BR> -d $IPADDR --dport 80 \
<BR> -m state --state NEW -j ACCEPT
<BR> fi
<BR>
<BR> iptables -A INPUT -i $INTERNET -p tcp \
<BR> --sport $UNPRIVPORTS \
<BR> -d $IPADDR --dport 80 -j ACCEPT
<BR>
<BR> iptables -A OUTPUT -o $INTERNET -p tcp ! --syn \
<BR> -s $IPADDR --sport 80 \
<BR> --dport $UNPRIVPORTS -j ACCEPT
<BR>fi
<BR>
<BR>###############################################################
<BR># SSL Web Traffic (TCP Port 443)
<BR>
<BR># Outgoing Local Client Requests to Remote Servers
<BR>
<BR>if [ "$CONNECTION_TRACKING" = "1" ]; then
<BR> iptables -A OUTPUT -o $INTERNET -p tcp \
<BR> -s $IPADDR --sport $UNPRIVPORTS \
<BR> --dport 443 -m state --state NEW -j ACCEPT
<BR>fi
<BR>
<BR>iptables -A OUTPUT -o $INTERNET -p tcp \
<BR> -s $IPADDR --sport $UNPRIVPORTS \
<BR> --dport 443 -j ACCEPT
<BR>
<BR>iptables -A INPUT -i $INTERNET -p tcp ! --syn \
<BR> --sport 443 \
<BR> -d $IPADDR --dport $UNPRIVPORTS -j ACCEPT
<BR>
<BR>#...............................................................
<BR># Incoming Remote Client Requests to Local Servers
<BR>
<BR>if [ "$SSL_SERVER" = "1" ]; then
<BR> if [ "$CONNECTION_TRACKING" = "1" ]; then
<BR> iptables -A INPUT -i $INTERNET -p tcp \
<BR> --sport $UNPRIVPORTS \
<BR> -d $IPADDR --dport 443 \
<BR> -m state --state NEW -j ACCEPT
<BR> fi
<BR>
<BR> iptables -A INPUT -i $INTERNET -p tcp \
<BR> --sport $UNPRIVPORTS \
<BR> -d $IPADDR --dport 443 -j ACCEPT
<BR>
<BR> iptables -A OUTPUT -o $INTERNET -p tcp ! --syn \
<BR> -s $IPADDR --sport 443 \
<BR> --dport $UNPRIVPORTS -j ACCEPT
<BR>fi
<BR>
<BR>###############################################################
<BR># whois (TCP Port 43)
<BR>
<BR># Outgoing Local Client Requests to Remote Servers
<BR>
<BR>if [ "$CONNECTION_TRACKING" = "1" ]; then
<BR> iptables -A OUTPUT -o $INTERNET -p tcp \
<BR> -s $IPADDR --sport $UNPRIVPORTS \
<BR> --dport 43 -m state --state NEW -j ACCEPT
<BR>fi
<BR>
<BR>iptables -A OUTPUT -o $INTERNET -p tcp \
<BR> -s $IPADDR --sport $UNPRIVPORTS \
<BR> --dport 43 -j ACCEPT
<BR>
<BR>iptables -A INPUT -i $INTERNET -p tcp ! --syn \
<BR> --sport 43 \
<BR> -d $IPADDR --dport $UNPRIVPORTS -j ACCEPT
<BR>
<BR>###############################################################
<BR># Accessing Remote Network Time Servers (UDP 123)
<BR># Note: some client and servers use source port 123
<BR># when querying a remote server on destination port 123.
<BR>
<BR>if [ "$CONNECTION_TRACKING" = "1" ]; then
<BR> iptables -A OUTPUT -o $INTERNET -p udp \
<BR> -s $IPADDR --sport $UNPRIVPORTS \
<BR> -d $TIME_SERVER --dport 123 \
<BR> -m state --state NEW -j ACCEPT
<BR>fi
<BR>
<BR>iptables -A OUTPUT -o $INTERNET -p udp \
<BR> -s $IPADDR --sport $UNPRIVPORTS \
<BR> -d $TIME_SERVER --dport 123 -j ACCEPT
<BR>
<BR>iptables -A INPUT -i $INTERNET -p udp \
<BR> -s $TIME_SERVER --sport 123 \
<BR> -d $IPADDR --dport $UNPRIVPORTS -j ACCEPT
<BR>
<BR>###############################################################
<BR># Accessing Your ISP´s DHCP Server (UDP Ports 67, 68)
<BR>
<BR># Some broadcast packets are explicitly ignored by the firewall.
<BR># Others are dopped by the default policy.
<BR># DHCP tests must precede broadcast-related rules, as DHCP relies
<BR># on broadcast traffic initially.
<BR>
<BR>if [ "$DHCP_CLIENT" = "1" ]; then
<BR> # Initialization or rebinding: No lease or Lease time expired.
<BR>
<BR> iptables -A OUTPUT -o $INTERNET -p udp \
<BR> -s $BROADCAST_SRC --sport 68 \
<BR> -d $BROADCAST_DEST --dport 67 -j ACCEPT
<BR>
<BR> # Incoming DHCPOFFER from available DHCP servers
<BR>
<BR> iptables -A INPUT -i $INTERNET -p udp \
<BR> -s $BROADCAST_SRC --sport 67 \
<BR> -d $BROADCAST_DEST --dport 68 -j ACCEPT
<BR>
<BR> # Fall back to initialization
<BR> # The client knows its server, but has either lost its lease,
<BR> # or else needs to reconfirm the IP address after rebooting.
<BR>
<BR> iptables -A OUTPUT -o $INTERNET -p udp \
<BR> -s $BROADCAST_SRC --sport 68 \
<BR> -d $DHCP_SERVER --dport 67 -j ACCEPT
<BR>
<BR> iptables -A INPUT -i $INTERNET -p udp \
<BR> -s $DHCP_SERVER --sport 67 \
<BR> -d $BROADCAST_DEST --dport 68 -j ACCEPT
<BR>
<BR> # As a result of the above, we´re supposed to change our IP
<BR> # address with this message, which is addressed to our new
<BR> # address before the dhcp client has received the update.
<BR> # Depending on the server implementation, the destination address
<BR> # can be the new IP address, the subnet address, or the limited
<BR> # broadcast address.
<BR>
<BR> # If the network subnet address is used as the destination,
<BR> # the next rule must allow incoming packets destined to the
<BR> # subnet address, and the rule must preceed any general rules
<BR> # that block such incoming broadcast packets.
<BR>
<BR> iptables -A INPUT -i $INTERNET -p udp \
<BR> -s $DHCP_SERVER --sport 67 \
<BR> --dport 68 -j ACCEPT
<BR>
<BR> # Lease renewal
<BR>
<BR> iptables -A OUTPUT -o $INTERNET -p udp \
<BR> -s $IPADDR --sport 68 \
<BR> -d $DHCP_SERVER --dport 67 -j ACCEPT
<BR>
<BR> iptables -A INPUT -i $INTERNET -p udp \
<BR> -s $DHCP_SERVER --sport 67 \
<BR> -d $IPADDR --dport 68 -j ACCEPT
<BR>
<BR> # Refuse directed broadcasts
<BR> # Used to map networks and in Denial of Service attacks
<BR> #iptables -A INPUT -i $INTERNET -d $SUBNET_BASE -j DROP
<BR> #iptables -A INPUT -i $INTERNET -d $SUBNET_BROADCAST -j DROP
<BR>
<BR> # Refuse limited broadcasts
<BR> iptables -A INPUT -i $INTERNET -d $BROADCAST_DEST -j DROP
<BR>
<BR>fi
<BR>###############################################################
<BR># ICMP Control and Status Messages
<BR>
<BR># Log and drop initial ICMP fragments
<BR>iptables -A INPUT -i $INTERNET --fragment -p icmp -j LOG \
<BR> --log-prefix "Fragmented incoming ICMP: "
<BR>iptables -A INPUT -i $INTERNET --fragment -p icmp -j DROP
<BR>
<BR>iptables -A OUTPUT -o $INTERNET --fragment -p icmp -j LOG \
<BR> --log-prefix "Fragmented outgoing ICMP: "
<BR>iptables -A OUTPUT -o $INTERNET --fragment -p icmp -j DROP
<BR>
<BR>iptables -A INPUT -i $INTERNET -p icmp \
<BR> --icmp-type source-quench -d $IPADDR -j ACCEPT
<BR>
<BR>iptables -A OUTPUT -o $INTERNET -p icmp \
<BR> -s $IPADDR --icmp-type source-quench -j ACCEPT
<BR>
<BR>iptables -A INPUT -i $INTERNET -p icmp \
<BR> --icmp-type parameter-problem -d $IPADDR -j ACCEPT
<BR>
<BR>iptables -A OUTPUT -o $INTERNET -p icmp \
<BR> -s $IPADDR --icmp-type parameter-problem -j ACCEPT
<BR>
<BR>iptables -A INPUT -i $INTERNET -p icmp \
<BR> --icmp-type destination-unreachable -d $IPADDR -j ACCEPT
<BR>
<BR>iptables -A OUTPUT -o $INTERNET -p icmp \
<BR> -s $IPADDR --icmp-type fragmentation-needed -j ACCEPT
<BR>
<BR># Don¹t log dropped outgoing ICMP error messages
<BR>iptables -A OUTPUT -o $INTERNET -p icmp \
<BR> -s $IPADDR --icmp-type destination-unreachable -j DROP
<BR>
<BR># Intermediate traceroute responses
<BR>iptables -A INPUT -i $INTERNET -p icmp \
<BR> --icmp-type time-exceeded -d $IPADDR -j ACCEPT
<BR>
<BR># allow outgoing pings to anywhere
<BR>if [ "$CONNECTION_TRACKING" = "1" ]; then
<BR> iptables -A OUTPUT -o $INTERNET -p icmp \
<BR> -s $IPADDR --icmp-type echo-request \
<BR> -m state --state NEW -j ACCEPT
<BR>fi
<BR>
<BR>iptables -A OUTPUT -o $INTERNET -p icmp \
<BR> -s $IPADDR --icmp-type echo-request -j ACCEPT
<BR>
<BR>iptables -A INPUT -i $INTERNET -p icmp \
<BR> --icmp-type echo-reply -d $IPADDR -j ACCEPT
<BR>
<BR># allow incoming pings from trusted hosts
<BR>#if [ "$CONNECTION_TRACKING" = "1" ]; then
<BR> #iptables -A INPUT -i $INTERNET -p icmp \
<BR> #-s $MY_ISP --icmp-type echo-request -d $IPADDR \
<BR> #-m state --state NEW -j ACCEPT
<BR>#fi
<BR>
<BR>#iptables -A INPUT -i $INTERNET -p icmp \
<BR> #-s $MY_ISP --icmp-type echo-request -d $IPADDR -j ACCEPT
<BR>
<BR>#iptables -A OUTPUT -o $INTERNET -p icmp \
<BR> #-s $IPADDR --icmp-type echo-reply -d $MY_ISP -j ACCEPT
<BR>
<BR>###############################################################
<BR># Logging Dropped Packets
<BR>
<BR># Don´t log dropped incoming echo-requests
<BR>iptables -A INPUT -i $INTERNET -p icmp \
<BR> --icmp-type ! 8 -d $IPADDR -j LOG
<BR>
<BR>iptables -A INPUT -i $INTERNET -p tcp \
<BR> -d $IPADDR -j LOG
<BR>
<BR>iptables -A OUTPUT -o $INTERNET -j LOG
<BR>
<BR>exit 0 </BLOCKQUOTE></FONT></TD></TR><TR><TD><HR></TD></TR></TABLE><!-- BBCode Quote End -->
<BR>
<BR>Siccome non sapevo cosa fossero i sottoindicati parametri:
<BR>
<BR><!-- BBCode Quote Start --><TABLE BORDER=0 ALIGN=CENTER WIDTH=85%><TR><TD><font size=-1>Quote:</font><HR></TD></TR><TR><TD><FONT SIZE=-1><BLOCKQUOTE> #SUBNET_BASE="" # ISP network segment base address
<BR>#SUBNET_BROADCAST="" # network segment broadcast address
<BR>#MY_ISP="" # ISP server & NOC address range </BLOCKQUOTE></FONT></TD></TR><TR><TD><HR></TD></TR></TABLE><!-- BBCode Quote End -->
<BR>
<BR>ho pensato bene di commentarli sia nella parte iniziale dello script sia all´interno del firewall vero e proprio, in quanto se lasciati "vuoti" e decommentati originano una serie di bad argument da parte di iptables! Ora il firewall "funziona" e sono in grado di fare tutto! Vorrei un vostro parere sulle modifiche da me apportate in quanto non vorrei che fossere delle bestiate come quella che apportai al primo script! In sostanza, così modificato lo script filtra oppure ho fatto un´altra scemenza? Have anice day
<BR>
<BR><br>