View previous topic :: View next topic |
Author |
Message |
muhaur n00b
Joined: 30 Jul 2005 Posts: 8
|
Posted: Sat Jul 30, 2005 10:47 pm Post subject: Transparents squid problem |
|
|
i m running redhat linux enterprize edition and i configured squid and internet was running on client's PC.
but when i was going to configure the transparents squid then it causes problem and now internet is not running on client's PC.
i also want to know, what i did wronge that causes that now internet is not running.
now i want to tell my scenario
i have two PCs one on which squid server is running and second is the client's PC.
i ve two thernet cards eth0 (internet provider connection) and eth1( attacjhed to the client's PC). To make the squid server as transparent i run this command
iptables-t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 3128
.iptables-t nat -A PREROUTING -i eth1 -p tcp --dport 80 -j REDIRECT --to-port 3128
unfortunately i run above command on both interfaces and now internet is not running. what is wronge in that. |
|
Back to top |
|
|
kawsper Tux's lil' helper
Joined: 09 Nov 2004 Posts: 128 Location: Copenhagen, Denmark
|
Posted: Sun Jul 31, 2005 1:55 am Post subject: |
|
|
Why are you doing it on both in and out?
The only thing i can remind as a problem is that a client is requesting a page on port 80, iptables redirects the attempt to squid, and while squid is fetching the file from port 80 out, you are redirecting squids fetching attempt to port 3128, so if i am your client, i connect to the, and try to fetch google.com, i am getting google.com on port 3128, which doesnt exists, and there are your problem.
Its only incoming connections on port 80 that should be redirected to squid on the internal network card. _________________ Laptop: Zepto 2314W, Pentium M 730, 512 Mb Pc-3200
Server 1: Athlon XP 3200+ | Asus A7V880 | 768 Mb DDR Pc-3200
Server 2: Pentium III Coppermine | Unknown MB | 64 Mb
All running Gentoo
www.hyggenet.org - IRC-Network for the pleasant atmosphere. |
|
Back to top |
|
|
muhaur n00b
Joined: 30 Jul 2005 Posts: 8
|
Posted: Sun Jul 31, 2005 5:20 am Post subject: you r right but i apply iptable commds on both interface b/c |
|
|
you are right but when i apply this command to redirect the internal client's request from 80 to 3128 it did not work. so i though that i should also apply this to the external ethernet (from where i m getting internet service) aswell. after that its not working at all. pls also tell me how can i come to my previous configuration, i mean how can i delete the previous iptables configuration. from where i can finish or edit the iptable configuration.
looking to hearing from you. |
|
Back to top |
|
|
kawsper Tux's lil' helper
Joined: 09 Nov 2004 Posts: 128 Location: Copenhagen, Denmark
|
Posted: Sun Jul 31, 2005 5:50 am Post subject: |
|
|
You can try using a script i once runned on my server, it's a very basic one, but it should do the job quite well.
Code: | #!/bin/sh
# Variables to use later in the script
EXT_IP="83.88.204.226"
LAN_NET="192.168.0.1/24"
# Turn forwarding off
echo 0 > /proc/sys/net/ipv4/ip_forward
/sbin/iptables -t nat -F
/sbin/iptables -F
/sbin/iptables -P FORWARD ACCEPT
/sbin/iptables -P OUTPUT ACCEPT
/sbin/iptables -P INPUT ACCEPT
/sbin/iptables -t nat -A POSTROUTING -s $LAN_NET -d ! $LAN_NET -j SNAT --to $EXT_IP
# Forward all outgoing trafic on port 80 from our clients to squid (That are listening on port 3128)
iptables -t nat -A PREROUTING -i eth1 -p tcp --destination-port 80 -j REDIRECT --to-port 3128
/sbin/iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
/sbin/iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
# Start the forwarding
echo 1 > /proc/sys/net/ipv4/ip_forward
|
On my server eth0 is the external one, and eth1 the internal.
REMEMBER: Set the right card name on the line that forwards, and remember to set your external ip and your lan in the first two variables. _________________ Laptop: Zepto 2314W, Pentium M 730, 512 Mb Pc-3200
Server 1: Athlon XP 3200+ | Asus A7V880 | 768 Mb DDR Pc-3200
Server 2: Pentium III Coppermine | Unknown MB | 64 Mb
All running Gentoo
www.hyggenet.org - IRC-Network for the pleasant atmosphere. |
|
Back to top |
|
|
muhaur n00b
Joined: 30 Jul 2005 Posts: 8
|
Posted: Sun Jul 31, 2005 7:02 am Post subject: thanx , right now i am somewhere, i ll try after 10 hour |
|
|
thanx , right now i am somewhere, i ll try after 10 hour i ll try it.
thanx again
Bye |
|
Back to top |
|
|
kawsper Tux's lil' helper
Joined: 09 Nov 2004 Posts: 128 Location: Copenhagen, Denmark
|
Posted: Sun Jul 31, 2005 7:09 am Post subject: |
|
|
Too bad, and bad style dude, you have to use gentoo ALL THE TIME and be home with the system all the time. At least use a SSH to the system
Me? Geeky? No!
When you come back please give feedback, others may find it useful, and i will be here to help _________________ Laptop: Zepto 2314W, Pentium M 730, 512 Mb Pc-3200
Server 1: Athlon XP 3200+ | Asus A7V880 | 768 Mb DDR Pc-3200
Server 2: Pentium III Coppermine | Unknown MB | 64 Mb
All running Gentoo
www.hyggenet.org - IRC-Network for the pleasant atmosphere. |
|
Back to top |
|
|
jani80k n00b
Joined: 07 Aug 2003 Posts: 40
|
Posted: Sun Jul 31, 2005 8:22 am Post subject: |
|
|
ok this schouldn´t be too hard...
make sure you have this in your squid config:
Code: |
httpd_accel_host virtual
httpd_accel_port 80
httpd_accel_with_proxy on
httpd_accel_uses_host_header on
|
i use this line, if the proxy is running on localhost
Code: |
iptables -t nat -A PREROUTING -s 192.168.0.0/24 -p tcp --dport 80 -j REDIRECT --to-port 3128
|
and these two lines, if the box the proxy is running on is not the gateway
Code: |
iptables -t nat -A PREROUTING -s ! ${host} -i ${LAN_IFACE} -d ! ${subnet} -p tcp --dport 80 -j DNAT --to-destination ${host}:${port}
iptables -t nat -A POSTROUTING -s ${subnet} -d ${host} -j SNAT --to-source ${MY_IP}
|
_________________ ...Linux is for free, if your time has no value. |
|
Back to top |
|
|
muhaur n00b
Joined: 30 Jul 2005 Posts: 8
|
Posted: Sun Jul 31, 2005 5:41 pm Post subject: one more thing to ask |
|
|
Thank u so much for reply and sorry for late.
the script that u send me is for when u r getting external as static. but in my scenario i am getting IP from DHCP server. so what changes should i make so that this scrpt can run according to my scenario. |
|
Back to top |
|
|
muhaur n00b
Joined: 30 Jul 2005 Posts: 8
|
Posted: Mon Aug 01, 2005 12:26 am Post subject: again abnormal behaviior in running squid |
|
|
The script that u told me when i run that script. The results was amazing, one the client PC, proxy was defined when i run your script then it start working, browsing on Client PCs starts (but it should not start because that tine on Client PC proxy was defined while script says it dont need any proxy on client side) but after 1 minute browsing stop working. so what would the problem?
One mistake i previously did that i also told u that i run the following script for both internal and external ethernet
iptables -t nat -A PREROUTING -i eth2 -p tcp --destination-port 80 -j REDIRECT --to-port 3128 (Internal)
iptables -t nat -A PREROUTING -i eth1 -p tcp --destination-port 80 -j REDIRECT --to-port 3128 (external)
how can i remove that command from external interface.
(on server machine it is doing browsing)
One thing more that i m getting IP from DHCP server so in your scrpt that u gave me i dont know how to modify the script to get ip from DHCP server so i simply see my ip that i was assigned that time from DHCP server and write that ip in your scrpt.
Whats wronge in that?
ihow to run squid transparently, even now i m unable to run with the help of proxy.
Thanx
Waiting for ur reply |
|
Back to top |
|
|
the_mgt Apprentice
Joined: 05 Aug 2005 Posts: 259 Location: Germany, near Hannover
|
Posted: Sat Aug 06, 2005 12:49 pm Post subject: |
|
|
thanks to jani80k! i got my squid transparency problem fixed now!
@muhaur:
If you don't want to mess around with the iptables commands, you can use shorewall.
It writes the iptable rules for you, but has a very simple syntax in the config files.
And provides good howtos on their homepage. Very good for beginners!! |
|
Back to top |
|
|
|