newtuxfan
(usa Fedora)
Enviado em 23/11/2009 - 12:23h
Seria assim ?
Qual regra faltaria para o que eu tenciono fazer ? Isolar as duas subredes (eth1 e eth2) eu já consegui.
#!/bin/sh
iptables -P FORWARD DROP
iptables -F FORWARD
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -j MASQUERADE
iptables -t nat -A POSTROUTING -s 172.16.0.0/24 -j MASQUERADE
echo 1 > /proc/sys/net/ipv4/conf/eth1/arp_filter
echo 1 > /proc/sys/net/ipv4/conf/eth2/arp_filter
iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
#As 2 subredes podem se enxergar
#iptables -A FORWARD -i eth1 -s 192.168.0.0/24 -j ACCEPT
#iptables -A FORWARD -i eth2 -s 172.16.0.0/24 -j ACCEPT
#As 2 subredes *não* podem se enxergar
iptables -A FORWARD -i eth1 -o eth0 -s 192.168.0.0/24 -j ACCEPT
iptables -A FORWARD -i eth2 -o eth0 -s 172.16.0.0/24 -j ACCEPT
#bloqueia acesso direto, por fora do Squid.
iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 3128
iptables -t nat -A PREROUTING -p tcp --dport 81 -j REDIRECT --to-port 3128
iptables -t nat -A PREROUTING -p tcp --dport 443 -j REDIRECT --to-port 3128
iptables -t nat -A PREROUTING -p tcp --dport 8080 -j REDIRECT --to-port 3128
#BLOQUEANDO RELAY SQUID CONTRA SPAMMERS
#iptables -A INPUT -p tcp -s ! 192.168.0.0/24 --dport 3128 -j LOG --log-level 1 --log-prefix "@TCP->SQUID RELAY DENIED "
#iptables -A INPUT -p tcp -s ! 192.168.0.0/24 --dport 3128 -j DROP
#iptables -A INPUT -p udp -s ! 192.168.0.0/24 --dport 3128 -j LOG --log-level 1 --log-prefix "@UDP->SQUID RELAY DENIED "
#iptables -A INPUT -p udp -s ! 192.168.0.0/24 --dport 3128 -j DROP
#BLOQUEANDO ACESSO EXTERNO AOS SERVIÇOS ESSENCIAIS
iptables -A INPUT -s 0/0 -p tcp -i eth0 --dport 21 -j LOG --log-level 1 --log-prefix "@TCP->FTP ACCESS DENIED "
iptables -A INPUT -s 0/0 -p tcp -i eth0 --dport 21 -j DROP
iptables -A INPUT -s 0/0 -p tcp -i eth0 --dport 22 -j LOG --log-level 1 --log-prefix "@TCP->SSH ACCESS DENIED "
iptables -A INPUT -s 0/0 -p tcp -i eth0 --dport 22 -j DROP
iptables -A INPUT -s 0/0 -p tcp -i eth0 --dport 23 -j LOG --log-level 1 --log-prefix "@TCP->TELNET ACCESS DENIED "
iptables -A INPUT -s 0/0 -p tcp -i eth0 --dport 23 -j DROP
iptables -A INPUT -s 0/0 -p tcp -i eth0 --dport 25 -j LOG --log-level 1 --log-prefix "@TCP->SMTP ACCESS DENIED "
iptables -A INPUT -s 0/0 -p tcp -i eth0 --dport 25 -j DROP
iptables -A INPUT -s 0/0 -p tcp -i eth0 --dport 110 -j LOG --log-level 1 --log-prefix "@TCP->POP ACCESS DENIED "
iptables -A INPUT -s 0/0 -p tcp -i eth0 --dport 110 -j DROP
iptables -A INPUT -s 0/0 -p tcp -i eth0 --dport 10000 -j LOG --log-level 1 --log-prefix "@TCP->WEBMIN ACCESS DENIED "
iptables -A INPUT -s 0/0 -p tcp -i eth0 --dport 10000 -j DROP