Skip to contentSkip to conversation

DNAT query

DISCUSSION Payal Rathod 3 participants 8 messages Nov 11, 2005

lore
Share & tools
lore
#0 lore raw

Hi,
I am trying to redirect trafffic from outside to an internal machine. The setup is SuSE Linux 9.1 (i586) 2.6.4-52-default

# iptables --version
iptables v1.2.9

When I give,

# iptables -t nat -I OUTPUT -d dyn.example.com -p tcp --dport 8000 -j DNAT --to-destination 192.168.10.2:8000
iptables: Target problem

What exactly is wrong? If I try it on my Mandrake box it works. Any ideas?
Thanks in advance.
With warm regards,
-Payal

#1 lore raw
Quoted 6 lines · Payal Rathod

Hi,
I am trying to redirect trafffic from outside to an internal machine. The setup is SuSE Linux 9.1 (i586) 2.6.4-52-default

# iptables --version
iptables v1.2.9
Quoted 7 lines

When I give,

# iptables -t nat -I OUTPUT -d dyn.example.com -p tcp --dport 8000 -j
DNAT --to-destination 192.168.10.2:8000
iptables: Target problem

What exactly is wrong? If I try it on my Mandrake box it works. Any ideas?

Can't say that I've had any problems with this. Try:

iptables -t nat -I PREROUTING -d dyn.example.com -p tcp --dport 8000 \
-j DNAT --to-destination 192.168.10.2:8000

Gr,
Rob

#2 lore raw
Quoted 2 lines · Rob Sterenborg

iptables -t nat -I PREROUTING -d dyn.example.com -p tcp --dport 8000 \
-j DNAT --to-destination 192.168.10.2:8000

This does work (sorry I should have mentioned it before). But I also need the OUTPUT rule too, right?

With warm regards,
-Payal

#3 lore raw
In reply to Payal Rathod
Quoted 6 lines · Payal Rathod

Hi,
I am trying to redirect trafffic from outside to an internal machine. The setup is SuSE Linux 9.1 (i586) 2.6.4-52-default

# iptables --version
iptables v1.2.9
Quoted 6 lines

When I give,

# iptables -t nat -I OUTPUT -d dyn.example.com -p tcp --dport 8000 -j DNAT --to-destination 192.168.10.2:8000
iptables: Target problem

What exactly is wrong? If I try it on my Mandrake box it works. Any ideas?

Some time ago I had a similar problem with SLES8 and nat/OUTPUT. The reason was, that is was the _only_ netfilter optio, that wasn't compiled into the kernel :) I generally don't work with SuSE, so I don't know. Bur maybe they still don't compile it as a kernel module.

HTH,

Joerg

#4 lore raw
In reply to Payal Rathod
Quoted 6 lines · Payal Rathod

Hi,
I am trying to redirect trafffic from outside to an internal machine. The setup is SuSE Linux 9.1 (i586) 2.6.4-52-default

# iptables --version
iptables v1.2.9
Quoted 6 lines

When I give,

# iptables -t nat -I OUTPUT -d dyn.example.com -p tcp --dport 8000 -j DNAT --to-destination 192.168.10.2:8000
iptables: Target problem

What exactly is wrong? If I try it on my Mandrake box it works. Any ideas?

Some time ago I had a similar problem with SLES8 and nat/OUTPUT. The reason was, that is was the _only_ netfilter optio, that wasn't compiled into the kernel :) I generally don't work with SuSE, so I don't know. Bur maybe they still don't compile it as a kernel module.

HTH,

Joerg

#5 lore raw
Quoted 4 lines · J?rg Harmuth

Some time ago I had a similar problem with SLES8 and nat/OUTPUT. The reason was, that is was the _only_ netfilter optio, that wasn't compiled into the kernel :) I generally don't work with SuSE, so I don't know. Bur maybe they still don't compile it as a kernel module.

So what do you suggest? How do I use it now? Do I have to recomiple te kernel for that? I never done that before.
With warm regards,
-Payal

#6 lore raw
Quoted 8 lines · Payal Rathod
Quoted 4 lines · J?rg Harmuth

Some time ago I had a similar problem with SLES8 and nat/OUTPUT. The reason was, that is was the _only_ netfilter optio, that wasn't compiled into the kernel :) I generally don't work with SuSE, so I don't know. Bur maybe they still don't compile it as a kernel module.

Quoted 4 lines

So what do you suggest? How do I use it now? Do I have to recomiple te kernel for that? I never done that before.
With warm regards,
-Payal

It depends. But as Robs solution works for you, it looks like you only need to redirect/forward connections (roughly: PREROUTING -> FORWARD -> POSTROUTING). You only need nat/OUTPUT for packets, generated on the firewall itself (roughly: local process -> OUTPUT -> POSTROUTING). If you need to redirect locally generated packets *and* nat/OUTPUT isn't compiled - well, yes then you have to compile the module from the kernel sources (which in this case is simple, because you only have to enable one option).

HTH,

Joerg

#7 lore raw
Quoted 4 lines · J?rg Harmuth

It depends. But as Robs solution works for you, it looks like you only need to redirect/forward connections (roughly: PREROUTING -> FORWARD -> POSTROUTING). You only need nat/OUTPUT for packets, generated on the firewall itself (roughly: local process -> OUTPUT -> POSTROUTING). If

[...]

I am sorry but you lost me here. Can you give the complete ruleset which I need now. I always thought I needed PREROUTING as well as OUTPUT. Thanks in advance.
With warm regards,
-Payal