I've tried several different combinations of rules and nothing seems to be working. I know that you can't use prerouting table for a request coming from the localhost so I used the output table and that just returns errors when using wget.
I have wget configured to use a proxy 127.0.0.1:8118. When I use the command below I get my public IP. If I change the command to remove the --no-proxy I get the IP from my proxy.
I want to use iptables to force any request for this site through the proxy regardless of the program requesting it. I'm essentially trying to create a transparent proxy but only for the request of one site.
System = Debian Squeeze
wget --no-proxy -q -O - checkip.dyndns.org|sed -e 's/.*Current IP Address: //' -e 's/<.*$//'
I've enabled net.ipv4.ip_forwarding=1 in /etc/sysctl.conf.
iptables -t nat -I OUTPUT --source 0/0 --destination checkip.dyndns.org -p tcp -j REDIRECT --to-ports 8118 iptables -t nat -I OUTPUT -p tcp -d checkip.dyndns.org -j REDIRECT --to-ports 8118 iptables -t nat -I PREROUTING -p tcp -s localhost -j DNAT --to 127.0.0.1:8118 iptables -t nat -I OUTPUT --source localhost --destination checkip.dyndns.org -p tcp -j REDIRECT --to-ports 8118
And various others that are all similar.