LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 10-21-2004, 06:19 AM   #1
james.farrow
Member
 
Registered: Mar 2003
Location: UK Darlington
Distribution: Fedora Freebsd Centos
Posts: 296

Rep: Reputation: 31
Squid and browser config


I have a squid proxy server 192.168.1.1, internet is on eth0 and eth1 is local LAN, and several other boxes getting their IP's via DHCP, all fine no problem. Squid uses port 3128 and I had to point all the browsers of the other boxes to this port using the rules added to my firewall:-

iptables -t nat -A PREROUTING -i eth1 -p tcp --dport 80 \

-j REDIRECT --to-ports 3128

iptables -A OUTPUT -j ACCEPT -m state --state NEW -o eth0 \

-p tcp --dport 80

Is it possible to configure the iptables rules so that all the browsers point to the standard port 80 and it gets redirected to 3128. I have httpd running, but only for the LAN, I do not require it to be accessible from 'outside'.

Thanx in advance.

My knowledge of iptbales is limited to say the least....
 
Old 10-24-2004, 05:18 AM   #2
ugge
Senior Member
 
Registered: Dec 2000
Location: Gothenburg, SWEDEN
Distribution: OpenSUSE 10.3
Posts: 1,028

Rep: Reputation: 45
What your asking for is called transparent proxy.
As far I can see from your setup this is exactly what you have accomplished.
First rule syas: "Before determining the interface to send the packet, check to see if it is comming in on eth1 and if it is a port 80 packet. If so then redirect it to localhost:3128, which is your squid proxy."

Isn't it working?
 
Old 10-24-2004, 06:50 AM   #3
james.farrow
Member
 
Registered: Mar 2003
Location: UK Darlington
Distribution: Fedora Freebsd Centos
Posts: 296

Original Poster
Rep: Reputation: 31
Its working but not exactly how I'd like. I was wanting to leave all the browsers on the network using port 80 but have my firewall redirect all traffic to squid on port 3128 on the same interface?
 
Old 10-24-2004, 07:04 AM   #4
ugge
Senior Member
 
Registered: Dec 2000
Location: Gothenburg, SWEDEN
Distribution: OpenSUSE 10.3
Posts: 1,028

Rep: Reputation: 45
Your squid server isn't on the same machine as your firewall?

Then you will have to use another destination. This is accomplished using DNAT (Destination Network Address Translation)
Code:
iptables -t nat -A PREROUTING -i eth1 -p tcp --dport 80 -j DNAT --to ipaddress:3128
That should do it. Exchange the ipaddress to your squid server.
This rule says: "Before determine the destination interface (routing), cheeck to see if the packet came in on eth1 and was a port 80 packet. If that's the case then change destination to ipaddressort."
Also make sure the rule gets in the right place in the chain so that no other rules stop your packets before they reach this rule.
 
Old 10-24-2004, 08:43 AM   #5
james.farrow
Member
 
Registered: Mar 2003
Location: UK Darlington
Distribution: Fedora Freebsd Centos
Posts: 296

Original Poster
Rep: Reputation: 31
My main box is has 2 eth cards, eth0 is internet and gets its ip via dhcp from cable modem, and eth1 is my internal network range 192.168.1.1 staic. This nic give out ip's in the range 192.168.1.100-200 to the boxes on the network. This main box is my dhcp, www, ftp, apache, squid and name server for the small network, i was wanting to use squid as the proxy for the network but without having to reconfigure every browser, and still have internal acess only to my apache sever, a kind of local intranet? Does that help in anyway!?
 
Old 10-24-2004, 01:39 PM   #6
ugge
Senior Member
 
Registered: Dec 2000
Location: Gothenburg, SWEDEN
Distribution: OpenSUSE 10.3
Posts: 1,028

Rep: Reputation: 45
Then we're back to the first situation, rule with REDIRECT target.
Instead of running iptables rules with -A option, try to enter the rules using -I instead.
This would ensure that your rules get inserted as first rule instead of being appended at the end.
There might be some rule high in the chain blocking your squid packets before they reach this transproxy 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
Need Help in Squid Config krishvij Linux - Networking 3 04-01-2005 03:29 AM
Squid default browser page xilace Linux - Networking 1 03-05-2005 01:17 AM
how to config squid thetzawko Linux - Networking 1 03-04-2005 06:34 AM
squid config tzkolinux Linux - Networking 1 12-16-2004 03:06 AM
squid config upload-3 Linux - Networking 6 12-04-2004 01:23 PM

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

All times are GMT -5. The time now is 09:43 PM.

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