Enviado em 23/09/2016 - 20:22h
Olá, pessoal. Boa noite!!!
echo "Iniciando o Firewall..."
iptables -t filter -F
iptables -t nat -F
iptables -t mangle -F
iptables -t raw -F
iptables -t security -F
# Habilitando politica do Firewall
for i in INPUT OUTPUT FORWARD; do iptables -t filter -P \$i DROP; done
# Protege de Spoofing
echo "1" > /proc/sys/net/ipv4/conf/default/rp_filter
# Protege de synflood
echo "1" > /proc/sys/net/ipv4/tcp_syncookies
# Protege de ICMP Broadcasting
echo "1" > /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts
# Bloqueia pings
echo "1" > /proc/sys/net/ipv4/icmp_echo_ignore_all
# Logando todos os pacotes com destino a squid
for i in INPUT OUTPUT; do iptables -t filter -A $i -j LOG; done
# Habilitando comunicação entre processos locais
iptables -t filter -A INPUT -s 0/0 -d 127.0.0.1 -j ACCEPT
iptables -t filter -A OUTPUT -d 0/0 -s 127.0.0.1 -j ACCEPT
# Habilitando conexão ao SSH
iptables -t filter -A INPUT -p tcp -s 0/0 --dport 22 -j ACCEPT
iptables -t filter -A OUTPUT -p tcp -d 0/0 --sport 22 -j ACCEPT
# Habilitando comunicação DNS na máquina
iptables -t filter -A INPUT -p udp -s 0/0 --dport 53 -j ACCEPT
iptables -t filter -A OUTPUT -p udp -d 0/0 --sport 53 -j ACCEPT
# Habilitando conexão ao Squid
iptables -t filter -A INPUT -p tcp -s 0/0 --dport 3128 -j ACCEPT
iptables -t filter -A OUTPUT -p tcp -d 0/0 --sport 3128 -j ACCEPT
echo "1" > /proc/sys/net/ipv4/ip_forward
# Recomendacao minima de configuracao:
acl manager proto cache_object
acl localhost src 127.0.0.1/32 ::1
acl to_localhost dst 127.0.0.0/8 0.0.0.0/32 ::1
acl SSL_ports port 443 563 # https
acl Safe_ports port 80 443 70 3128 1025-65535 # http https gopher squid
acl CONNECT method CONNECT
http_access allow manager localhost
http_access deny manager
http_access allow Safe_ports
http_access deny CONNECT !SSL_ports
http_access allow localhost
http_access allow to_localhost
# Porta do proxy Squid
http_port 200.x.x.x:3128