We help IT Professionals succeed at work.

squid proxy

Sabrin
Sabrin asked
on
Medium Priority
718 Views
Last Modified: 2010-04-20
hello,
I have squid proxy and I also have 5 ips
I have edited the .conf file so I can
use the ips like this

http_port ip1:port1
http_port ip2:port2
http_port ip3:port3
http_port ip4:port4
http_port ip5:port5

when I connect to the ip and port it always
gives me the main IP.. how can I fix it?
Comment
Watch Question

CERTIFIED EXPERT
Top Expert 2007

Commented:
What gives you the main IP address?  Do you mean the source address of the request?

Author

Commented:
ip2location.com shows me only the main ip
Top Expert 2005

Commented:
You mean the squid connects to remotes using always one IP?
Use 'tcp_outgoing_address' configuration directive to change it.

Author

Commented:
yes that what im using, like this

tcp_outgoing_address ip1
tcp_outgoing_address ip2
Top Expert 2005

Commented:
tcp_outgoing_address can't be used that way - will always use first match. That's it - the tcp_outgoing_address can bind one outgoing address for some ACLs, another for others ACLs. From the manual, which You propably already seen
#  TAG: tcp_outgoing_address
#       Allows you to map requests to different outgoing IP addresses
#       based on the username or sourceaddress of the user making
#       the request.
#
#       tcp_outgoing_address ipaddr [[!]aclname] ...
#
#       Example where requests from 10.0.0.0/24 will be forwareded
#       with source address 10.1.0.1, 10.0.2.0/24 forwarded with
#       source address 10.1.0.2 and the rest will be forwarded with
#       source address 10.1.0.3.
#
#       acl normal_service_net src 10.0.0.0/255.255.255.0
#       acl good_service_net src 10.0.1.0/255.255.255.0
#       tcp_outgoing_address 10.0.0.1 normal_service_net
#       tcp_outgoing_address 10.0.0.2 good_service_net
#       tcp_outgoing_address 10.0.0.3
#
#       Processing proceeds in the order specified, and stops at first fully
#       matching line.

Author

Commented:
I saw that but i dont understand! how it should be ?
Top Expert 2005

Commented:
An how You want it to behave?

Author

Commented:
lets say these are my ips and the ports i want to use them
86.65.25.101:3120
86.65.25.102:3121
86.65.25.103:3122
how can I do that ?


Top Expert 2005

Commented:
Do You want the squid should pick random source IP while connectiong to remote http server?
If so, I think You have to do it with linux's iptables rather than from squid itself

Author

Commented:
dude, I only want to use 1 ip per port!
If I connect to 86.65.25.101:3120
and I go to ip2location.com I want to see 86.65.25.101
same thing with 86.65.25.102:3121 and 86.65.25.103:3122
thats it!
Top Expert 2005

Commented:
dude, why it took You so long to be clear! (or maybe I have problems - possible as english is not my native)

acl from_ip1 myip 86.65.25.101
acl from_ip2 myip 86.65.25.102
tcp_outgoing_address 86.65.25.101 from_ip1
tcp_outgoing_address 86.65.25.102 from_ip2
tcp_outgoing_address 86.65.25.101 # always leave there some defaults...

Note - You can't control source port on outgoing tcp connection. It will be choosen randomly by system.

Author

Commented:
what if I just open port 3120 from firewall and I connect to
the 5 ips I have will ip2location be able to show that IP ?
If so how can I do it?
Top Expert 2005

Commented:
I'm sorry - I don't get You.
You have to open firewall for each IP:port the squid listens. Apart from that You should allow any ESTABLISHED connection to the squid box. And finally You should allow any outgoing connection from the squid box.

The config I provided tells squid to initiate remote connection from same localIP, as it received the proxy request on.
In other words: if client connects to squid at 86.65.25.102:3128, squid will(if required) connect to remote www server from 86.65.25.102

Author

Commented:
ok but I have 5 ip addresses not just 2
Top Expert 2005

Commented:
dude, make it for all five addresses - should be easy to folow the pattern...

Author

Commented:
ok correct me if im worng!

acl from_ip1 myip 86.65.25.101
acl from_ip2 myip 86.65.25.102
acl from_ip1 myip 86.65.25.103
acl from_ip2 myip 86.65.25.104
acl from_ip1 myip 86.65.25.105

tcp_outgoing_address 86.65.25.101 from_ip1
tcp_outgoing_address 86.65.25.102 from_ip2
tcp_outgoing_address 86.65.25.103 from_ip1
tcp_outgoing_address 86.65.25.104 from_ip2
tcp_outgoing_address 86.65.25.105 from_ip1

tcp_outgoing_address 86.65.25.101
tcp_outgoing_address 86.65.25.102
tcp_outgoing_address 86.65.25.103
tcp_outgoing_address 86.65.25.104
tcp_outgoing_address 86.65.25.105
Top Expert 2005

Commented:
You wrong.

acl from_ip1 myip 86.65.25.101
acl from_ip2 myip 86.65.25.102
acl from_ip1 myip 86.65.25.103
acl from_ip2 myip 86.65.25.104
acl from_ip1 myip 86.65.25.105

tcp_outgoing_address 86.65.25.101 from_ip1
tcp_outgoing_address 86.65.25.102 from_ip2
tcp_outgoing_address 86.65.25.103 from_ip1
tcp_outgoing_address 86.65.25.104 from_ip2
tcp_outgoing_address 86.65.25.105 from_ip1
tcp_outgoing_address 86.65.25.101 # default one - eg. if connected from localhost
Top Expert 2005
Commented:
And I'm wrong as well.

acl from_ip1 myip 86.65.25.101
acl from_ip2 myip 86.65.25.102
acl from_ip3 myip 86.65.25.103
acl from_ip4 myip 86.65.25.104
acl from_ip5 myip 86.65.25.105

tcp_outgoing_address 86.65.25.101 from_ip1
tcp_outgoing_address 86.65.25.102 from_ip2
tcp_outgoing_address 86.65.25.103 from_ip3
tcp_outgoing_address 86.65.25.104 from_ip4
tcp_outgoing_address 86.65.25.105 from_ip5
tcp_outgoing_address 86.65.25.101 # default one - eg. if connected from localhost

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.