Skip to contentSkip to conversation

iptables query

DISCUSSION shardul Adhikari 2 participants 4 messages Mar 25, 2005 – Mar 27, 2005

lore
Share & tools
lore
#0 lore raw

Hi list,
I am relatively new to iptables

i am trying this

iptables -A PREROUTING -t nat -i eth0 -d 202.75.112.3 --dport 8080 -j REDIRECT --to-port 3128 .
Now the problem is it does not get redirected ,
if i remove the -d part , it works just fine
but i do not want to redirect for any destination , but only if request comes for a particular destination .
Is there any thing wrong that i am doing , or do i have to use some different chain or ruleset ,

please help

#1 lore raw
Quoted 2 lines · shardul Adhikari

iptables -A PREROUTING -t nat -i eth0 -d 202.75.112.3 --dport 8080 -j REDIRECT --to-port 3128

I don't see "-p tcp" in that rule. You can use --dport or --sport only if you specify "-p tcp" or "-p udp".

For this reason, that rule will give you an error if you try and run it. Before you correct your mistake, you should look for the error message and see where it is displayed, so that you can more easily discover future mistakes and problems.

Toby

Signature · 2 lines
Love(n): The delusion that one woman differs from another.
						H.L. Mencken
#2 lore raw
Quoted 12 lines · Toby
Quoted 2 lines · shardul Adhikari

iptables -A PREROUTING -t nat -i eth0 -d 202.75.112.3 --dport 8080 -j REDIRECT --to-port 3128

I don't see "-p tcp" in that rule. You can use --dport or --sport only if you specify "-p tcp" or "-p udp".

For this reason, that rule will give you an error if you try and run it. Before you correct your mistake, you should look for the error message and see where it is displayed, so that you can more easily discover future mistakes and problems.

Quoted 7 lines

Toby

--
Love(n): The delusion that one woman differs from another.
H.L. Mencken

- p tcp is there , i forgot to mention it , sorry for that the rule is getting accepted , as it is showing in iptables -L -t nat

#3 lore raw
Quoted 15 lines · shardul Adhikari
Quoted 14 lines · Toby
Quoted 2 lines · shardul Adhikari

iptables -A PREROUTING -t nat -i eth0 -d 202.75.112.3 --dport 8080 -j REDIRECT --to-port 3128

I don't see "-p tcp" in that rule. You can use --dport or --sport only if you specify "-p tcp" or "-p udp".

For this reason, that rule will give you an error if you try and run it. Before you correct your mistake, you should look for the error message and see where it is displayed, so that you can more easily discover future mistakes and problems.

Toby

Quoted 8 lines
Quoted 5 lines

--
Love(n): The delusion that one woman differs from another.
H.L. Mencken

- p tcp is there , i forgot to mention it , sorry for that the rule is getting accepted , as it is showing in iptables -L -t nat

Basically what i am trying to do is redirect any request going to 202.75.112.3 on port 8080 to port 3128 on the same machine . Will that be possible , or do i have to set up a separate iptables server for that purpose.
My iptables squid and dansguardian are running on same machine.