LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
LinkBack Search this Thread
Old 02-19-2009, 06:06 AM   #1
slacker_me
LQ Newbie
 
Registered: Dec 2008
Posts: 11

Rep: Reputation: 0
How to show IP address and Client Names on Squid Logs


Hi Sirs,

Im using Debian ETCH as a proxy server here in our SOHO. I'd like to know how to set the squid logs to also show the client's names requesting the url and their IP address.

As of now, when I type in tail -f /var/log/squid/access.log it only shows the URLs.

Second, I would also like to know how long the logs are kept in the server like what is the default time. Somehow, it seems like it only shows the last 30 min logs of a single user.

How do I also edit this to show at least all of the logs for a number of days.

Any help would be appreciated

thanks
 
Old 02-19-2009, 07:45 AM   #2
bathory
Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 9,608

Rep: Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004
You should take a look here to see how you can customize the squid logformat.
The logs are kept as long as you don't run:
Code:
squid -k rotate
. If you have only 30min logs, that means that there is a cronjob that rotate the logs every half an hour.
 
Old 02-19-2009, 09:15 AM   #3
slacker_me
LQ Newbie
 
Registered: Dec 2008
Posts: 11

Original Poster
Rep: Reputation: 0
Hi bathory,

thanks for the reply.

I tried to turn emulate_httpd_log on and tried to enable each of the logformat like combine and common, and lastly the option log_ip_on_direct to on, still I get the same format of logs which really does not show me the IP address and time.

the format is like this:

1234884806.156 25697 127.0.0.1 TCP_MISS/200 418 GET http://mail.google.com/mail/channel/...gm8-c3ui5e&t=1 - DIRECT/209.85.143.83 text/plain
1234884809.969 626 127.0.0.1 TCP_MISS/200 1638 POST http://www.mmorpg.com/ajax/tools.cfc...=1234884732035 - DIRECT/216.168.135.100 text/html

hope u can help me out.

I really appreciate it
 
Old 02-19-2009, 09:34 AM   #4
bathory
Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 9,608

Rep: Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004
If you want the date and time to be in a readable format, use %tl. In my squid.conf I use:
Code:
logformat squid  %tl %6tr %>a %Ss/%03Hs %<st %rm %ru %un %Sh/%<A %mt
...
access_log /var/log/squid/access.log squid
The Ip is the Ip of the client, in your case localhost. You can use %>A to have the fqdn of the client.
 
Old 02-19-2009, 09:59 AM   #5
slacker_me
LQ Newbie
 
Registered: Dec 2008
Posts: 11

Original Poster
Rep: Reputation: 0
thanks for the help sir!

I can see the time now. just one more question, what do i need to do for it to show the exact IP address of the client instead of localhost?
 
Old 02-19-2009, 11:27 AM   #6
yoh101
LQ Newbie
 
Registered: Nov 2006
Location: Philippines
Distribution: slackware/ubuntu/fedoracore
Posts: 3

Rep: Reputation: 0
on squid.conf change the value of the client_netmask 255.255.255.255/255.255.255.0
 
Old 02-19-2009, 11:58 AM   #7
bathory
Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 9,608

Rep: Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004
@slacker_me
Use another box to test squid, so you'll the IP of that box

@yoh101
I guess that the OP just sees localhost because he uses the same box running squid to test
The default "client_netmask 255.255.255.255" should display the whole IP of the client, while "client_netmask 255.255.255.0" will replace the last octet with "0".
 
Old 02-20-2009, 03:08 AM   #8
slacker_me
LQ Newbie
 
Registered: Dec 2008
Posts: 11

Original Poster
Rep: Reputation: 0
Hi

thanks for all the help

sorry for being quite dumb in asking this but im not really sure wat you mean by using another box to test squid.

My squid box is also a dhcp server so i know all of the ip addresses of each of the clients passing through squid.

However, all just shows localhost in the logs instead of their ips.

thanks and i really appreciate it.
 
Old 02-20-2009, 05:03 AM   #9
bathory
Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 9,608

Rep: Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004
Quote:
sorry for being quite dumb in asking this but im not really sure wat you mean by using another box to test squid.
My squid box is also a dhcp server so i know all of the ip addresses of each of the clients passing through squid.
However, all just shows localhost in the logs instead of their ips.
I thought that you're checking squid from the computer running squid. It seems that the same box runs except from squid and dhcpd, a firewall that masquerades the LAN IPs.
You can turn of masquerading and see if it works.

Regards
 
Old 02-20-2009, 05:13 AM   #10
slacker_me
LQ Newbie
 
Registered: Dec 2008
Posts: 11

Original Poster
Rep: Reputation: 0
thanks bathory! i'll try this
 
Old 02-20-2009, 06:51 AM   #11
slacker_me
LQ Newbie
 
Registered: Dec 2008
Posts: 11

Original Poster
Rep: Reputation: 0
In addition to this, wouldnt it be much easier to have logs display the client's username? have you tried this? coz i think im sure i was able to include the options UL and UN in my logformat but it does not show it still. is this still affected by masquerade in iptables?

any thoughts?

thanks
 
Old 02-20-2009, 07:30 AM   #12
bathory
Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 9,608

Rep: Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004
This can be done only if you use some kind of authentication for your clients to use squid.
 
Old 02-21-2009, 08:52 AM   #13
yoh101
LQ Newbie
 
Registered: Nov 2006
Location: Philippines
Distribution: slackware/ubuntu/fedoracore
Posts: 3

Rep: Reputation: 0
nice catch bathory need those info thanks
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Show useful names/labels in Konqueror media:/ arizonagroovejet Linux - Desktop 3 08-18-2008 05:26 PM
how to show global address book in client side by sendmail singh_chitranjan Linux - Networking 0 07-10-2008 02:44 PM
How can I show the full names on my desktop? mehmetunlu Linux - Newbie 3 02-14-2006 06:55 AM
DC++ doesn't show user names with winetools Baran Linux - Software 2 03-17-2005 11:27 PM
cannot show the traditional Chinese names on a ftp client tony yu Mandriva 4 09-09-2003 08:07 PM


All times are GMT -5. The time now is 05:56 AM.

Main Menu
 
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration