Discussion Locked

linux routing

0 helpful
9 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I have a problem in routing a natting server to squid server, my setup is

router
? |
? |
-switch---
?| ?????????????|
?| ??????????????????????????????????|
natting server(eth0, eth1) ???????Squid server(eth0)

my router address is 200.200.0.1
natting server eth0 is 200.200.0.2
??????????????eth1 is 192.168.1.1
squid server eth0 is 200.200.0.3

all my clients are on private network as 192.168.0.0, and i want to route these clinet http requests to squid server, so i implemented as follows.

squid Server:iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 3128

natting server:
iptables -A PREROUTING -i eth0 -t mangle -p tcp --dport 80 -j MARK --set-mark 2
echo 202 www.out >> /etc/iproute2/rt_tables
ip rule add fwmark 2 table www.out
ip route add default via 200.200.0.3 dev eth0 table www.out
ip route flush cache
now i am not routing to squid server my error in browser is

The requested URL could not be retrieved

While trying to retrieve the URL: /

The following error was encountered:

Invalid URL
Some aspect of the requested URL is incorrect. Possible problems:

Missing or incorrect access protocol (should be `http://'' or similar)
Missing hostname
Illegal double-escape in the URL-Path
Illegal character in hostname; underscores are not allowed

and my config details

ip rule ls
0: ?????from all lookup local
32765: ?from all fwmark 0x2 lookup www.out
32766: ?from all lookup main
32767: ?from all lookup 253

ip route list table www.out
default via 200.200.0.3 dev eth0

ip route
200.200.0.2/29 dev eth0 ?scope link
192.168.0.0/24 deveth1 ?scope link
127.0.0.0/8 dev lo ?scope link
default via 200.200.0.1 dev eth0

can any one give me a solution reg this error, thanks for all the support your are providing.

9 replies

by avswamy

i have one more network interface for squid server, having ip address 192.168.0.2, while all of my clinets can browse through squid by configuring proxy in browser even as 192.168.0.2 or the other ip as 200.200.0.2, both are working fine, while i want an automatic config so that no proxy config necessary in each client, so i implemented above to route all my clients to 200.200.0.2.

by lhomsher

To forward the proxy traffic from your firewall to your proxy server, you also need a FORWARD rule in your iptables script. You can do it with the following rules (without mangling the packet). Something like:

iptables -t nat -A PREROUTING -i eth1 -p tcp --dport 3128 -j DNAT --to-destination 200.200.0.3:80

iptables -A FORWARD -i eth1 -p tcp -d 200.200.0.3 --dport 80 -j ACCEPT

Also, on your rules I noticed you're using '-i eth0', but you say the traffic is coming from your local networkon eth1. You might try changing your rules to eth1.

Hope this helps,
Lori

by avswamy

my forward policy is accept
the two commands are executed with out any error but my error is same and why you have asked dport 3128, i am not connecting with 3128 port from my client machines.

all are able to connect my squid server with direct proxy config in internet explorer with out port. if i tried my config which i posted here no one is getting connected wo proxy config in IE.

by lhomsher

Sorry for the confusion on the dport...on my config I connect with port 3128. I'll assume your dport is correct.

What about your interface? Are your client machines connecting through eth1 on the firewall? If so, your rules should specify the interface as '-i eth1'. If the traffic is coming from eth1 and there is no prerouting rule for that interface, the packets will not get prerouted to your proxy server.

by avswamy

yes you are right i have given wrongly here the ip address of squid server again i am giving details here.
there are two interfaces in both servers(natting & squid server)eth0 is public interface and eth1 is private interface. eth1 of natting server ip is 192.168.1.1 and squid server eth1 is 192.168.1.2 and i want to remove the eth1 from squid server and i want to route all the traffic to eth0 interface of squid server which is a public ip. Now i am allowing all the clients on eth1 interface which is the input for squid server.

by jassy

I can help with these tips if it would help you.
Do a SNAT and configure squid for http acceleration on port 80.
Change the default gateway of the client machine to the private interface of the natting server.

All the best

by jassy

I can help with these tips if it would help you.
Do a SNAT and configure squid for http acceleration on port 80.
Change the default gateway of the client machine to the private interface of the natting server.

All the best

by chetu_75

Hi mr. Swamy,

I seen your this command detail

iptables -A PREROUTING -i eth0 -t mangle -p tcp --dport 80 -j MARK --set-mark 2
echo 202 www.out >> /etc/iproute2/rt_tables
ip rule add fwmark 2 table www.out
ip route add default via 200.200.0.3 dev eth0 table www.out
ip route flush cache

Please don't use last command ip route flush cache,

please put this command on top if you want otherwise remove this and try this.

i think that will help and you are enjoying the same.

Please update me if you through

Chetan

This discussion is closed to new replies.