Enviado em 20/03/2015 - 18:11h
Olá pessoal,### Interfaces ###
int=eth0
ext=ppp0
### Exclusão de regras ###
iptables -t nat -F
iptables -t mangle -F
iptables -t filter -F
### Exclusão de cadeias ###
iptables -X
### Reset em contadores ###
iptables -t nat -Z
iptables -t mangle -Z
iptables -t filter -Z
### Carregamento dos modulos ###
modprobe iptable_nat
modprobe iptable_filter
modprobe iptable_mangle
### Definição de políticas ###
iptables -P INPUT DROP
iptables -P OUTPUT ACCEPT
iptables -P FORWARD DROP
### Trafego http para Squid ###
#iptables -t nat -A PREROUTING -s 192.168.100.0/255.255.255.0 -p tcp --dport 80 -j REDIRECT --to-port 3128
### Regras INPUT ###
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
# Loopback #
iptables -A INPUT -i lo -j ACCEPT
# ICMP 0 #
iptables -A INPUT -p icmp --icmp-type 0 -j ACCEPT
# ICMP 8 #
iptables -A INPUT -p icmp --icmp-type 8 -j ACCEPT
# SSH #
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
# FTP #
iptables -A INPUT -p tcp --dport 21 -j ACCEPT
# OpenVPN #
iptables -A INPUT -p tcp --dport 1194 -j ACCEPT
# HTTP #
iptables -A INPUT -p tcp --dport 80 -j ACCEPT
### Regras FORWARD ###
iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
# ICMP #
iptables -A FORWARD -p icmp -j ACCEPT
# SMTP #
iptables -A FORWARD -p tcp --dport 25 -j ACCEPT
# SSH #
iptables -A FORWARD -p tcp --dport 22 -j ACCEPT
# FTP #
iptables -A FORWARD -p tcp --dport 21 -j ACCEPT
# POP #
iptables -A FORWARD -p tcp --dport 110 -j ACCEPT
# SSL #
iptables -A FORWARD -p tcp --dport 443 -j ACCEPT
# MS Terminal Server #
iptables -A FORWARD -p tcp --dport 3389 -j ACCEPT
# HTTP #
iptables -A FORWARD -p tcp --dport 80 -j ACCEPT
# HTTPS #
iptables -A FORWARD -p tcp --dport 443 -j ACCEPT
# VNC #
iptables -A FORWARD -p tcp --dport 5900 -j ACCEPT
# OpenVPN #
iptables -A FORWARD -p tcp --dport 1194 -j ACCEPT
# Sites #
for list in `cat /tmp/firewall/sites_bloq` ; do
iptables -I FORWARD -m string --algo bm --string $list -j DROP
done
### Regras OUTPUT ###
iptables -A OUTPUT -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
### Regras POSTROUTING ###
iptables -t nat -A POSTROUTING -o $ext -j MASQUERADE
echo 1 > /proc/sys/net/ipv4/ip_forward
### Mensagem de encerramento ###
echo "Firewall ativado"
youtube.com
facebook.com
twitter.com
instagram.com