Enviado em 26/12/2013 - 10:36h
Olá pessoal, estou preparando um servidor Debian 7, com squid3 e firewall iptables. O squid3 já está instalado e configurado, estou configurando o iptables. Já compartilhei a internet e está funcionando, porém, apenas setando o proxy e a porta no browser, ativei o proxy transparente colocando a linha http_port 3128 transparent no squid.conf, mas ainda não funciona. Segue as minhas regras do firewall:
#!/bin/sh
#
firewall_start(){
echo ""
echo " Iniciando as Regras do Firewall ..............."
echo ""
echo " Limpando as Regras Anteriores .......... [ OK ]"
echo ""
iptables -F INPUT
iptables -F OUTPUT
iptables -F FORWARD
iptables -t filter -F
iptables -t nat -F
iptables -t mangle -F
iptables -t raw -F
#### REGRAS DE LOG ####
iptables -A OUTPUT -p tcp --dport 80 -j LOG
#lIBERA PINGS
iptables -I INPUT -p icmp -j ACCEPT
iptables -I OUTPUT -p icmp -j ACCEPT
#Libera SSH
iptables -A INPUT -p tcp -s 10.1.4.15 --dport 7654 -j ACCEPT
iptables -A INPUT -p tcp -s 10.1.4.170 --dport 7654 -j ACCEPT
iptables -A OUTPUT -p tcp -d 10.1.4.15 --sport 7654 -j ACCEPT
#iptables -A OUTPUT -p tcp -d 10.1.4.170 --sport 7654 -j ACCEPT
echo " Ativando o Proxy Transparente SQUID .......... [ OK ]"
iptables -t nat -A PREROUTING -i eth1 -p tcp --dport 80 -j REDIRECT --to-port 3128
iptables -A INPUT -p tcp --dport 3128 -j ACCEPT
iptables -A INPUT -p udp --dport 3128 -j ACCEPT
iptables -A INPUT -p ALL -i lo -s ip_ext -j ACCEPT
iptables -A OUTPUT -p ALL -s ip_ext -j ACCEPT
iptables -t nat -A POSTROUTING -s 10.1.4.0/24 -o eth0 -d 0/0 -j SNAT --to-source ip_ext
echo " Ativando o IP forward .......... [ OK ]"
echo "1" > /proc/sys/net/ipv4/ip_forward
echo "1" > /proc/sys/net/ipv4/conf/all/rp_filter
echo "1" > /proc/sys/net/ipv4/conf/all/proxy_arp
echo "1" > /proc/sys/net/ipv4/ip_dynaddr
#echo 1 > /proc/sys/net/ipv4/ip_forward
#modprobe iptable_nat
#libera pacotes de retorno da internet
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A OUTPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
echo " Liberando a interface de loopback .......... [ OK ]"
iptables -A INPUT -i lo -j ACCEPT
echo " Firewall em operacao .......... [ OK ]"
sleep 1
echo " Definindo Politicas Padrao ..............."
echo ""
iptables -P INPUT DROP
iptables -P OUTPUT DROP
iptables -P FORWARD DROP
}
firewall_stop(){
iptables -F
iptables -X
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT
}
case "$1" in
"start")
firewall_start
;;
"stop")
firewall_stop
echo " Desativando todas as Regras do Firewall .......... [ OK ]"
sleep 1
;;
status)
echo -e " ============================== Table Filter ============================ ";
iptables -t filter -L -n
echo -e " ============================== Table Nat ============================= ";
iptables -t nat -L -n
echo -e " ============================== Table Mangle =========================== ";
iptables -t mangle -L -n
echo -e " ============================== Table Raw ============================ ";
iptables -t raw -L -n
;;
"restart")
echo " Reativando todas as Regras do Firewall .......... [ OK ]"
sleep 1
firewall_stop; firewall_start
;;
*)
iptables -L -n
esac