Enviado em 27/01/2008 - 14:15h
Caros amigos, estou com um probleminha. Tenho uma conexão NET VIRTUA com ip dinâmico. Tenho uma maquina com duas placas de rede (eth0-net e eth1-rede interna). Estou usando SQUID 2.5. Tudo configurado, porém, não consigo coloca-lo como proxy transparente, apenas, definindo a configuração de proxy nas estações. Estou enviando minhas configurações:
Arquivo squid.conf
http_port 3128
visible_hostname agata
cache_mem 64 MB # quantidade da cache usada na memória ram,
maximum_object_size_in_memory 64 KB
maximum_object_size 700 MB
minimum_object_size 0 KB
cache_swap_low 90
cache_swap_high 95
cache_dir ufs /var/spool/squid 5000 16 256
refresh_pattern ^ftp: 15 2% 2280
refresh_pattern ^gother: 15 0% 2280
refresh_pattern . 15 20% 2280
cache_effective_user squid
cache_access_log /var/log/squid/access.log
acl all src 0.0.0.0/0.0.0.0
acl manager proto cache_object
acl localhost src 127.0.0.1/255.255.255.255
acl SSL_ports port 443 563
acl Safe_ports port 80 # http
acl Safe_ports port 21 # ftp
acl Safe_ports port 443 563 # https, snews
acl Safe_ports port 70 # gopher
acl Safe_ports port 210 # wais
acl Safe_ports port 1025-65535 # unregistered pors
acl Safe_ports port 280 # http-mgmt
acl Safe_ports port 488 # gss-http
acl Safe_ports port 591 # filemaker
acl Safe_ports port 777 # multiling http
acl Safe_ports port 901 # SWAT
acl purge method PURGE
acl CONNECT method CONNECT
http_access allow manager localhost
http_access deny manager
http_access allow purge localhost
http_access deny purge
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
acl permitidos src 10.0.0.5
acl redelocal src 10.0.0.0/8
http_access allow localhost
http_access allow permitidos
acl proibidos url_regex "/etc/squid/proibidos"
acl excecoes url_regex "/etc/squid/excecoes"
http_access deny proibidos !excecoes
acl exe url_regex -i .exe
acl zip url_regex -i .zip
acl rar url_regex -i .rar
acl scr url_regex -i .scr
acl msi url_regex -i .msi
acl wmv url_regex -i .wmv
acl pif url_regex -i .pif
acl avi url_regex -i .avi
http_access deny exe !excecoes
http_access deny zip !excecoes
http_access deny rar !excecoes
http_access deny scr !excecoes
http_access deny msi !excecoes
http_access deny wmv !excecoes
http_access deny pif !excecoes
http_access deny avi !excecoes
http_access allow redelocal
http_access deny all
httpd_accel_host virtual
httpd_accel_port 80
httpd_accel_with_proxy on
httpd_accel_uses_host_header on
Arquivo FIREWALL
#!/bin/bash
firewall_start(){
iptables -A INPUT -s 10.0.0.0/255.0.0.0 -j ACCEPT
iptables -A INPUT -p tcp --destination-port 22 -j ACCEPT
iptables -A INPUT -p tcp --destiantion-port 10000 -j ACCEPT
echo "1" > /proc/sys/net/ipv4/icmp_echo_ignore_all
echo 1 > /proc/sys/net/ipv4/conf/default/rp_filter
echo "1" > /proc/sys/net/ipv4/tcp_syncookies
echo "1" > /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts
iptables -A INPUT -p udp --dport 33435:33525 -j DROP
iptables -A FORWARD -p icmp --icmp-type echo-request -m limit --limit 1/s -j ACCEPT
iptables -A FORWARD -p tcp -m limit --limit 1/s -j ACCEPT
iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -p tcp --tcp-flags SYN,ACK,FIN,RST RST -m limit --limit 1/s -j ACCEPT
iptables -A FORWARD --protocol tcp --tcp-flags ALL SYN,ACK -j DROP
iptables -A FORWARD -m unclean -j DROP
iptables -A INPUT -m state --state INVALID -j DROP
iptables -N VALID_CHECK
iptables -A VALID_CHECK -p tcp --tcp-flags ALL FIN,URG,PSH -j DROP
iptables -A VALID_CHECK -p tcp --tcp-flags ALL SYN,RST,ACK,FIN,URG -j DROP
iptables -A VALID_CHECK -p tcp --tcp-flags ALL ALL -j DROP
iptables -A VALID_CHECK -p tcp --tcp-flags ALL FIN -j DROP
iptables -A VALID_CHECK -p tcp --tcp-flags SYN,RST SYN,RST -j DROP
iptables -A VALID_CHECK -p tcp --tcp-flags SYN,FIN SYN,FIN -j DROP
iptables -A VALID_CHECK -p tcp --tcp-flags ALL NONE -j DROP
iptables -A INPUT -p tcp --syn -s 127.0.0.1/255.0.0.0 -j ACCEPT
iptables -A INPUT -i lo -j ACCEPT
iptables -A INPUT -p udp -s 127.0.0.1/255.0.0.0 -j ACCEPT
iptables -A INPUT -p udp --dport 1:1024 -j DROP
iptables -A INPUT -p udp --dport 59229 -j DROP
iptables -A INPUT -p tcp --syn -j DROP
/etc/skel-fix/firewall-msg
}
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 "O firewall está¡ sendo desativado"
sleep 2
echo "ok."
;;
"restart")
echo "O firewall está¡ sendo desativado"
sleep 1
echo "ok."
firewall_stop; firewall_start
;;
*)
iptables -L -n
esac
modprobe iptable_nat
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -I POSTROUTING -o eth0 -j MASQUERADE
iptables -t nat -A PREROUTING -i eth1 -p tcp --dport 80 -j REDIRECT --to-port 3128
iptables -A INPUT -p TCP -s 0/0 -d 10.0.0.1 --dport 3128 -m state --state NEW -j ACCEPT
iptables -t nat -A PREROUTING -i eth1 -p tcp --dport 80 -j REDIRECT --to-port 3128
Me ajudem......... Obrigado
Arquivo squid.conf
http_port 3128
visible_hostname agata
cache_mem 64 MB # quantidade da cache usada na memória ram,
maximum_object_size_in_memory 64 KB
maximum_object_size 700 MB
minimum_object_size 0 KB
cache_swap_low 90
cache_swap_high 95
cache_dir ufs /var/spool/squid 5000 16 256
refresh_pattern ^ftp: 15 2% 2280
refresh_pattern ^gother: 15 0% 2280
refresh_pattern . 15 20% 2280
cache_effective_user squid
cache_access_log /var/log/squid/access.log
acl all src 0.0.0.0/0.0.0.0
acl manager proto cache_object
acl localhost src 127.0.0.1/255.255.255.255
acl SSL_ports port 443 563
acl Safe_ports port 80 # http
acl Safe_ports port 21 # ftp
acl Safe_ports port 443 563 # https, snews
acl Safe_ports port 70 # gopher
acl Safe_ports port 210 # wais
acl Safe_ports port 1025-65535 # unregistered pors
acl Safe_ports port 280 # http-mgmt
acl Safe_ports port 488 # gss-http
acl Safe_ports port 591 # filemaker
acl Safe_ports port 777 # multiling http
acl Safe_ports port 901 # SWAT
acl purge method PURGE
acl CONNECT method CONNECT
http_access allow manager localhost
http_access deny manager
http_access allow purge localhost
http_access deny purge
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
acl permitidos src 10.0.0.5
acl redelocal src 10.0.0.0/8
http_access allow localhost
http_access allow permitidos
acl proibidos url_regex "/etc/squid/proibidos"
acl excecoes url_regex "/etc/squid/excecoes"
http_access deny proibidos !excecoes
acl exe url_regex -i .exe
acl zip url_regex -i .zip
acl rar url_regex -i .rar
acl scr url_regex -i .scr
acl msi url_regex -i .msi
acl wmv url_regex -i .wmv
acl pif url_regex -i .pif
acl avi url_regex -i .avi
http_access deny exe !excecoes
http_access deny zip !excecoes
http_access deny rar !excecoes
http_access deny scr !excecoes
http_access deny msi !excecoes
http_access deny wmv !excecoes
http_access deny pif !excecoes
http_access deny avi !excecoes
http_access allow redelocal
http_access deny all
httpd_accel_host virtual
httpd_accel_port 80
httpd_accel_with_proxy on
httpd_accel_uses_host_header on
Arquivo FIREWALL
#!/bin/bash
firewall_start(){
iptables -A INPUT -s 10.0.0.0/255.0.0.0 -j ACCEPT
iptables -A INPUT -p tcp --destination-port 22 -j ACCEPT
iptables -A INPUT -p tcp --destiantion-port 10000 -j ACCEPT
echo "1" > /proc/sys/net/ipv4/icmp_echo_ignore_all
echo 1 > /proc/sys/net/ipv4/conf/default/rp_filter
echo "1" > /proc/sys/net/ipv4/tcp_syncookies
echo "1" > /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts
iptables -A INPUT -p udp --dport 33435:33525 -j DROP
iptables -A FORWARD -p icmp --icmp-type echo-request -m limit --limit 1/s -j ACCEPT
iptables -A FORWARD -p tcp -m limit --limit 1/s -j ACCEPT
iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -p tcp --tcp-flags SYN,ACK,FIN,RST RST -m limit --limit 1/s -j ACCEPT
iptables -A FORWARD --protocol tcp --tcp-flags ALL SYN,ACK -j DROP
iptables -A FORWARD -m unclean -j DROP
iptables -A INPUT -m state --state INVALID -j DROP
iptables -N VALID_CHECK
iptables -A VALID_CHECK -p tcp --tcp-flags ALL FIN,URG,PSH -j DROP
iptables -A VALID_CHECK -p tcp --tcp-flags ALL SYN,RST,ACK,FIN,URG -j DROP
iptables -A VALID_CHECK -p tcp --tcp-flags ALL ALL -j DROP
iptables -A VALID_CHECK -p tcp --tcp-flags ALL FIN -j DROP
iptables -A VALID_CHECK -p tcp --tcp-flags SYN,RST SYN,RST -j DROP
iptables -A VALID_CHECK -p tcp --tcp-flags SYN,FIN SYN,FIN -j DROP
iptables -A VALID_CHECK -p tcp --tcp-flags ALL NONE -j DROP
iptables -A INPUT -p tcp --syn -s 127.0.0.1/255.0.0.0 -j ACCEPT
iptables -A INPUT -i lo -j ACCEPT
iptables -A INPUT -p udp -s 127.0.0.1/255.0.0.0 -j ACCEPT
iptables -A INPUT -p udp --dport 1:1024 -j DROP
iptables -A INPUT -p udp --dport 59229 -j DROP
iptables -A INPUT -p tcp --syn -j DROP
/etc/skel-fix/firewall-msg
}
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 "O firewall está¡ sendo desativado"
sleep 2
echo "ok."
;;
"restart")
echo "O firewall está¡ sendo desativado"
sleep 1
echo "ok."
firewall_stop; firewall_start
;;
*)
iptables -L -n
esac
modprobe iptable_nat
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -I POSTROUTING -o eth0 -j MASQUERADE
iptables -t nat -A PREROUTING -i eth1 -p tcp --dport 80 -j REDIRECT --to-port 3128
iptables -A INPUT -p TCP -s 0/0 -d 10.0.0.1 --dport 3128 -m state --state NEW -j ACCEPT
iptables -t nat -A PREROUTING -i eth1 -p tcp --dport 80 -j REDIRECT --to-port 3128
Me ajudem......... Obrigado