predator
(usa Debian)
Enviado em 08/03/2013 - 13:58h
Olá pessoal,
Estou mudando as politicas do meu firewall todas para DROP, porem, se eu coloco o OUTPUT como DROP, não consigo acessar a internet, nem do proprio firewall, segue o meu script...
Obrigado
Eduardo
#!/bin/sh
iniciar(){
#Carregando modulos
modprobe ip_tables
modprobe iptable_filter
modprobe ip_conntrack
modprobe ip_conntrack_ftp
modprobe iptable_nat
modprobe ip_nat_ftp
modprobe ipt_LOG
modprobe ipt_state
modprobe ipt_MASQUERADE
#Definindo a politica default das cadeias
iptables -P INPUT DROP
iptables -P OUTPUT DROP
iptables -P FORWARD DROP
#Ativando Roteamento e Compartilhamento de Conexao
echo "1" > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE
# Liberando acesso da rede interna e loopback
iptables -A INPUT -p ALL -s 127.0.0.1 -i lo -j ACCEPT
iptables -A INPUT -p ALL -s 192.168.0.0/24 -i lo -j ACCEPT
iptables -A INPUT -i eth0 -p tcp --dport 3128 -j ACCEPT
iptables -t filter -A INPUT -p tcp --dport 22 -j ACCEPT
#Sockets validos
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A OUTPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
#Liberando portas
iptables -A OUTPUT -p udp --dport 53 -j ACCEPT
iptables -A FORWARD -p tcp -i eth0 -s 192.168.0.0/24 -m multiport --dport 143,25,587 -j ACCEPT
}
parar(){
/sbin/iptables -F
/sbin/iptables -X
/sbin/iptables -F -t nat
/sbin/iptables -X -t nat
/sbin/iptables -F -t mangle
/sbin/iptables -X -t mangle
echo "Regras de firewall desativadas..."
}
case "$1" in
"start") iniciar ;;
"stop") parar ;;
"restart") parar; iniciar ;;
*) echo "Use os parametros start ou stop"
esac