fillipemcs
(usa Debian)
Enviado em 15/09/2009 - 13:32h
Amigos, seguem as regras de firewall
#!/bin/bash
iniciar()
{
iptables -F
iptables -Z
iptables -X
iptables -t nat -F
## nat
modprobe iptable_nat
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -A INPUT -s 0/0 -p tcp --dport 20 -j ACCEPT
iptables -A OUTPUT -d 0/0 -p tcp --sport 20 -j ACCEPT
iptables -A INPUT -s 0/0 -p tcp --dport 21 -j ACCEPT
iptables -A OUTPUT -d 0/0 -p tcp --sport 21 -j ACCEPT
#iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE
#iptables -A INPUT -p tcp --dport 21 -j ACCEPT #Fillipe
## Regra de redirecionamento da porta 80 para a 8080 utilizada pelo Dansguardian
iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 8080
iptables -A INPUT -m tcp -p tcp -s ! 127.0.0.1 --dport 3128 -j DROP
## Regra de redirecionamento da porta 3389 ulilizada pelo Termial Server do Windows 2003
iptables -t nat -A PREROUTING -s 0/0 -m tcp -p tcp -i eth0 --dport 3389 -j DNAT --to-destination 192.168.0.251
## Regra de redirecionamento da porta 82 utilizada pelo TSWeb do windows
iptables -t nat -A PREROUTING -s 0/0 -m tcp -p tcp -i eth0 --dport 82 -j DNAT --to-destination 192.168.0.251
## VNC
iptables -I FORWARD -p tcp -d 192.168.0.1 --dport 5900 -j ACCEPT
iptables -t nat -A PREROUTING -p tcp --dport 5900 -j DNAT --to-destination 192.168.0.1:5900
## VNC
iptables -I FORWARD -p tcp -d 192.168.0.253 --dport 3130 -j ACCEPT
iptables -t nat -A PREROUTING -p tcp --dport 3130 -j DNAT --to-destination 192.168.0.253:3130
iptables -I FORWARD -p tcp -d 192.168.0.253 --dport 3000 -j ACCEPT
iptables -t nat -A PREROUTING -p tcp --dport 3000 -j DNAT --to-destination 192.168.0.253:3000
iptables -I FORWARD -p tcp -d 192.168.0.253 --dport 3001 -j ACCEPT
iptables -t nat -A PREROUTING -p tcp --dport 3001 -j DNAT --to-destination 192.168.0.253:3001
iptables -I FORWARD -p tcp -d 192.168.0.253 --dport 3003 -j ACCEPT
iptables -t nat -A PREROUTING -p tcp --dport 3003 -j DNAT --to-destination 192.168.0.253:3003
iptables -I FORWARD -p tcp -d 192.168.0.253 --dport 3005 -j ACCEPT
iptables -t nat -A PREROUTING -p tcp --dport 3005 -j DNAT --to-destination 192.168.0.253:3005
iptables -I FORWARD -p udp -d 192.168.0.253 --dport 3007 -j ACCEPT
iptables -t nat -A PREROUTING -p udp --dport 3007 -j DNAT --to-destination 192.168.0.253:3007
iptables -I FORWARD -p tcp -d 192.168.0.253 --dport 8800 -j ACCEPT
iptables -t nat -A PREROUTING -p tcp --dport 8800 -j DNAT --to-destination 192.168.0.253:8800
# iptables -I FORWARD -p tcp -d 192.168.0.6 --dport 22000 -j ACCEPT
# iptables -t nat -A PREROUTING -p tcp --dport 22000 -j DNAT --to-destination 192.168.0.6:22000
## outlook
iptables -A FORWARD -p udp -s 192.168.0.0/24 -d 200.10.120.2 --dport 53 -j ACCEPT
iptables -A FORWARD -p udp -s 192.168.0.0/24 -d 200.10.128.3 --dport 53 -j ACCEPT
iptables -A FORWARD -p udp -s 200.10.120.2 --sport 53 -d 192.168.0.0/24 -j ACCEPT
iptables -A FORWARD -p udp -s 200.10.128.3 --sport 53 -d 192.168.0.0/24 -j ACCEPT
##FTP (em 11/08/09)
iptables -A FORWARD -p TCP -i 192.168.0.0/24 --dport 21 -j ACCEPT
##POP (11/08/09)
iptables -A FORWARD -p TCP -i 192.168.0.0/24 --dport 110 -j ACCEPT
##SMTP (11/08/09)
iptables -A FORWARD -p TCP -s 192.168.0.0/24 --dport 25 -j ACCEPT
iptables -A FORWARD -p TCP -s 192.168.0.0/24 --dport 25 -j ACCEPT
iptables -A FORWARD -p TCP -s 192.168.0.0/24 --dport 110 -j ACCEPT
iptables -A FORWARD -p tcp --sport 25 -j ACCEPT
iptables -A FORWARD -p tcp --sport 110 -j ACCEPT
# iptables -A FORWARD -p TCP --dport 25 -i eth0 -j ACCEPT
# iptables -A FORWARD -p UDP --dport 53 -i eth0 -j ACCEPT
# iptables -A FORWARD -p TCP --dport 110 -i eth0 -j ACCEPT
}
parar()
{
iptables -F -t nat
}
case "$1" in
"start")
iniciar
;;
"stop")
parar
;;
*)
echo "utilize start ou stop"
esac
OBS: alguns cometários foram feitos por mim pois já venho tentando mudar essas regras a algumas semanas.
Obrigado pela atenção de todos!