servidorlinux
(usa Debian)
Enviado em 12/01/2023 - 12:29h
Olá pessoal bom dia. Tudo bem?
Tenho aqui um servidor com Debian 11, duas placas de rede que é o gateway de uma rede wifi. Os bloqueios no iptables estão todos ok, está funcionando certinho. O problema está no Squid versão 4.13, quando configuro a linha http_port 3128 intercept e reinicio o Squid ele dá erro, conforme a imagem em anexo. Se eu tiro o intercept http_port 3128 e reinicio o Squid não dá erro.
Todos os bloqueios estão no iptables. Só preciso do Squid para fazer cache. Minha intenção é configurar o Squid para ser transparente.
Por favor, o que pode estar errado?
Abaixo estão os arquivos de configuração do iptables e do Squid.
Desde já agradeço a todos pela ajuda.
===== iptables ======
#!/bin/sh
### BEGIN INIT INFO
# Provides: firewall
# Required-Start: $ifwan $iflocal $redelocal
# Required-Stop: $ifwan $iflocal $redelocal
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Firewall
# Description: Firewall da rede wifi dos alunos
#
### END INIT INFO
# Interface rede wan
ifwan="enp0s25"
# Interface rede local
iflocal="enp1s4"
# Rede Local
redelocal="10.0.0.0/23"
iniciar(){
# Regras basicas do firewall
iptables -A INPUT -i lo -j ACCEPT
iptables -A INPUT -p icmp --icmp-type echo-request -m limit --limit 1/s -j ACCEPT
echo 1 > /proc/sys/net/ipv4/conf/default/rp_filter
iptables -A INPUT -m state --state INVALID -j DROP
############################################
# Libera a porta do Squid
############################################
iptables -A INPUT -p tcp --dport 3128 -j ACCEPT
iptables -A OUTPUT -p tcp --dport 3128 -j ACCEPT
iptables -A FORWARD -p tcp --dport 3128 -j ACCEPT
iptables -t nat -A PREROUTING -i $iflocal -p tcp --dport 80 -j REDIRECT --to-port 3128
##############################################
#
# Permite conexões SSH na porta 2222
#
##############################################
iptables -I INPUT -p tcp --dport 2222 -j ACCEPT
##################################################
# Blocked Sites
##################################################
for site in $(cat /etc/init.d/blocked-sites.txt | grep -v "#")
do
iptables -I OUTPUT -p tcp -m multiport --dports 80,443,563 -s $redelocal -o $iflocal -m string --algo bm --string $site -j REJECT
iptables -I FORWARD -p tcp -m multiport --dports 80,443,563 -s $redelocal -i $iflocal -m string --algo bm --string $site -j REJECT
done
##################################################
# App's bloqueados nos smartphones
##################################################
for site2 in $(cat /etc/init.d/aps-bloqueados.txt | grep -v "#")
do
iptables -t filter -A OUTPUT -m string --algo bm --string $site2 -j LOG
iptables -t filter -I FORWARD -s $redelocal -m string --algo bm --string $site2 -j LOG
iptables -t filter -A OUTPUT -m string --algo bm --string $site2 -j REJECT
iptables -t filter -I FORWARD -s $redelocal -m string --algo bm --string $site2 -j REJECT
done
##################################################
# Sites permitidos
##################################################
for site3 in $(cat /etc/init.d/sites-permitidos.txt | grep -v "#")
do
iptables -I FORWARD -p tcp -m multiport --dports 80,443 -s $redelocal -i $iflocal -m string --algo bm --string $site3 -j ACCEPT
done
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -o $ifwan -j MASQUERADE
# Impede a abertura de novas conexões, bloqueando o acesso externo ao seu servidor,
# com excecao das portas e faixas de enderecos especificadas anteriormente
iptables -A INPUT -p tcp --syn -j DROP
echo "Regras de firewall ativadas"
echo ""
}
parar(){
iptables -F
iptables -t nat -F
iptables -P INPUT ACCEPT
iptables -P OUTPUT ACCEPT
echo 0 > /proc/sys/net/ipv4/ip_forward
echo "Regras de firewall e compartilhamento desativados"
}
case "$1" in
"start") iniciar ;;
"stop") parar ;;
"restart") parar; iniciar ;;
*) echo " Use os parâmetros start, stop ou restart"
esac
====Squid=====
http_port 10.0.0.1:3128
visible_hostname PROXY-ALUNOS
error_directory /usr/share/squid/errors/Portuguese
cache_mem 2048 MB
maximum_object_size_in_memory 128 KB
maximum_object_size 512 MB
minimum_object_size 127 KB
cache_swap_low 90
cache_swap_high 95
cache_dir ufs /var/spool/squid 10240 16 256
cache_access_log /var/log/squid/access.log
refresh_pattern ^ftp: 15 20% 2280
refresh_pattern ^gopher: 15 0% 2280
refresh_pattern . 15 20% 2280
acl SSL_ports port 443 563
acl Safe_ports port 21 80 443 563 70 210 280 488 59 777 901 1025-65535
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 rede_local src 10.0.0.0/23
acl direct url_regex -i "/etc/squid/direct.txt"
always_direct allow direct
http_access allow localhost
http_access allow rede_local
http_access deny all