kroger
(usa Ubuntu)
Enviado em 05/09/2008 - 16:48h
Estou usando:
Slackware 12 rodando: iptables, Squid, Samba PDC
Modem Adsl e duas placas de rede no servidor
Preciso forçar a rede interna 192.168.0.1 a passar pelo squid e deixar a 10.1.0.1 aberta sem restrições
Segue meus arquivos conf e rc
rc.network:
ifconfig eth0:0 192.168.0.1 netmask 255.255.255.0 up
ifconfig eth0:1 10.1.0.1 broadcast 10.1.0.255 netmask 255.0.0.0 up
dhcpd eth0
ifconfig eth1 192.168.254.1 netmask 255.255.255.0 up
echo 1 > /proc/sys/net/ipv4/ip_forward
rc.firewall:
#
iptables -F
iptables -F -t nat
iptables -A FORWARD -j LOG
#
# Liberando portas
# 22 - ssh (necessário para acessar o servidor)
# 25 - smtp (envio de email)
# 110 - pop3 (recebimento de email)
# 80 - http (páginas web)
# 443 - https (páginas seguras)
# 21 - ftp (transferências de arquivos)
echo "Definiçoes de portas principais..."
#
iptables -A FORWARD -s 192.168.0.0/24 -p tcp --dport 21 -j ACCEPT
iptables -A FORWARD -s 192.168.0.0/24 -p tcp --dport 25 -j ACCEPT
iptables -A FORWARD -s 192.168.0.0/24 -p tcp --dport 110 -j ACCEPT
iptables -A FORWARD -s 192.168.0.0/24 -p udp --dport 53 -j ACCEPT
iptables -A FORWARD -s 192.168.0.0/24 -p tcp --dport 80 -j ACCEPT
iptables -A FORWARD -s 192.168.0.0/24 -p udp --dport 443 -j ACCEPT
iptables -A FORWARD -s 192.168.0.0/24 -p icmp -j ACCEPT
#
iptables -A FORWARD -s 10.1.0.0/24 -p tcp --dport 21 -j ACCEPT
iptables -A FORWARD -s 10.1.0.0/24 -p tcp --dport 25 -j ACCEPT
iptables -A FORWARD -s 10.1.0.0/24 -p tcp --dport 110 -j ACCEPT
iptables -A FORWARD -s 10.1.0.0/24 -p udp --dport 53 -j ACCEPT
iptables -A FORWARD -s 10.1.0.0/24 -p tcp --dport 80 -j ACCEPT
iptables -A FORWARD -s 10.1.0.0/24 -p udp --dport 443 -j ACCEPT
iptables -A FORWARD -s 10.1.0.0/24 -p icmp -j ACCEPT
#
# Acelerando portas do Samba
#
echo "Acelerando o Samba...QoS..."
iptables -t mangle -A INPUT -p tcp --dport 139 -j TOS --set-tos 16
iptables -t mangle -A INPUT -p tcp --dport 138 -j TOS --set-tos 16
iptables -t mangle -A INPUT -p udp --dport 137 -j TOS --set-tos 16
#
# Sites de bancos
#
echo "Sites Seguros."
#
iptables -A FORWARD -p tcp --dport 443 -j ACCEPT
iptables -A INPUT -p tcp --dport 443 -j ACCEPT
iptables -A OUTPUT -p tcp --dport 443 -j ACCEPT
#
echo "Sites do Governo e Certidões."
iptables -A INPUT -j ACCEPT -p tcp -i eth1 --sport 2631
iptables -A INPUT -j ACCEPT -p tcp -i eth1 --dport 2631
iptables -A INPUT -j ACCEPT -p tcp -i eth1 -s 200.201.174.0/24
iptables -A INPUT -j ACCEPT -p tcp -i eth1 -d 200.201.174.0/24
iptables -A INPUT -j ACCEPT -p tcp -i eth1 -s 200.201.0.0/16
iptables -A INPUT -j ACCEPT -p tcp -i eth1 -d 200.201.0.0/16
#Libera Porta RECEITA FEDERAL (ReceitaNET)
iptables -A INPUT -j ACCEPT -p tcp -i eth1 --sport 3456
iptables -A INPUT -j ACCEPT -p tcp -i eth1 --dport 3456
#Libera Porta CAT-INSS
iptables -A INPUT -j ACCEPT -p tcp -i eth1 --sport 5017
iptables -A INPUT -j ACCEPT -p tcp -i eth1 --dport 5017
#Libera Porta SINTEGRA / POSTO FISCAL
iptables -A INPUT -j ACCEPT -p tcp -i eth1 --sport 8017
iptables -A INPUT -j ACCEPT -p tcp -i eth1 --dport 8017
#
echo "Windows Update."
# Liberando acesso ao Windows Update
#iptables -A FORWARD -d 207.46.209.122 -p tcp --dport 80 -j ACCEPT
#iptables -A FORWARD -d 64.4.21.91 -p tcp --dport 80 -j ACCEPT
#iptables -A FORWARD -d 200.171.222.93 -p tcp --dport 86 -j ACCEPT
#
# Regras de Bloqueio
echo "Aplicando Regras de segurança..."
iptables -A FORWARD -s 192.168.0.0/24 -p tcp --dport 1863 -j REJECT
iptables -I FORWARD -s 192.168.0.0/24 -m string --algo bm --string "gateway.dll" -j DROP
iptables -I FORWARD -s 192.168.0.0/24 -m string --algo bm --string "e-messenger.net" -j DROP
iptables -I FORWARD -s 192.168.0.0/24 -m string --algo bm --string "meebo.com" -j DROP
iptables -I FORWARD -s 192.168.0.0/24 -m string --algo bm --string "messenger.msn.com" -j DROP
iptables -I FORWARD -s 192.168.0.0/24 -m string --algo bm --string "clientless.net" -j DROP
iptables -I FORWARD -s 192.168.0.0/24 -m string --algo bm --string "wbmsn.net" -j DROP
iptables -I FORWARD -s 192.168.0.0/24 -m string --algo bm --string "msn2go.com" -j DROP
iptables -I FORWARD -s 192.168.0.0/24 -m string --algo bm --string "iloveim.com" -j DROP
iptables -I FORWARD -s 192.168.0.0/24 -m string --algo bm --string "info.sytes.net" -j DROP
iptables -I FORWARD -s 192.168.0.0/24 -m string --algo bm --string "x-msn-messenger" -j DROP
iptables -I FORWARD -s 192.168.0.0/24 -m string --algo bm --string "messenger.hotmail.com" -j DROP
iptables -I FORWARD -s 192.168.0.0/24 -m string --algo bm --string "loginnet.passport.com" -j DROP
#
# Bloqueando Orkut e Outros
iptables -I FORWARD -s 192.168.0.0/24 -m string --algo bm --string "www.orkut.com" -j DROP
iptables -I FORWARD -s 192.168.0.0/24 -m string --algo bm --string "orkut.com" -j DROP
iptables -I FORWARD -s 192.168.0.0/24 -m string --algo bm --string "https://orkut.com" -j DROP
iptables -I FORWARD -s 192.168.0.0/24 -m string --algo bm --string "powerscrap.com" -j DROP
iptables -I FORWARD -s 192.168.0.0/24 -m string --algo bm --string "userplane.com" -j DROP
#
# Bloqueando acessos suspeitos
iptables -A FORWARD -d 212.211.132.32 -p tcp --dport 80 -j DROP
iptables -A FORWARD -d 199.239.233.9 -p tcp --dport 80 -j DROP
iptables -A FORWARD -d 209.8.40.140 -p tcp --dport 80 -j DROP
iptables -A FORWARD -d 209.59.139.38 -p tcp --dport 80 -j DROP
iptables -A FORWARD -d 66.7.200.245 -p tcp -j DROP
iptables -A FORWARD -d 66.150.14.24 -p tcp --dport 80 -j DROP
iptables -A FORWARD -d 208.111.159.15 -p tcp --dport 80 -j DROP
#
# Bloqueia todo resto
iptables -A FORWARD -s 192.168.0.0/24 -j REJECT
iptables -A FORWARD -s 10.1.0.0/24 -j REJECT
#
#
echo "Aplicando Configurações..."
#iptables -A INPUT -s 192.168.0.0/24 -d 192.168.0.1/255.255.255.0 -p tcp -j ACCEPT
#iptables -A OUTPUT -s 192.168.0.0/24 -d 192.168.0.1/255.255.255.0 -j ACCEPT
iptables -A INPUT -s 192.168.0.0/24 -p tcp -d 192.168.254.254 -j ACCEPT
iptables -A OUTPUT -s 192.168.0.0/24 -p tcp -d 192.168.254.254 -j ACCEPT
iptables -A INPUT -s 10.1.0.0/24 -d 192.168.254.254 -p tcp -j ACCEPT
iptables -A OUTPUT -s 10.1.0.0/24 -d 0/0 -j ACCEPT
#
# Ativa routeamento
iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE
echo "Concluido."
squid.conf
http_port 3128
hierarchy_stoplist cgi-bin ?
acl QUERY urlpath_regex cgi-bin \?
no_cache deny QUERY
cache_mem 32 MB
cache_swap_low 90
cache_swap_high 95
maximum_object_size 4096 KB
cache_dir ufs /var/log/squid/cache 512 16 256
cache_access_log /var/log/squid/logs/access.log
ftp_user Squid@
visible_hostname server
acl RedeLocal src 192.168.0.0/24
acl MsnAllow src 10.1.0.0/24
acl sites dstdomain .cervejazul.com.br .inutilidades.hex.com.br .video.google.com .meebo.com .inutilidades.com.br .meebo.com.br .portaldovt.com.br .imaginarlo.com .ninjaproxy.com .playboy.com.br .sexy.com .video.msn.com .video.globo.com .orkut.com .powerscrap.com
acl extensoes urlpath_regex .wma$ .asf$ .mov$ .mpg$ .mpeg$ .avi$ .mp3$ .wav$ .mid$ .bat$ .scr$ .exe$
acl palavras url_regex -i talkx talk koolim mathtunnel safehazard meebo google-talk googletalk thecrims radiotuner iloveim msnanywhere proxify mastaline screensaver linkblog messbrasil ilovemessenger canalmsn meiobit mmclient centova tutorials1 contabilsantaizabel msnpiki msnfanatic youtube messengerfx sexo
[*****] filetransferenabled
acl MsnDominiosIP dst 216.32.66.235/255.255.255.255 72.21.057.0/255.255.255.0 207.46.110.0/255.255.255.0 62.116.121.0/255.255.255.0 64.12.163.0/255.255.255.0 205.188.179.0/255.255.255.0 205.188.213.0/255.255.255.0 62.116.83.62/255.255.255.255 69.36.226.0/255.255.255.0 216.129.112.0/255.255.255.0 216.129.113.0/255.255.255.0 65.216.115.0/255.255.255.0 85.184.4.0/255.255.255.0 193.238.160.0/255.255.255.0 72.36.146.0/255.255.255.0 209.34.241.0/255.255.255.0 64.92.172.108/255.255.255.255
acl MsnDominios dstdomain .imessenger.com .messenger.msn.com .messenger.hotmail.com .realtunnel.com .webmessenger.msn.com .webmessenger.com.br .e-messenger.com.br .e-messenger.net .msnmessenger.com .webmessenger.com .emessenger.com .iloveim.com .iloveim.com.br .ilovemessenger.com .akamai.net .akamaitech.net .hopster.com .meebo.com .meebo.com.br .wm.jabbernet.dk .imessenger.com.br .webmessenger.blitzaffe.com .leamonde.net .msngamecenter.com .msn2go.com .msnger.com .messenger.yahoo.com .cresce.net .messengerfx.com
acl localhost src 127.0.0.1/255.255.255.255
acl all src 0.0.0.0/0.0.0.0
acl manager proto cache_object
#Recommend minimum configuration
acl SSL_ports port 443 563 # https, snews
acl SSL_ports port 873 # rsync
acl Safe_ports port 80 # http
acl Safe_ports port 21 # ftp
acl Safe_ports port 443 563 10000 # https, snews
acl Safe_ports port 70 # gopher
acl Safe_ports port 210 # wais
acl Safe_ports port 1025-65535 # unregistered ports
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 631 # cups
acl Safe_ports port 873 # rsync
acl Safe_ports port 901 # SWAT
acl Java browser Java/1.4 /Java/1.5 Java/1.6
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
http_access deny palavras
http_access deny sites
http_access deny extensoes
#http_access allow MsnAllow
http_access deny MsnDominiosIP
http_access deny MsnDominios
http_access allow localhost
http_access allow RedeLocal
http_access deny all
#Limpeza automática do cache
#reference_age 1 week
#Definição para que não seja feito cachê de páginas seguras SSL
no_cache deny SSL_ports
Não consigo fazer a rede interna 192.168.0.0 navegar quando redireciono para o ip do servidor na porta do proxy.