LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 09-29-2009, 04:04 PM   #1
witch_doctor
LQ Newbie
 
Registered: Jun 2007
Posts: 10

Rep: Reputation: 0
Squid + multiple interfaces


Hey all,

Here is a problem I'm trying to solve for hours, with no luck:

My debian host has a single ethernet card and is configured with 3 virtual interfaces, each with it's own IP address, let's say a.a.a.a, b.b.b.b, and c.c.c.c

A squid server is proxying http requests for authenticated users. Squid is configured to listen to all interfaces, not bound to any single one.

What I need to do is make the squid http requests originate from the *same* IP address that the client request comes in. For example if a client uses a.a.a.a:3128 to make a request to the proxy, squid will use a.a.a.a in its corresponding http request. If another client request comes in b.b.b.b:3128, squid will use b.b.b.b for it's http request.
In other words, I need the source IP of the squid http requests leaving my box to be the same as the destination IP of the client requests that come in.
I haven't found any way to do this with squid itself, so I tried in vain to implement it in iptables by trying to MARK/SNAT traffic. As it seems, squid http requests are not RELATED to the client requests to squid, so there is no way to do this with usual connection tracking. Is there any other way?
Thanks for any help!
 
Old 09-29-2009, 04:46 PM   #2
anomie
Senior Member
 
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora
Posts: 3,935
Blog Entries: 5

Rep: Reputation: Disabled
I don't quite understand the scenario.

Quote:
Originally Posted by witch_doctor
For example if a client uses a.a.a.a:3128 to make a request to the proxy, squid will use a.a.a.a in its corresponding http request. If another client request comes in b.b.b.b:3128, squid will use b.b.b.b for it's http request.
I'm not an HTTP expert, but I think when you say "http request" in this context, you really mean the response + message body that is returned by the remote web server, right?

Also, is your squid host providing NAT to your client networks or not?

-------

Finally, what OS / version / squid version?
 
Old 09-29-2009, 06:22 PM   #3
witch_doctor
LQ Newbie
 
Registered: Jun 2007
Posts: 10

Original Poster
Rep: Reputation: 0
ok, got it...

Thank you for your reply anomie. Sorry for not being very clear.
It also turns out I should have RTFMed better before asking for help! I found that squid is perfectly capable of providing what I wanted. I just added these to my squid.conf file, and it worked:

acl incoming1 myip a.a.a.a
acl incoming2 myip b.b.b.b
acl incoming3 myip c.c.c.c

http_access allow incoming1 incoming2 incoming3

tcp_outgoing_address a.a.a.a incoming1
tcp_outgoing_address b.b.b.b incoming2
tcp outgoing_address c.c.c.c incoming3


Again, what I wanted was that squid would use the same IP address to make any requests to remote servers that the client uses in his requests.
For example if a client makes a request to squid on IP a.a.a.a, squid will use the same IP to connect to the remote server.

For the reference, the OS is Debian 5.0.3 (stable), Squid is 2.7


One last question though: how can I, in addition to the above, demand that the clients are authenticated? I mean something similar to:

acl auth proxy_auth REQUIRED

Is it possible to "chain" acl statements? Sorry, I'm a complete squid noob at the moment!
 
Old 09-29-2009, 07:03 PM   #4
witch_doctor
LQ Newbie
 
Registered: Jun 2007
Posts: 10

Original Poster
Rep: Reputation: 0
Replying to myself, the http_access statement above is of course wrong, and incidentally the answer to my second question. The correct configuration is:

Code:
acl incoming1 myip a.a.a.a
acl incoming2 myip b.b.b.b
acl incoming3 myip c.c.c.c
acl auth proxy_auth REQUIRED

http_access allow incoming1 auth
http_access allow incoming2 auth
http_access allow incoming3 auth

tcp_outgoing_address a.a.a.a incoming1
tcp_outgoing_address b.b.b.b incoming2
tcp_outgoing_address c.c.c.c incoming3

server_persistent_connections off
Case solved.
 
Old 09-30-2009, 11:39 AM   #5
anomie
Senior Member
 
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora
Posts: 3,935
Blog Entries: 5

Rep: Reputation: Disabled
Quote:
Originally Posted by witch_doctor
Is it possible to "chain" acl statements?
You already solved your own problem, but yes.

Note that named acl directives are cumulative. So:

Code:
acl foo dstdomain .some.place
acl foo dstdomain .other.place
acl goodguys src 192.168.50.0/24
... means that "foo" consists of both .some.place and .other.place.

On the other hand, http_access directives are treated like logical ANDs. So:

Code:
http_access allow foo goodguys
... means that both "foo" and "goodguys" must be satisfied to match the rule.
 
  


Reply



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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Squid and interfaces NoRefill Linux - Server 2 05-11-2009 03:52 PM
multiple bonds = multiple primary interfaces? turbo_acura Linux - Server 1 02-17-2009 11:15 AM
squid configuration, multiple eth interfaces zeeshan12 Linux - Networking 8 03-25-2008 11:26 AM
Squid Interfaces? adymroxx Linux - Networking 2 01-07-2006 08:45 PM
Red Hat 7.3 and multiple gateways on multiple interfaces bluefmc Linux - Networking 2 11-19-2004 05:01 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

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

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration