I have iptables setup for selective routing. In the current configuration it checks if the dst address is listed in a specific chain and if it is not it redirects the traffic to my proxy port which is active on port 1080.

This works fine with the following setup:

iptables -t nat -N PROXY
# Do not redirect
iptables -t nat -A PROXY -d external.proxy.address.1 -j RETURN
iptables -t nat -A proxy -d external.proxy.address.2 -j RETURN
iptables -t nat -A PROXY -d -j RETURN
iptables -t nat -A PROXY -d -j RETURN
iptables -t nat -A PROXY -d -j RETURN
... [and many more address] ...

# Redirect everything else to the proxy listening on port 1080
iptables -t nat -A PROXY -p tcp -j REDIRECT --to-ports 1080
iptables -t nat -I PREROUTING -p tcp -j PROXY 

As mentioned this works fine for proxy1 but I am trying to redirect traffic in a similar way for destination to a different proxy (proxy2) which listens on port 1088.

I've tried several ways to accomplish this without success.

Configuration I have tried :

iptables -t nat -A PROXY -d -j REDIRECT --to-ports 1088 # didn't do anything

What would be the best way to achieve this (if it's possible)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.