kamiloko
(usa Debian)
Enviado em 16/03/2014 - 22:18h
Olá pessoal,
Mudei para scrit e acabei achando o erro!!!
Pelo que percebi eram 2!
Um era que a porta 80 não estava aberta para o servidor e outra foi resolvido com estes comandos:
#permite que conexoes ja criadas pela LAN retornem sem criar novas regras
iptables -t filter -A INPUT -m state --state ESTABLISHED,RELATED,NEW -j ACCEPT
iptables -t filter -A OUTPUT -m state --state ESTABLISHED,RELATED,NEW -j ACCEPT
iptables -t filter -A FORWARD -m state --state ESTABLISHED,RELATED,NEW -j ACCEPT
segue código:
#!/bin/sh
#interface de internet:
iface="eth0:1"
#interface de rede local
ifacelocal="eth0"
iniciar(){
modprobe iptable_nat
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -o $iface -j MASQUERADE
echo 1 > /proc/sys/net/ipv4/conf/default/rp_filter
iptables -t nat -A PREROUTING -i $ifacelocal -p tcp --dport 80 -j REDIRECT --to 3128
iptables -A INPUT -m state --state INVALID -j DROP
iptables -A INPUT -i lo -j ACCEPT
#iptables -A INPUT -i eth0 -j ACCEPT
#permite que conexoes ja criadas pela LAN retornem sem criar novas regras
iptables -t filter -A INPUT -m state --state ESTABLISHED,RELATED,NEW -j ACCEPT
iptables -t filter -A OUTPUT -m state --state ESTABLISHED,RELATED,NEW -j ACCEPT
iptables -t filter -A FORWARD -m state --state ESTABLISHED,RELATED,NEW -j ACCEPT
#liberando passagem de pacotes entre interfaces
iptables -t filter -A FORWARD -i $ifacelocal -o $iface -j ACCEPT
####criando cadeias
iptables -N C_DNS
iptables -N C_SSH
iptables -N C_HTTP_SQUID
iptables -N C_HTTP
iptables -N C_NETBIOS
iptables -N C_GERAL_INPUT
iptables -N C_GERAL_FORWARD
###Atribuicoes
iptables -A INPUT -p udp -m udp --dport 53 -j C_DNS
iptables -A INPUT -p tcp -m tcp --dport 137 -j C_NETBIOS
iptables -A INPUT -p udp -m udp --dport 137 -j C_NETBIOS
iptables -A INPUT -p tcp -m tcp --dport 22 -j C_SSH
iptables -A INPUT -p tcp -m tcp --dport 3128 -j C_HTTP_SQUID
iptables -A INPUT -p tcp -m tcp --dport 80 -j C_HTTP
iptables -A INPUT -j C_GERAL_INPUT
iptables -A FORWARD -p udp -m udp --dport 53 -j C_DNS
iptables -A FORWARD -p tcp -m tcp --dport 137 -j C_NETBIOS
iptables -A FORWARD -p udp -m udp --dport 137 -j C_NETBIOS
iptables -A FORWARD -p tcp -m tcp --dport 22 -j C_SSH
iptables -A FORWARD -p tcp -m tcp --dport 3128 -j C_HTTP_SQUID
iptables -A FORWARD -p tcp -m tcp --dport 80 -j C_HTTP
iptables -A FORWARD -j C_GERAL_FORWARD
#####https
iptables -t filter -A OUTPUT -p tcp --dport 443 -j ACCEPT
iptables -t filter -A FORWARD -i $ifacelocal -p tcp --dport 443 -j ACCEPT
#####
###regras http squid
iptables -A C_HTTP_SQUID -s 192.168.1.0/24 -j ACCEPT
iptables -A C_HTTP_SQUID -s 192.168.2.0/24 -j ACCEPT
iptables -A C_HTTP_SQUID -j LOG --log-prefix "BLOCKED C_HTTP_SQUID: "
iptables -A C_HTTP_SQUID -j DROP
###/regras http squid
###regras http
iptables -A C_HTTP -d 192.168.1.34 -j ACCEPT
iptables -A C_HTTP -s 192.168.1.34 -j ACCEPT
iptables -A C_HTTP -j LOG --log-prefix "BLOCKED C_HTTP: "
iptables -A C_HTTP -j DROP
###/regras http
###regras ssh
iptables -A C_SSH -d 192.168.1.34/32 -j ACCEPT
iptables -A C_SSH -d 192.168.2.1/32 -j ACCEPT
iptables -A C_SSH -j LOG --log-prefix "BLOCKED C_SSH: "
iptables -A C_SSH -j DROP
###/regras ssh
###regras dns
iptables -A C_DNS -d 192.168.1.0/24 -j ACCEPT
iptables -A C_DNS -d 192.168.2.0/24 -j ACCEPT
iptables -A C_DNS -j LOG --log-prefix "BLOCKED C_DNS: "
iptables -A C_DNS -j DROP
###/regras dns
###regras netbios
iptables -A C_NETBIOS -s 192.168.1.0/24 -j ACCEPT
iptables -A C_NETBIOS -s 192.168.2.0/24 -j ACCEPT
iptables -A C_NETBIOS -j DROP
###/regras nrtbios
###regras geral INPUT
iptables -A C_GERAL_INPUT -j LOG --log-prefix "BLOCKED GERAL INPUT : "
iptables -A C_GERAL_INPUT -j DROP
###/regras GERAl INPUT
###regras geral INPUT
iptables -A C_GERAL_FORWARD -j LOG --log-prefix "BLOCKED GERAL FORWARD : "
iptables -A C_GERAL_FORWARD -j DROP
###/regras GERAl INPUT
}
parar(){
iptables -F
iptables -F -t nat
}
case "$1" in
"start") iniciar ;;
"stop") parar ;;
"restart") parar; iniciar;;
*) echo "use os parametros start, stop ou reestart"
esac
**************************************************************************************************************