Squid + Iptables - Combinação Infalível

Neste artigo, veremos como criar um Firewall e Proxy com autenticação para uma rede pequena, e também,
veremos como debugar alguns erros que podem acontecer no dia a dia.

[ Hits: 145.958 ]

Por: Phillip Vieira em 13/03/2012


Sarg



O Sarg é o programa responsável por gerar os relatórios bonitinhos do que foi acessado, ele mostra o que foi acessado, o que foi negado, gera estatísticas de tempo de acesso, etc.

Os arquivos de configuração do Sarg, quando instalado pelo APT-GET, ficam dentro de “/etc/squid”, não confundam com o diretório “/etc/squid3”.

Vamos então, configurar o Sarg através do arquivo “sarg.conf”.

Lembrando que, aqui estou colocando o arquivo original (/etc/squid/sarg.conf), e que também vou comentar somente as principais linhas, portanto, o restante das configurações ficam a seu critério:

# sarg.conf
#
# TAG:  language 
#	Available languages:
#		Bulgarian_windows1251
#		Catalan
#		Czech
#		Dutch
#		English
#		French
#		German
#		Greek
#		Hungarian
#		Indonesian
#		Italian
#		Japanese
#		Latvian
#		Polish
#		Portuguese
#		Romanian
#		Russian_koi8
#		Russian_UFT-8
#		Russian_windows1251
#		Serbian
#		Slovak
#		Spanish
#		Turkish
#
# VAMOS COLOCAR OS RELATÓRIOS EM PORTUGÊS
language Portuguese

# TAG:  access_log file
#       Where is the access.log file
#       sarg -l file
#
# ESTA LINHA INFORMA ONDE O SARG VAI BUSCAR OS LOGS DO SQUID
access_log /var/log/squid3/access.log

# TAG: graphs yes|no
#	Use graphics where is possible.
#           graph_days_bytes_bar_color blue|green|yellow|orange|brown|red
#
#graphs yes
#graph_days_bytes_bar_color orange

# TAG:	title
# 	Especify the title for html page.
#
# A LINHA ABAIXO DIZ RESPEITO AO NOME DA PÁGINA, ALTERE A SEU GOSTO
title "Squid User Access Reports"

# TAG:	font_face
# 	Especify the font for html page.
#
font_face Tahoma,Verdana,Arial

# TAG:	header_color
# 	Especify the header color
#
header_color darkblue

# TAG:	header_bgcolor
# 	Especify the header bgcolor
#
header_bgcolor blanchedalmond

# TAG:	font_size
# 	Especify the text font size
#
font_size 9px

# TAG:	header_font_size
# 	Especify the header font size
#
#header_font_size 9px

# TAG:	title_font_size
# 	Especify the title font size
#
#title_font_size 11px

# TAG:	background_color
# TAG:	background_color
#	Html page background color
#
background_color white

# TAG:	text_color
#	Html page text color
#
text_color #000000

# TAG:	text_bgcolor
#	Html page text background color
#
text_bgcolor lavender

# TAG:	title_color
#	Html page title color
#
title_color green

# TAG:	logo_image
#	Html page logo.
#
#logo_image none

# TAG:	logo_text
#	Html page logo text.
#
#logo_text ""

# TAG:	logo_text_color
#	Html page logo texti color.
#
#logo_text_color #000000

# TAG:	logo_image_size
#	Html page logo image size. 
#       width height
#
#image_size 80 45

# TAG:	background_image
#	Html page background image
#
#background_image none

# TAG:  password
#       User password file used by authentication
#       If used here, reports will be generated only for that users.
#
#password none

# TAG:  temporary_dir
#       Temporary directory name for work files
#       sarg -w dir
#
temporary_dir /tmp

# TAG:  output_dir
#       The reports will be saved in that directory
#       sarg -o dir
#
# A LINHA ABAIXO INFORMA ONDE SERÁ SALVO OS RELATÓRIOS GERADOS, APONTE PARA O SEU DIRETÓRIO WEB,
# QUE NO CASO DO DEBIAN É /var/www/ e o diretório, squid-reports
#output_dir /var/www/html/squid-reports
output_dir /var/www/squid-reports

# TAG:  output_email
#       Email address to send the reports. If you use this tag, no html reports will be generated.
#       sarg -e email
#
#output_email none

# TAG:  resolve_ip yes/no
#       Convert ip address to dns name
#       sarg -n
# QUANDO HABILITADO, RESOLVE IP EM NOME
resolve_ip  yes

# TAG:  user_ip yes/no
#       Use Ip Address instead userid in reports.
#       sarg -p
# A LINHA ABAIXO INFORMA SE VOCÊ QUER OBTER O IP DO USUÁRIO NO CASO EU DEIXEI COMO "no" POIS
# IREMOS VER OS RELATÓRIOS POR USUÁRIOS
user_ip no

# TAG:  topuser_sort_field field normal/reverse
#       Sort field for the Topuser Report.
#       Allowed fields: USER CONNECT BYTES TIME
#
topuser_sort_field BYTES reverse

# TAG:  user_sort_field field normal/reverse
#       Sort field for the User Report.
#       Allowed fields: SITE CONNECT BYTES TIME
#
user_sort_field BYTES reverse

# TAG:  exclude_users file
#       users within the file will be excluded from reports.
#       you can use indexonly to have only index.html file.
#
# A LINHA ABAIXO DIZ RESPEITO AO ARQUIVO ONDE CONSTAM OS USUÁRIOS QUE NÃO TERÃO RELATÓRIOS
exclude_users /etc/squid/sarg.users

# TAG:  exclude_hosts file
#       Hosts, domains or subnets will be excluded from reports.
#
#       Eg.: 192.168.10.10 - exclude ip address only
#            192.168.10.0  - exclude full C class
#            s1.acme.foo   - exclude hostname only
#            acme.foo      - exclude full domain name
#
exclude_hosts /etc/squid/sarg.hosts

# TAG:  useragent_log file
#       useragent.log file patch to generate useragent report.
#
#useragent_log none

# TAG:  date_format
#       Date format in reports: e (European=dd/mm/yy), u (American=mm/dd/yy), w (Weekly=yy.ww)
#       
date_format u

# TAG:  per_user_limit file MB
#       Saves userid on file if download exceed n MB.
#       This option allow you to disable user access if user exceed a download limit.
#       
#per_user_limit none

# TAG: lastlog n
#      How many reports files must be keept in reports directory.
#      The oldest report file will be automatically removed.
#      0 - no limit.
#
lastlog 0

# TAG: remove_temp_files yes
#      Remove temporary files: geral, usuarios, top, periodo from root report directory.
#
# REMOVE ARQUIVOS TEMPORÁRIOS, SE VOCÊ HABILITAR ESTA OPÇÃO CORRE O RISCO DE ENCHER O DISCO
remove_temp_files yes

# TAG: index yes|no|only
#      Generate the main index.html.
#      only - generate only the main index.html
#
index yes

# TAG: index_tree date|file
#      How to generate the index.
#
index_tree file

# TAG: overwrite_report yes|no
#      yes - if report date already exist then will be overwrited.
#       no - if report date already exist then will be renamed to filename.n, filename.n+1
#
overwrite_report yes

# TAG: records_without_userid ignore|ip|everybody
#      What can I do with records without user id (no authentication) in access.log file ?
#
#      ignore - This record will be ignored.
#          ip - Use ip address instead. (default)
#   everybody - Use "everybody" instead.
#
records_without_userid ip

# TAG: use_comma no|yes
#      Use comma instead point in reports.
#      Eg.: use_comma yes => 23,450,110
#           use_comma no  => 23.450.110
#
use_comma yes

# TAG: mail_utility mail|mailx
#      Mail command to use to send reports via SMTP
#
mail_utility mailx

# TAG: topsites_num n
#      How many sites in topsites report.
#
topsites_num 100

# TAG: topsites_sort_order CONNECT|BYTES A|D
#      Sort for topsites report, where A=Ascendent, D=Descendent
#
topsites_sort_order CONNECT D

# TAG: index_sort_order A/D
#      Sort for index.html, where A=Ascendent, D=Descendent
#
index_sort_order D

# TAG: exclude_codes file
#      Ignore records with these codes. Eg.: NONE/400
#
exclude_codes /etc/squid/sarg.exclude_codes

# TAG: replace_index string
#      Replace "index.html" in the main index file with this string
#      If null "index.html" is used 
#
#replace_index 

# TAG: max_elapsed milliseconds
#      If elapsed time is recorded in log is greater than max_elapsed use 0 for elapsed time.
#      Use 0 for no checking 
#
#max_elapsed 0
# 8 Hours
max_elapsed 28800000

# TAG: report_type type
#      What kind of reports to generate.
#      topusers            - users, sites, times, bytes, connects, links to accessed sites, etc
#      topsites		   - site, connect and bytes report
#      sites_users	   - users and sites report
#      users_sites	   - accessed sites by the user report
#      date_time	   - bytes used per day and hour report
#      denied		   - denied sites with full URL report
#      auth_failures       - autentication failures report
#      site_user_time_date - sites, dates, times and bytes report
#      downloads           - downloads per user report
#
#      Eg.: report_type topsites denied 
#
#report_type topusers topsites sites_users users_sites date_time denied auth_failures site_user_time_date downloads
report_type topusers topsites sites_users users_sites date_time denied auth_failures site_user_time_date downloads

# TAG: usertab filename
#      You can change the "userid" or the "ip address" to be a real user name on the reports.
#      Table syntax:
# 		userid name   or   ip address name
#      Eg:
#		SirIsaac Isaac Newton
#		vinci Leonardo da Vinci
#		192.168.10.1 Karol Wojtyla
#      
#      Each line must be terminated with '\n'
#
usertab /etc/squid/sarg.usertab

# TAG: long_url yes|no
#      If yes, the full url is showed in report.
#      If no, only the site will be showed
#
#      YES option generate very big sort files and reports.
#
# AQUI ELE DIZ SOBRE SE VOCÊ QUER VER OS ENDEREÇOS NOS RELATÓRIOS NO MODO CURTO
# OU A URL INTEIRA, COM POR EXEMPLO

# Modo curto: meusite.com
# Modo extenso: meusite.com/aplicacoes/aplicacao1
long_url no

# TAG: date_time_by bytes|elap
#      Date/Time reports will use bytes or elapsed time?
#
date_time_by bytes

# TAG: charset name
#      ISO 8859 is a full series of 10 standardized multilingual single-byte coded (8bit)
#      graphic character sets for writing in alphabetic languages
#      You can use the following charsets:
#		Latin1 		- West European
#		Latin2 		- East European 
#		Latin3 		- South European 
#		Latin4 		- North European 
#		Cyrillic 
#		Arabic 
#		Greek 
#		Hebrew 
#		Latin5 		- Turkish 
#		Latin6
#		Windows-1251
#		Koi8-r
#
charset Latin1

# TAG: user_invalid_char "&/"
#      Records that contain invalid characters in userid will be ignored by Sarg.
#
#user_invalid_char "&/"

# TAG: privacy yes|no
#      privacy_string "***.***.***.***"
#      privacy_string_color blue
#      In some countries the sysadm cannot see the visited sites by a restrictive law.
#      Using privacy yes the visited url will be changes by privacy_string and the link
#      will be removed from reports.
#
#privacy no
#privacy_string "***.***.***.***"
#privacy_string_color blue

# TAG: include_users "user1:user2:...:usern"
#      Reports will be generated only for listed users.
#
#include_users none

# TAG: exclude_string "string1:string2:...:stringn"
#      Records from access.log file that contain one of listed strings will be ignored.
#
#exclude_string none

# TAG: show_successful_message yes|no
#      Shows "Successful report generated on dir" at end of process.
#
show_successful_message no

# TAG: show_read_statistics yes|no
#      Shows some reading statistics.
#
show_read_statistics no

# TAG: topuser_fields
#      Which fields must be in Topuser report.
#
topuser_fields NUM DATE_TIME USERID CONNECT BYTES %BYTES IN-CACHE-OUT USED_TIME MILISEC %TIME TOTAL AVERAGE

# TAG: user_report_fields
#      Which fields must be in User report.
#
user_report_fields CONNECT BYTES %BYTES IN-CACHE-OUT USED_TIME MILISEC %TIME TOTAL AVERAGE

# TAG: topuser_num n
#      How many users in topsites report. 0 = no limit
#
topuser_num 0

# TAG: site_user_time_date_type list|table
#      generate reports for site_user_time_date in list or table format
#
site_user_time_date_type table

# TAG: datafile file
#      Save the report results in a file to populate some database
#
#datafile none

# TAG: datafile_delimiter ";"
#      ascii character to use as a field separator in datafile
#
#datafile_delimiter ";"

# TAG: datafile_fields all
#      Which data fields must be in datafile
#      user;date;time;url;connect;bytes;in_cache;out_cache;elapsed
#
#datafile_fields user;date;time;url;connect;bytes;in_cache;out_cache;elapsed

# TAG: datafile_url ip|name
#      Saves the URL as ip or name in datafile
#
#datafile ip

# TAG: weekdays
#      The weekdays to take account ( Sunday->0, Saturday->6 )
# Example:
#weekdays 1-3,5
# Default:
#weekdays 0-6

# TAG: hours
#      The hours to take account
# Example:
#hours 7-12,14,16,18-20
# Default:
#hours 0-23

# TAG: dansguardian_conf file
#      DansGuardian.conf file path
#      Generate reports from DansGuardian logs.
#      Use 'none' to disable it.
#      dansguardian_conf /usr/dansguardian/dansguardian.conf
#
#dansguardian_conf none

# TAG: dansguardian_ignore_date on|off
#      Use 'on'  use the record even the date range is different from the used squid access.log file.
#      Use 'off' use the record only if the date range is in the used squid access.log file.
#
#dansguardian_ignore_date off

# TAG: squidguard_conf file
#      path to squidGuard.conf file
#      Generate reports from SquidGuard logs.
#      Use 'none' to disable.
#      You can use sarg -L filename to use an alternate squidGuard log.
#      squidguard_conf /usr/local/squidGuard/squidGuard.conf
#
#squidguard_conf none

# TAG: squidguard_ignore_date on|off
#      Use 'on'  use the record even the date range is different from the used squid access.log file.
#      Use 'off' use the record only if the date range is in the used squid access.log file.
#
#squidguard_ignore_date off

# TAG: squidguard_log_format
#      Format string SquidGuard logs.
#      REJIK       #year#-#mon#-#day# #hour# #list#:#tmp# #ip# #user# #tmp#/#tmp#/#url#/#end#
#      SQUIDGUARD  #year#-#mon#-#day# #hour# #tmp#/#list#/#tmp#/#tmp#/#url#/#tmp# #ip#/#tmp# #user# #end#
#squidguard_log_format #year#-#mon#-#day# #hour# #tmp#/#list#/#tmp#/#tmp#/#url#/#tmp# #ip#/#tmp# #user# #end#

# TAG: show_sarg_info yes|no
#      shows sarg information and site path on each report bottom
#
#show_sarg_info yes

# TAG: show_sarg_logo yes|no
#      shows sarg logo
#
#show_sarg_logo yes

# TAG: parsed_output_log directory
#      Saves the processed log in a sarg format after parsing the squid log file.
#      This is a way to dump all of the data structures out, after parsing from 
#      the logs (presumably this data will be much smaller than the log files themselves),
#      and pull them back in for later processing and merging with data from previous logs.
#
#parsed_output_log none

# TAG: parsed_output_log_compress /bin/gzip|/usr/bin/bzip2|nocompress
#      sarg logs compress util
#
#parsed_output_log_compress /bin/gzip

# TAG: displayed_values bytes|abbreviation
#      how the values will be displayed in reports.
#      eg. bytes  	-  209.526
#          abbreviation -  210K
#
#displayed_values bytes

# Report limits
# TAG: authfail_report_limit n
# TAG: denied_report_limit n
# TAG: siteusers_report_limit n
# TAG: squidguard_report_limit n
# TAG: user_report_limit n
# TAG: dansguardian_report_limit n
# TAG: download_report_limit n
#      report limits (lines).
#      '0' no limit
#
#authfail_report_limit 10
#denied_report_limit 10
#siteusers_report_limit 0
#squidguard_report_limit 10
#dansguardian_report_limit 10
#user_report_limit 10
#user_report_limit 50

# TAG: www_document_root dir
#     Where is your Web DocumentRoot
#     Sarg will create sarg-php directory with some PHP modules:
#     - sarg-squidguard-block.php - add urls from user reports to squidGuard DB
#
#www_document_root /var/www/html

# TAG: block_it module_url
#     This tag allow you to pass urls from user reports to a cgi or php module,
#     to be blocked by some Squid acl
#
#     Eg.: block_it /sarg-php/sarg-block-it.php
#     sarg-block-it is a php that will append a url to a flat file.
#     You must change /var/www/html/sarg-php/sarg-block-it to point to your file
#     in $filename variable, and chown to a httpd owner.
#
#     sarg will pass http://module_url?url=url
#
#block_it none

# TAG: external_css_file path
#     This tag allow internal sarg css override.
#     Sarg use theses style classes:
#     	.body		body class
#	.info		sarg information class, align=center
#	.title		title class, align=center
#	.header		header class, align:left
#	.header2	header class, align:right
#	.header3	header class, align:right
#	.text		text class, align:left
#	.data		table text class, align:right
#	.data2		table text class, align:right, border colors
#	.link  		link class
#
#     There is a sample in /usr/local/sarg/etc/css.tpl
#
#external_css_file none

# TAG: user_authentication yes|no
#     Allow user authentication in User Reports using .htaccess
#     Parameters:  
#	AuthUserFile 	- where the user password file is
#	AuthName	- authentication realm. Eg "Members Only"
#	AuthType	- authenticaion type - basic
#	Require		- authorized users to see the report.
#                                          %u - user report
#
# user_authentication no
# AuthUserFile /usr/local/sarg/passwd
# AuthName "SARG, Restricted Access"
# AuthType Basic
# Require user admin %u

# TAG: download_suffix "suffix,suffix,...,suffix"
#    file suffix to be considered as "download" in Download report.
#    Use 'none' to disable.    
#
download_suffix "zip,arj,bzip,gz,ace,doc,iso,adt,bin,cab,com,dot,drv$,lha,lzh,mdb,mso,ppt,rtf,src,shs,sys,exe,dll,mp3,avi,mpg,mpeg"

# TAG: ulimit n
#    The maximum number of open file descriptors to avoid "Too many open files" error message.
#    You need to run sarg as root to use ulimit tag.
#
#ulimit 20000

# TAG: ntlm_user_format username|domainname+username
#      NTLM users format.
#
#ntlm_user_format domainname+username

# TAG: realtime_refresh_time num sec
#      How many time to auto refresh the realtime report
#      0 = disable
#
# realtime_refresh_time 3

# TAG: realtime_access_log_lines num
#      How many last lines to get from access.log file 
#
# realtime_access_log_lines 1000

# TAG: realtime_types: GET,PUT,CONNECT,ICP_QUERY,POST
#      Which records must be in realtime report.
#
# realtime_types GET,PUT,CONNECT  

# TAG: realtime_unauthenticated_records: ignore|show
#      What to do with unauthenticated records in realtime report.
#
# realtime_unauthenticated_records: ignore

# TAG: byte_cost value no_cost_limit
#      Cost per byte.
#      Eg. byte_cost 0.01 100000000
#           per byte cost      = 0.01
#           bytes with no cost = 100 Mb
#      0 = disable
#
# byte_cost 0.01 50000000


Dicas

Bom, vamos entender melhor a linha: exclude_users /etc/squid/sarg.users

Dentro do arquivo "/etc/squid/sarg.users", deve constar os usuários que serão excluídos do relatório gerado pelo Sarg.

Caso você não queira gerar o relatório de algum usuário, insira o nome do usuário (1 por linha) dentro do arquivo citado.

Para gerar os relatórios automaticamente, insira a seguinte linha dentro do cron:

00 22 * * * /usr/sbin/sarg-reports today


Assim, será gerado o relatório todos os dias, às 22:00hs.
Página anterior     Próxima página

Páginas do artigo
   1. O que veremos neste artigo?
   2. IPtables
   3. Squid
   4. Squid.conf
   5. Sarg
   6. Debugando possíveis erros
Outros artigos deste autor

Iptables - Segurança total para sua rede

Linux e Windows - Prós e Contras

Instalando o Linux Fedora 8 no Notebook Positivo v53

Samba - Dançando conforme a música

Recuperando dados do Windows usando um live-CD

Leitura recomendada

O Mestre, o Tecnólogo e o Aprendiz

Bonding para Heartbeat + Bonding para DRBD + OCFS2 + Debian Squeeze

Aprisionamento Tecnológico

Instalando o Linux direto do HD

Criando um LiveCD do FreeBSD

  
Comentários
[1] Comentário enviado por blaiser em 13/03/2012 - 22:43h

Mandou bem garoto..



me fala ai. meu sarg com o passar dos dias ele gera uma zica no browse do tipo DIARIO MENSAL E ANUAL. que lance é esse?

[2] Comentário enviado por phrich em 13/03/2012 - 22:57h

Obrigado blaiser!

Bom no exemplo eu utilizei o parâmetro daily do sarg, que gera os relatórios separados por dia, se vc der o comando sarg sem nenhum argumento, ele salva o relatório do que estiver no arquivo de log do squid até o momento e não mostra mais as opções de diário, semanal,etc.

Para você ver um pouco mais dos parâmetro disponíveis no sarg, consulte o manual com:

# man sarg

[3] Comentário enviado por cirinho em 16/04/2012 - 19:52h

Está "bugadão" os scripts e .conf

Eu não conseguir visualizar nada, está tudo junto. Não teve espaços nem quebra de linha. Assim fica difícil de entender, ficou bagunçado.

Não sei se o problema foi quando vc enviou se já veio assim, ou se foram os moderadores ao postar. Bom há também a possibilidade do problema ser cmgo.

[4] Comentário enviado por phrich em 16/04/2012 - 19:59h

Aqui aparece normal...

Talvez tenha dado erro no script do site na hora em que vc abriu... recarregue a página.

[5] Comentário enviado por Thiago Emannuel em 19/04/2012 - 09:43h

Na minha configuracao ta dando erro na linha

acl rede_interna 10.0.0.0/24

segue meu interfaces

thiago@ORBITA:~$ su
Senha:
root@ORBITA:/home/thiago# cd /etc/squid/
root@ORBITA:/etc/squid# ls
acls grupos sarg.conf.bak squid.conf squid.conf.bak
root@ORBITA:/etc/squid# vim squid.conf
root@ORBITA:/etc/squid# /etc/init.d/squid restart
Restarting Squid HTTP proxy: squid2012/04/19 08:43:19| Parsing Config File: Unknown authentication scheme 'bacis'.
2012/04/19 08:43:19| Invalid Proxy Auth ACL 'acl internal_lan proxy_auth REQUIRED' because no authentication schemes are fully configured.
FATAL: Bungled squid.conf line 28: acl internal_lan proxy_auth REQUIRED
Squid Cache (Version 2.7.STABLE9): Terminated abnormally.
failed!
root@ORBITA:/etc/squid# cd grupos
root@ORBITA:/etc/squid/grupos# ls
moderado restrito total
root@ORBITA:/etc/squid/grupos# cat moderado
luiz.gonzaga:Mx7QbjJ4GmQp.
joaquim.juliao:aT5SmGf6ie/xY
root@ORBITA:/etc/squid/grupos# cat restrito
armando.reis:ny9XYfx8Jhix2
arthur.reis:EUXdsh0ttW.ac
root@ORBITA:/etc/squid/grupos# cat total
thiago.emannuel:xvLjfWqFsQVxk
amanda.reis:ttlNeoctSsT.c
root@ORBITA:/etc/squid/grupos#
root@ORBITA:/etc/squid/grupos# cd ..
root@ORBITA:/etc/squid# vim squid.conf
root@ORBITA:/etc/squid# ls
acls grupos sarg.conf.bak squid.conf squid.conf.bak
root@ORBITA:/etc/squid# htpasswd -c /etc/squid/grupos/Administradores thiago.emannuel
New password:
Re-type new password:
Adding password for user thiago.emannuel
root@ORBITA:/etc/squid# cd grupos/
root@ORBITA:/etc/squid/grupos# ls
Administradores moderado restrito total
root@ORBITA:/etc/squid/grupos# cat Administradores
thiago.emannuel:2HItEIt3cqFDk
root@ORBITA:/etc/squid/grupos# cd ..
root@ORBITA:/etc/squid# vim squid.conf
root@ORBITA:/etc/squid# /etc/init.d/squid restart
Restarting Squid HTTP proxy: squid2012/04/19 08:52:13| Parsing Config File: Unknown authentication scheme 'bacis'.
2012/04/19 08:52:13| Invalid Proxy Auth ACL 'acl internal_lan proxy_auth REQUIRED' because no authentication schemes are fully configured.
FATAL: Bungled squid.conf line 28: acl internal_lan proxy_auth REQUIRED
Squid Cache (Version 2.7.STABLE9): Terminated abnormally.
failed!
root@ORBITA:/etc/squid# vim squid.conf
root@ORBITA:/etc/squid# /etc/init.d/squid restart
Restarting Squid HTTP proxy: squid2012/04/19 08:52:56| Parsing Config File: Unknown authentication scheme 'bacis'.
2012/04/19 08:52:56| Invalid Proxy Auth ACL 'acl Administradores proxy_auth "/etc/squid/grupos/Administradores"' because no authentication schemes are fully configured.
FATAL: Bungled squid.conf line 33: acl Administradores proxy_auth "/etc/squid/grupos/Administradores"
Squid Cache (Version 2.7.STABLE9): Terminated abnormally.
failed!
root@ORBITA:/etc/squid# vim squid.conf
root@ORBITA:/etc/squid# /etc/init.d/squid restart
Restarting Squid HTTP proxy: squid2012/04/19 08:54:17| Parsing Config File: Unknown authentication scheme 'bacis'.
2012/04/19 08:54:17| Invalid Proxy Auth ACL 'acl total proxy_auth "/etc/squid/grupos/total"' because no authentication schemes are fully configured.
FATAL: Bungled squid.conf line 36: acl total proxy_auth "/etc/squid/grupos/total"
Squid Cache (Version 2.7.STABLE9): Terminated abnormally.
failed!
root@ORBITA:/etc/squid#
root@ORBITA:/etc/squid# vim squid.conf
root@ORBITA:/etc/squid# /etc/init.d/squid restart
Restarting Squid HTTP proxy: squid2012/04/19 09:02:40| strtokFile: /etc/squid/acls/palavras_permitidas not found
2012/04/19 09:02:40| aclParseAclLine: WARNING: empty ACL: acl palavras_permitidas url_regex "/etc/squid/acls/palavras_permitidas"
2012/04/19 09:02:40| strtokFile: /etc/squid/acls/sites_restritos not found
2012/04/19 09:02:40| aclParseAclLine: WARNING: empty ACL: acl sites_restritos dstdomain "/etc/squid/acls/sites_restritos"
2012/04/19 09:02:40| aclParseAclLine: Invalid ACL type 'localhost'
FATAL: Bungled squid.conf line 63: acl to localhost dst 127.0.0.0/8
Squid Cache (Version 2.7.STABLE9): Terminated abnormally.
failed!
root@ORBITA:/etc/squid#










root@ORBITA:/etc/squid# ls
acls grupos sarg.conf.bak squid.conf squid.conf.bak
root@ORBITA:/etc/squid# cd acls/
root@ORBITA:/etc/squid/acls# ls
palavras_proibidas sites_restrito
root@ORBITA:/etc/squid/acls# vim palavras_proibidas
root@ORBITA:/etc/squid/acls#
















root@ORBITA:/etc/squid/acls# ls
palavras_proibidas sites_restrito
root@ORBITA:/etc/squid/acls# touch palavras_permitidas
root@ORBITA:/etc/squid/acls# ls
palavras_permitidas palavras_proibidas sites_restrito
root@ORBITA:/etc/squid/acls# cat palavras_proibidas
sexo*
jogo*
jogatina*
facebook*
youtube*
orkut*
messenger*
msn*
playboy*
root@ORBITA:/etc/squid/acls# vim palavras_permitidas
root@ORBITA:/etc/squid/acls# vim sites_restrito
root@ORBITA:/etc/squid/acls# vim /etc/squid/squid.conf
root@ORBITA:/etc/squid/acls# ls
palavras_permitidas palavras_proibidas sites_restrito
root@ORBITA:/etc/squid/acls#


root@ORBITA:/etc/squid/acls# /etc/init.d/squid restart
Restarting Squid HTTP proxy: squid2012/04/19 09:24:42| aclParseAclLine: Invalid ACL type 'localhost'
FATAL: Bungled squid.conf line 63: acl to localhost dst 127.0.0.0/8
Squid Cache (Version 2.7.STABLE9): Terminated abnormally.
failed!
root@ORBITA:/etc/squid/acls# vim /etc/squid/squid.conf
root@ORBITA:/etc/squid/acls# /etc/init.d/squid restart
Restarting Squid HTTP proxy: squid2012/04/19 09:25:57| aclParseAclLine: Invalid ACL type 'interna'
FATAL: Bungled squid.conf line 64: acl rede interna 10.0.0.0/24
Squid Cache (Version 2.7.STABLE9): Terminated abnormally.
failed!
root@ORBITA:/etc/squid/acls# vim /etc/squid/squid.conf
root@ORBITA:/etc/squid/acls# /etc/init.d/squid restart
Restarting Squid HTTP proxy: squid2012/04/19 09:26:41| aclParseAclLine: Invalid ACL type '10.0.0.0/24'
FATAL: Bungled squid.conf line 64: acl rede_interna 10.0.0.0/24
Squid Cache (Version 2.7.STABLE9): Terminated abnormally.
failed!
root@ORBITA:/etc/squid/acls#


root@ORBITA:/etc/squid/acls# vim /etc/squid/squid.conf
root@ORBITA:/etc/squid/acls# cat /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
allow-hotplug eth0
iface eth0 inet dhcp

auto eth1
iface eth1 inet static
address 10.0.1.1
netmask 255.255.255.0
network 10.0.1.0
broadcast 10.0.1.255

auto eth1:rede2
iface eth1:rede2 inet static
address 10.0.2.1
netmask 255.255.255.0
network 10.0.2.0
broadcast 10.0.2.255
root@ORBITA:/etc/squid/acls# vim /etc/squid/squid.conf
root@ORBITA:/etc/squid/acls#
root@ORBITA:/etc/squid/acls# /etc/init.d/squid restart
Restarting Squid HTTP proxy: squid2012/04/19 09:29:28| aclParseAclLine: Invalid ACL type '10.0.0.0/24'
FATAL: Bungled squid.conf line 64: acl rede_interna 10.0.0.0/24
Squid Cache (Version 2.7.STABLE9): Terminated abnormally.
failed!
root@ORBITA:/etc/squid/acls# vim /etc/squid/squid.conf
root@ORBITA:/etc/squid/acls# /etc/init.d/squid restart
Restarting Squid HTTP proxy: squid2012/04/19 09:29:58| aclParseAclLine: Invalid ACL type '10.0.2.0/24'
FATAL: Bungled squid.conf line 64: acl rede_interna 10.0.2.0/24
Squid Cache (Version 2.7.STABLE9): Terminated abnormally.
failed!
root@ORBITA:/etc/squid/acls# vim /etc/squid/squid.conf
root@ORBITA:/etc/squid/acls# /etc/init.d/squid restart
Restarting Squid HTTP proxy: squid2012/04/19 09:30:51| aclParseAclLine: Invalid ACL type '10.0.1.0/24'
FATAL: Bungled squid.conf line 64: acl rede_interna 10.0.1.0/24
Squid Cache (Version 2.7.STABLE9): Terminated abnormally.
failed!
root@ORBITA:/etc/squid/acls# vim /etc/squid/squid.conf
root@ORBITA:/etc/squid/acls# /etc/init.d/squid restart
Restarting Squid HTTP proxy: squid2012/04/19 09:31:25| aclParseAclLine: Invalid ACL type '10.0.2.12.1'
FATAL: Bungled squid.conf line 64: acl rede_interna 10.0.2.12.1
Squid Cache (Version 2.7.STABLE9): Terminated abnormally.
failed!
root@ORBITA:/etc/squid/acls# vim /etc/squid/squid.conf
root@ORBITA:/etc/squid/acls# /etc/init.d/squid restart
Restarting Squid HTTP proxy: squid2012/04/19 09:31:55| aclParseAclLine: Invalid ACL type '10.0.2.1/24'
FATAL: Bungled squid.conf line 64: acl rede_interna 10.0.2.1/24
Squid Cache (Version 2.7.STABLE9): Terminated abnormally.
failed!
root@ORBITA:/etc/squid/acls#
root@ORBITA:/etc/squid/acls# cat /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
allow-hotplug eth0
iface eth0 inet dhcp

auto eth1
iface eth1 inet static
address 10.0.1.1
netmask 255.255.255.0
network 10.0.1.0
broadcast 10.0.1.255

auto eth1:rede2
iface eth1:rede2 inet static
address 10.0.2.1
netmask 255.255.255.0
network 10.0.2.0
broadcast 10.0.2.255
root@ORBITA:/etc/squid/acls# vim /etc/squid/squid.conf
root@ORBITA:/etc/squid/acls# /etc/init.d/squid restart
Restarting Squid HTTP proxy: squid2012/04/19 09:38:21| aclParseAclLine: Invalid ACL type '10.0.0.0/8'
FATAL: Bungled squid.conf line 64: acl rede_interna 10.0.0.0/8
Squid Cache (Version 2.7.STABLE9): Terminated abnormally.
failed!
root@ORBITA:/etc/squid/acls#
root@ORBITA:/etc/squid/acls# vim /etc/squid/squid.conf
root@ORBITA:/etc/squid/acls# vim /etc/squid/squid.conf
root@ORBITA:/etc/squid/acls# cat /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
allow-hotplug eth0
iface eth0 inet dhcp

auto eth1
iface eth1 inet static
address 10.0.1.1
netmask 255.255.255.0
network 10.0.1.0
broadcast 10.0.1.255

auto eth1:rede2
iface eth1:rede2 inet static
address 10.0.2.1
netmask 255.255.255.0
network 10.0.2.0
broadcast 10.0.2.255

Agradeceria quem pudesse me ajudar

[6] Comentário enviado por phrich em 19/04/2012 - 10:35h

Bom dia Thiago Emanuel!

Eu sugiro que vc abra um tópico na comunidade http://www.vivaolinux.com.br/comunidade/Squid-Iptables

Assim poderemos te ajudar, já explique o que vc disse aqui e poste o seu squid.conf lá, assim será melhor para responder ok?

[7] Comentário enviado por Thiago Emannuel em 19/04/2012 - 11:47h

ok.... estarei postando la

[8] Comentário enviado por kakashi963 em 17/05/2012 - 20:32h

Meu squid bloqueia o acesso a todos os sites. A politica de segurança aqui deve ser:
Alguns ips com acesso total a internet: ipsLiberados
Alguns ips com acesso total mas com filtro de palavras: ipsLiberadosRestritos
Palavras que não podem conter nos acessos: palavras bloqueadas
Sites permitidos a todos os usuários da rede: sitesLiberados
Download é bloqueado: download
Acesso a site de antivirus é liberado: antivirus

Para o caso dos ipsLiberadosRestritos, da certo, se o usuário tem seu ip nessa listagem, ele acessa tudo menos o conteudo das palavras, ta ok.

Entretando, para o restante dos usuários da rede que deveriam poder acessar pelo menos os sitesLiberados, tudo fica como bloqueado.

Minhas acls:

acl antivirus dstdomain "/etc/squid3/acls/antivirus"

acl ipsLiberados src "/etc/squid3/acls/ipsLiberados"

acl ipsLiberadosRestritos src "/etc/squid3/acls/ipsLiberadosRestritos"

acl palavrasBloqueadas url_regex -i "/etc/squid3/acls/palavrasBloqueadas"

acl sitesLiberados dstdomain "/etc/squid3/acls/sitesLiberados"

acl download url_regex -i "/etc/squid3/acls/download"

acl localnet src 192.168.0.0/24
acl localhost src 127.0.0.1/32



E meus http_access:


http_access allow antivirus
http_access allow ipsLiberados
http_access deny download
http_access allow ipsLiberadosRestritos !palavrasBloqueadas
http_access allow localhost

http_access deny all !sitesLiberados

[9] Comentário enviado por phrich em 17/05/2012 - 21:15h

Prezado kakashi963 eu recomendo que vc abra um tópico na comunidade sobre squid / iptables pois lá além de ser o local correto para dúvidas, vc terá mais pessoas para ajudar.

Abraços.

[10] Comentário enviado por afdominguez em 23/05/2012 - 23:42h

Amigo, esta dando o seguinte erro:


root@lorrany:~# /etc/rc.local
iptables v1.4.10: REDIRECT: Bad value for "--to-ports" option: "10.15.84.20:3389"
Try `iptables -h' or 'iptables --help' for more information.


[11] Comentário enviado por phrich em 23/05/2012 - 23:46h

Cara, depende de como vc colocou a regra...

Seria mais interessante vc utilizar o fórum para postar suas dúvidas, além de ser o mais correto, vc estaria sendo ajudado por outras pessoas e ajudaria também.

http://www.vivaolinux.com.br/comunidade/Squid-Iptables

[12] Comentário enviado por johnnyb em 13/07/2012 - 14:27h

amigo não intendi essa parte e habilitar ou desabilitar ?

# REMOVE ARQUIVOS TEMPORÁRIOS, SE VOCÊ HABILITAR ESTA OPÇÃO CORRE O RISCO DE ENCHER O DISCO
remove_temp_files yes

[13] Comentário enviado por phrich em 13/07/2012 - 15:45h

Caro johnnyb, se vc habilitar vc irá remover os arquivos temporários gerados pelo SARG, na hora da escrita eu errei, mas habilite para esvaziar o disco ok?

[14] Comentário enviado por ronymoliveira em 11/09/2012 - 11:50h

Bom dia, como faço para implementar o IPTables + squid tendo a seguinte situação:
Internet da GVT: 192.168.25.1
Rede Interna: 192.168.1.1 a 192.168.1.254
Sou novato aqui, estou usando o Debian, se tiver como me ajudar, agradeço.

Atenciosamente,

Rony

[15] Comentário enviado por phrich em 12/09/2012 - 12:11h

A situação é a mesma, basta vc adaptar para sua necessidade.

Qqr coisa, vá até http://www.vivaolinux.com.br/comunidade/Squid-Iptables e abra um tópico lá, mas com este artigo vai ser tranquilo vc fazer, basta adaptar, além é claro das demais configurações de rede.

[16] Comentário enviado por nene_guitar em 25/10/2012 - 20:47h

seguindo os passos
cheguei a esse erro.
ja instalei via yast
o apache2 e também o pacote apache2-utils

linux-62cn:~ # htpasswd -c /etc/squid/grupos/sala1
Could not open passwd file -c for reading.
Use -c option to create new one.

linux-62cn:/ # zypper se htpasswd
Loading repository data...
Reading installed packages...
No packages found.

linux-62cn:/ # find / -name htpasswd
find: `/var/lib/ntp/proc/3517/net': Invalid argument
find: `/var/lib/ntp/proc/3519/net': Invalid argument
find: `/var/lib/ntp/proc/3755/net': Invalid argument
^[[/usr/bin/htpasswd
find: `/proc/3517/net': Invalid argument
find: `/proc/3519/net': Invalid argument
find: `/proc/3755/net': Invalid argument
find: `/run/user/jesse/gvfs': Permission denied
linux-62cn:/ # find / -name apache2
/etc/apache2
/etc/init.d/apache2
/etc/sysconfig/apache2
/etc/sysconfig/SuSEfirewall2.d/services/apache2
/etc/logrotate.d/apache2
/var/cache/apache2
/var/lib/apache2
/var/lib/systemd/migrated/apache2
find: `/var/lib/ntp/proc/3517/net': Invalid argument
find: `/var/lib/ntp/proc/3519/net': Invalid argument
find: `/var/lib/ntp/proc/3755/net': Invalid argument
/var/log/apache2
/usr/lib64/apache2
/usr/share/apache2
/usr/share/doc/packages/apache2
find: `/proc/3517/net': Invalid argument
find: `/proc/3519/net': Invalid argument
find: `/proc/3755/net': Invalid argument
find: `/run/user/jesse/gvfs': Permission denied




[17] Comentário enviado por phrich em 26/10/2012 - 10:52h

Cara vc está com vários erros de permissões aí...

Faz o seguinte, abre um tópico na comunidade www.vivaolinux.com.br/comunidade/Squid-Iptables lá terão vários usuários para ajudar além de ser o local adequado para isto ok?

[18] Comentário enviado por xirux em 11/07/2014 - 12:19h

Cara, muito bom o artigo, realmente show. Foi pros favoritos e será de valia nos meus arquivos com certeza!
Se posso opinar, no squid.conf eu impediria o uso do proxy por rede externa limitando com a adição do ip do FW, antes da porta na linha:

http_port 10.0.0.254:3128

E adicionaria em sarg.conf um limite de logs para o squid, impedindo problemas com espaço:

lastlog 10

Parabéns!

[19] Comentário enviado por phrich em 11/07/2014 - 16:14h

Obrigado xiux, essa opção do SARG é ótima!
Com relação ao proxy, bloqueamos isso no iptables, visto que a porta 3128 está liberada apenas para a rede interna.
abs!

[20] Comentário enviado por jnt.santos em 14/10/2014 - 11:40h

Obrigado pelo Tutorial
Mais quando tento logar nao pede usuário nem senha.
Estou fazendo em teste então mantive o seu mesmo script no meu squid3(so alterando os erros), a UNICA DIFERENÇA FOI NO IPTABLES só possuo uma placa de rede então configurei assim o IPtables:
# Carrega os modulos
#modprobe iptables
modprobe iptable_nat
# Limpa a tabela filter
iptables -F
iptables -t nat -F
iptables -t mangle -F

# Compartilha a conexao
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
echo 1 > /proc/sys/net/ipv4/ip_forward

# Proxy Transparente
iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 3128
iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 443 -j REDIRECT --to-port 3128

iptables -A INPUT -p tcp --destination-port 22 -j ACCEPT
iptables -A INPUT -p tcp --destination-port 110 -j ACCEPT
iptables -A INPUT -p tcp --destination-port 25 -j ACCEPT
iptables -A INPUT -p tcp --destination-port 587 -j ACCEPT
iptables -A INPUT -p tcp --destination-port 3128 -j ACCEPT
iptables -A INPUT -p tcp --destination-port 80 -j ACCEPT
iptables -A INPUT -p tcp --destination-port 137 -j ACCEPT
iptables -A INPUT -p tcp --destination-port 139 -j ACCEPT
iptables -A INPUT -p tcp --destination-port 88 -j ACCEPT
iptables -A INPUT -p tcp --destination-port 53 -j ACCEPT
iptables -A INPUT -p tcp --destination-port 445 -j ACCEPT
iptables -A INPUT -p tcp --destination-port 443 -j ACCEPT
iptables -A INPUT -p tcp --destination-port 111 -j ACCEPT
iptables -A INPUT -p tcp --destination-port 901 -j ACCEPT
iptables -A INPUT -p tcp --destination-port 548 -j ACCEPT
iptables -A INPUT -p tcp --destination-port 2049 -j ACCEPT
iptables -A INPUT -p tcp --destination-port 3000 -j ACCEPT
iptables -A INPUT -p tcp --destination-port 3389 -j ACCEPT
iptables -A INPUT -p tcp --destination-port 3900 -j ACCEPT
iptables -A INPUT -p tcp --destination-port 4900 -j ACCEPT
iptables -A INPUT -p tcp --destination-port 23 -j ACCEPT
iptables -A INPUT -p tcp --destination-port 2323 -j ACCEPT
iptables -A INPUT -p tcp --destination-port 3306 -j ACCEPT
iptables -A INPUT -p tcp --destination-port 9100 -j ACCEPT
iptables -A INPUT -p tcp --destination-port 1723 -j ACCEPT
iptables -A INPUT -p tcp --destination-port 47 -j ACCEPT

# Abre para a rede local
iptables -A INPUT -p tcp --syn -s 192.168.10.0/255.255.255.0 -j ACCEPT

Depois na estação configuro para o IP so server e para a porta 3128, o que pode estar errado?

[21] Comentário enviado por phrich em 14/10/2014 - 11:54h

Caro jnt.santos,

Autenticação com proxy transparent e 1 placa de rede?

Só com mágica mesmo rsrsrs.

Remova as linhas de redirecionamento que vai funcionar.

[22] Comentário enviado por jnt.santos em 14/10/2014 - 12:06h

Opa Princh Tbm, Valeu pela ajuda, MAIS ainda não pede nada =/, cara esta assim agora
# Carrega os modulos
#modprobe iptables
modprobe iptable_nat
# Limpa a tabela filter
iptables -F
iptables -t nat -F
iptables -t mangle -F

# Compartilha a conexao
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
echo 1 > /proc/sys/net/ipv4/ip_forward

# Proxy Transparente
#iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 3128
#ptables -t nat -A PREROUTING -i eth0 -p tcp --dport 443 -j REDIRECT --to-port 3128

iptables -A INPUT -p tcp --destination-port 22 -j ACCEPT
iptables -A INPUT -p tcp --destination-port 110 -j ACCEPT
iptables -A INPUT -p tcp --destination-port 25 -j ACCEPT
iptables -A INPUT -p tcp --destination-port 587 -j ACCEPT
iptables -A INPUT -p tcp --destination-port 3128 -j ACCEPT
iptables -A INPUT -p tcp --destination-port 80 -j ACCEPT
iptables -A INPUT -p tcp --destination-port 137 -j ACCEPT
iptables -A INPUT -p tcp --destination-port 139 -j ACCEPT
iptables -A INPUT -p tcp --destination-port 88 -j ACCEPT
iptables -A INPUT -p tcp --destination-port 53 -j ACCEPT
iptables -A INPUT -p tcp --destination-port 445 -j ACCEPT
iptables -A INPUT -p tcp --destination-port 443 -j ACCEPT
iptables -A INPUT -p tcp --destination-port 111 -j ACCEPT
iptables -A INPUT -p tcp --destination-port 901 -j ACCEPT
iptables -A INPUT -p tcp --destination-port 548 -j ACCEPT
iptables -A INPUT -p tcp --destination-port 2049 -j ACCEPT
iptables -A INPUT -p tcp --destination-port 3000 -j ACCEPT
iptables -A INPUT -p tcp --destination-port 3389 -j ACCEPT
iptables -A INPUT -p tcp --destination-port 3900 -j ACCEPT
iptables -A INPUT -p tcp --destination-port 4900 -j ACCEPT
iptables -A INPUT -p tcp --destination-port 23 -j ACCEPT
iptables -A INPUT -p tcp --destination-port 2323 -j ACCEPT
iptables -A INPUT -p tcp --destination-port 3306 -j ACCEPT
iptables -A INPUT -p tcp --destination-port 9100 -j ACCEPT
iptables -A INPUT -p tcp --destination-port 1723 -j ACCEPT
iptables -A INPUT -p tcp --destination-port 47 -j ACCEPT

# Abre para a rede local
iptables -A INPUT -p tcp --syn -s 192.168.10.0/255.255.255.0 -j ACCEPT

[23] Comentário enviado por phrich em 14/10/2014 - 12:09h

Veja as suas regras novamente, estão faltando algumas coisas nelas, compare novamente com o artigo e imagine como seu script deve ser adaptado.

O correto mesmo para as dúvidas é no fórum, onde poderemos compartilhar com outras pessoas tbém ;-)

[24] Comentário enviado por ronivonjunio em 21/10/2015 - 18:43h



[25] Comentário enviado por ronivonjunio em 21/10/2015 - 18:46h

BOA TARDE ! OTIMO ARTIGO , GOSTEI MUITO, SOU INICIANTE E USO O OPEN SUSE TERIA UM TUTORIAL DO OPEN SUSE? COM ESSE MSMO ARTIGO?


Contribuir com comentário




Patrocínio

Site hospedado pelo provedor RedeHost.
Linux banner

Destaques

Artigos

Dicas

Tópicos

Top 10 do mês

Scripts