canalli
(usa Ubuntu)
Enviado em 21/01/2013 - 19:52h
segue configuração do Iptables e Squid.conf
*Firewall*
#!/bin/bash
echo "Iniciando Firewall"
#ativar modulos
/sbin/modprobe iptable_nat
/sbin/modprobe ip_conntrack
/sbin/modprobe ip_conntrack_ftp
/sbin/modprobe ip_nat_ftp
/sbin/modprobe ipt_LOG
/sbin/modprobe ipt_REJECT
/sbin/modprobe ipt_MASQUERADE
echo "modulos carregados"
#zerar regras
/sbin/iptables -F
/sbin/iptables -X
/sbin/iptables -F -t nat
/sbin/iptables -X -t nat
/sbin/iptables -F -t mangle
/sbin/iptables -X -t mangle
iptables -P INPUT ACCEPT
iptables -P OUTPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -t nat -P PREROUTING ACCEPT
iptables -t nat -P POSTROUTING ACCEPT
echo "Flush de regras OK"
#Proxy Transparente
echo 1 > /proc/sys/net/ipv4/ip_forward
#nesta linha mascaramos os pacotes de saida para internet
/sbin/iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE
#nesta linha redireciona o trafego da porta 80 para o SQUID porta 3128
/sbin/iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 3128
echo "Carga do proxy transparente OK"
*squid.conf*
#Default:
# authenticate_cache_garbage_interval 1 hour
#Default:
# authenticate_ttl 1 hour
#Default:
# authenticate_ip_ttl 0 seconds
acl all src
acl manager proto cache_object
acl localhost src 127.0.1.1/32 ::1
acl to_localhost dst 127.0.0.0/8
# Example rule allowing access from your local networks.
# Adapt to list your (internal) IP networks from where browsing
# should be allowed
#acl localnet src 10.0.0.0/8 # RFC1918 possible internal network
#acl localnet src 172.16.0.0/12 # RFC1918 possible internal network
acl localnet src 192.168.0.0/24 # RFC1918 possible internal network
#acl lan src 192.168.0.0/255.255.255.0
#acl localnet src fc00::/7 # RFC 4193 local private network range
#acl localnet src fe80::/10 # RFC 4291 link-local (directly plugged) machines
acl SSL_ports port 443
acl Safe_ports port 80 # http
acl Safe_ports port 21 # ftp
acl Safe_ports port 443 # https
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 CONNECT method CONNECT
#Default:
# http_access deny all
#
# Only allow cachemgr access from localhost
http_access allow manager localhost
http_access allow localnet
http_access deny manager
# Deny requests to certain unsafe ports
http_access deny !Safe_ports
# Deny CONNECT to other than secure SSL ports
http_access deny CONNECT !SSL_ports
#http_access deny to_localhost
#
# INSERT YOUR OWN RULE(S) HERE TO ALLOW ACCESS FROM YOUR CLIENTS
#
#definir ips liberados
acl chefe src 192.168.1.10
#bloqueio fora do horario de trabalho
acl matutino time 08:00-12:00
acl vespertino time 13:30-17:30
#bloqueia acesso em periodos deferentes dos citados na acl
#http_access deny !matutino !vespertino
#bloqueio por extenções de arquivos
acl extencoes url_regex -i \.exe \.torrent
http_access deny extencoes
#bloqueio por palavras menos chefe
#acl palavras url_regex -i "/etc/squid/palavras.txt"
#http_access deny palavras !chefe
#acl liberados dstdomain "/etc/squid3/liberado"
#http_access allow liberados
#lista de bloqueios
acl bloqueados dstdomain "/etc/squid3/bloqueado"
http_access deny bloqueados vespertino
http_access deny bloqueados matutino
http_access allow localhost
# And finally deny all other access to this proxy
http_access allow all
#Default:
# icp_access deny all
#Default:
# htcp_access deny all
#Default:
# htcp_clr_access deny all
#Default:
# miss_access allow all
#Default:
# ident_lookup_access deny all
# NETWORK OPTIONS
# -----------------------------------------------------------------------------
http_port 3128
#Default:
cache_mem 128 MB
#Default:
# maximum_object_size_in_memory 512 KB
#Default:
# memory_replacement_policy lru
#Default:
# cache_replacement_policy lru
#
#Default:
# cache_swap_high 95
#Default:
# access_log /var/log/squid3/access.log squid
#Default:
# logfile_rotate 0
#Default:
# emulate_httpd_log off
#Default:
# log_ip_on_direct on
#Default:
# mime_table /usr/share/squid3/mime.conf
#Default:
# log_mime_hdrs off
#Default:
# pid_filename /var/run/squid3.pid
#Default:
log_fqdn off
#Default:
# client_netmask no_addr
#Default:
# none
#default:
# strip_query_terms on
#Default:
# buffered_logs off
#Default:
# netdb_filename /var/log/squid3/netdb.state
#Default:
# cache_log /var/log/squid3/cache.log
#Default:
# debug_options ALL,1
#Default:
# coredump_dir none
#Default:
# ftp_user Squid@
#Default:
# ftp_list_width 32
#Default:
# ftp_passive on
#Default:
# ftp_epsv_all off
#Default:
# ftp_epsv on
#Default:
# ftp_eprt on
#Default:
# ftp_sanitycheck on
#Default:
# ftp_telnet_protocol on
#Default:
# diskd_program /usr/lib/squid3/diskd
#Default:
# unlinkd_program /usr/lib/squid3/unlinkd
#Default:
# pinger_program /usr/lib/squid3/pinger
#Default:
# pinger_enable off
#Default:
# url_rewrite_children 5
#Default:
# url_rewrite_concurrency 0
#Default:
# url_rewrite_host_header on
#Default:
# url_rewrite_bypass off
# Add any of your own refresh_pattern entries above these.
refresh_pattern ^ftp: 1440 20% 10080
refresh_pattern ^gopher: 1440 0% 1440
refresh_pattern -i (/cgi-bin/|\?) 0 0% 0
refresh_pattern (Release|Packages(.gz)*)$ 0 20% 2880
# example lin deb packages
#refresh_pattern (\.deb|\.udeb)$ 129600 100% 129600
refresh_pattern . 0 20% 4320
# TAG: quick_abort_min (KB)
#Default:
# quick_abort_min 16 KB
# TAG: quick_abort_max (KB)
#Default:
# quick_abort_max 16 KB
#Default:
# read_ahead_gap 16 KB
#Default:
# negative_ttl 0 seconds
#Default:
# positive_dns_ttl 6 hours
#Default:
# negative_dns_ttl 1 minutes
#Default:
# range_offset_limit 0 KB
#Default:
# minimum_expiry_time 60 seconds
#Default:
# store_avg_object_size 13 KB
#Default:
# store_objects_per_bucket 20
#Default:
# request_header_max_size 64 KB
#Default:
# reply_header_max_size 64 KB
#Default:
# request_body_max_size 0 KB
#Default:
# client_request_buffer_max_size 512 KB
#Default:
# chunked_request_body_max_size 64 KB
#Default:
# icap_uses_indirect_client on
#Default:
# via on
#Default:
# ie_refresh off
#Default:
# vary_ignore_expire off
#Default:
# request_entities off
#Default:
# relaxed_header_parser on
#Default:
# ignore_expect_100 off
#Default:
# forward_timeout 4 minutes
#Default:
# connect_timeout 1 minute
#Default:
# peer_connect_timeout 30 seconds
#Default:
# read_timeout 15 minutes
#Default:
# request_timeout 5 minutes
#Default:
# persistent_request_timeout 2 minutes
#Default:
# client_lifetime 1 day
#Default:
# half_closed_clients off
#Default:
# pconn_timeout 1 minute
#Default:
# ident_timeout 10 seconds
#Default:
# shutdown_lifetime 30 seconds
#Default:
cache_mgr rafael.canalli@inovare.net
#Default:
# none
#Default:
# mail_program mail
#Default:
cache_effective_user proxy
#Default:
# httpd_suppress_version_string off
#Default:
visible_hostname squi_proxy
#Default:
# umask 027
#Default:
# announce_period 0
#Default:
# announce_host tracker.ircache.net
#Default:
# none
#Default:
# announce_port 3131
#Default:
# httpd_accel_surrogate_id unset-id
#Default:
# http_accel_surrogate_remote off
#Default:
# esi_parser custom
#Default:
# delay_pools 0
#Default:
# delay_initial_bucket_level 50
#Default:
# wccp_router any_addr
#Default:
# wccp_version 4
#Default:
# wccp2_rebuild_wait on
#Default:
# wccp2_forwarding_method gre
#Default:
# wccp2_return_method gre
#Default:
# wccp2_assignment_method hash
#Default:
# wccp2_service standard 0
#Default:
# wccp2_weight 10000
#Default:
# wccp_address 0.0.0.0
#Default:
# wccp2_address 0.0.0.0
#Default:
# client_persistent_connections on
#Default:
# server_persistent_connections on
#Default:
# persistent_connection_after_error on
#Default:
# detect_broken_pconn off
#Default:
# digest_generation on
#Default:
# digest_bits_per_entry 5
#Default:
# digest_rebuild_period 1 hour
#Default:
# digest_rewrite_period 1 hour
#Default:
# digest_swapout_chunk_size 4096 bytes
#Default:
# digest_rebuild_chunk_percentage 10
#Default:
# snmp_port 0
#Default:
# snmp_access deny all
#Default:
# snmp_incoming_address any_addr
#Default:
# snmp_outgoing_address no_addr
#Default:
# icp_port 0
#Default:
# htcp_port 0
#Default:
# log_icp_queries on
#Default:
# udp_incoming_address any_addr
#Default:
# udp_outgoing_address no_addr
#Default:
# icp_hit_stale off
#Default:
# minimum_direct_hops 4
#Default:
# minimum_direct_rtt 400
#Default:
# netdb_low 900
#Default:
# netdb_high 1000
#Default:
# netdb_ping_period 5 minutes
#Default:
# query_icmp off
#Default:
# test_reachability off
#Default:
# icp_query_timeout 0
#Default:
# maximum_icp_query_timeout 2000
#Default:
# minimum_icp_query_timeout 5
#Default:
# background_ping_rate 10 seconds
#Default:
# mcast_miss_addr no_addr
#Default:
# mcast_miss_ttl 16
#Default:
# mcast_miss_port 3135
#Default:
# mcast_miss_encode_key XXXXXXXXXXXXXXXX
#Default:
# mcast_icp_query_timeout 2000
#Default:
# icon_directory /usr/share/squid3/icons
#Default:
# global_internal_static on
#Default:
# short_icon_urls on
#Default:
# error_log_languages on
#Default:
# err_page_stylesheet /etc/squid3/errorpage.css
#Default:
# email_err_data on
#Default:
# nonhierarchical_direct on
#Default:
# prefer_direct off
# TAG: incoming_icp_average
#Default:
# incoming_icp_average 6
# TAG: incoming_http_average
#Default:
# incoming_http_average 4
# TAG: incoming_dns_average
#Default:
# incoming_dns_average 4
# TAG: min_icp_poll_cnt
#Default:
# min_icp_poll_cnt 8
# TAG: min_dns_poll_cnt
#Default:
# min_dns_poll_cnt 8
#Default:
# min_http_poll_cnt 8
#Default:
# client_ip_max_connections -1
#Default:
# tcp_recv_bufsize 0 bytes
#Default:
# icap_enable off
#Default:
# icap_service_failure_limit 10
#Default:
# icap_service_revival_delay 180
#Default:
# icap_preview_enable on
#Default:
# icap_preview_size -1
#Default:
# icap_default_options_ttl 60
#Default:
# icap_persistent_connections on
#Default:
# icap_send_client_ip off
#Default:
# icap_send_client_username off
#Default:
# icap_client_username_header X-Client-Username
#Default:
# icap_client_username_encode off
#Default:
# ecap_enable off
#Default:
# adaptation_service_iteration_limit 16
#Default:
# icap_retry deny all
#Default:
# icap_retry_limit 0
#Default:
# check_hostnames off
#Default:
# allow_underscore on
#Default:
# cache_dns_program /usr/lib/squid3/dnsserver
#Default:
# dns_children 5
#Default:
# dns_retransmit_interval 5 seconds
#Default:
# dns_timeout 2 minutes
#Default:
# dns_defnames off
#Default:
# hosts_file /etc/hosts
#Default:
# ignore_unknown_nameservers on
#Default:
# dns_v4_fallback on
#Default:
# dns_v4_first off
# TAG: ipcache_size (number of entries)
#Default:
# ipcache_size 1024
# TAG: ipcache_low (percent)
#Default:
# ipcache_low 90
# TAG: ipcache_high (percent)
# The size, low-, and high-water marks for the IP cache.
#Default:
# ipcache_high 95
# TAG: fqdncache_size (number of entries)
# Maximum number of FQDN cache entries.
#Default:
# fqdncache_size 1024
#Default:
# memory_pools on
#Default:
# memory_pools_limit 5 MB
#Default:
# forwarded_for on
#Default:
# client_db on
#Default:
# refresh_all_ims off
#Default:
# reload_into_ims off
#Default:
# maximum_single_addr_tries 1
#Default:
# retry_on_error off
#Default:
# as_whois_server whois.ra.net
#Default:
# offline_mode off
#Default:
# uri_whitespace strip
#Default:
balance_on_multiple_ip off
#Default:
# pipeline_prefetch off
#Default:
# high_response_time_warning 0
#Default:
# high_page_fault_warning 0
#Default:
# high_memory_warning 0 KB
#Default:
# sleep_after_fork 0
#Default:
# windows_ipaddrchangemonitor on
#Default:
# max_filedescriptors 0