Skip to contentSkip to conversation

Port DNATting

DISCUSSION Oleg A. Arkhangelsky 2 participants 3 messages Nov 26, 2005

lore
Share & tools
lore
#0 lore raw

Hello All,

When I'm trying to do something like this:

  iptables -t nat -I POSTROUTING -p tcp --dport 8080 -j DNAT --to :80

I get: "iptables: Invalid argument".

What I want is only to translate destination port of all TCP-packets going to some_ip:8080 into some_ip:80. I don't want to change IP. It seems that syntax of this command is corrent, but... What is wrong?

Thanks!

P.S.: Kernel 2.4.31, iptables v1.3.2

Signature · 2 lines
Best regards,
 Oleg
#1 lore raw
Quoted 8 lines · Oleg A. Arkhangelsky

Hello All,

When I'm trying to do something like this:

iptables -t nat -I POSTROUTING -p tcp --dport 8080 -j DNAT --to :80

I get: "iptables: Invalid argument".

Quoted 10 lines

What I want is only to translate destination port of all TCP-packets going to some_ip:8080 into some_ip:80. I don't want to change IP. It seems that syntax of this command is corrent, but... What is wrong?

Thanks!

P.S.: Kernel 2.4.31, iptables v1.3.2

If you want to do that you should read the iptables-tutorial.frozentux.net, then use the REDIRECT target:
iptables -t nat -A PREROUTING -p tcp --dport 8080 -j REDIRECT --to 80

regards,
Georgi Alexandrov

#2 lore raw

Hello Georgi,

Saturday, November 26, 2005, 1:20:09 PM, you wrote:

GA> If you want to do that you should read the
GA> iptables-tutorial.frozentux.net, then use the REDIRECT target:
GA> iptables -t nat -A PREROUTING -p tcp --dport 8080 -j REDIRECT --to 80

Thank you very much! My error was that I use POSTROUTING instead of PREROUTING with DNAT.

Signature · 2 lines
Best regards,
 Oleg