Skip to contentSkip to conversation

IPTables design question (nat)

DISCUSSION Aki Karjalainen 2 participants 2 messages Nov 1, 2002 – Nov 2, 2002

lore
Share & tools
lore
#0 lore raw

Hi.

I've got a question about IPTables.

Let's say I want to "hide" a public IP pool (e.g. 144.50.50.0/24) behing NAT. Easy.

Let's say I want to provide SMTP port from LAN to the outside world. I'd say "-t nat -A PREROUTING -p tcp -d FWexternalIP --dport smtp -j DNAT --to 144.50.50.12:smtp".

Ok, I'd still have to allow the connection in the BAD-GOOD chain for this to work.

The result is that the outside world sees the smtp port from the firewall external IP _as well as_ directly from 144.50.50.12.

The question is how to hide 144.50.50.12:smtp but still allow firewall external ip:smtp (DNATted port)?

Summary: How to DNAT some port and still hide the destination IP+port in the case the real destination IP is a public IP address?

#1 lore raw
Quoted 10 lines · Aki Karjalainen

Hi.

I've got a question about IPTables.

Let's say I want to "hide" a public IP pool (e.g. 144.50.50.0/24) behing NAT. Easy.

Let's say I want to provide SMTP port from LAN to the outside world. I'd say "-t nat -A PREROUTING -p tcp -d FWexternalIP --dport smtp -j DNAT --to 144.50.50.12:smtp".

Looks good. You might want to add a "-i FWextIF" so you only catch packets
from the outside, not the inside, but it's not too important...

Quoted 2 lines

Ok, I'd still have to allow the connection in the BAD-GOOD chain for this to work.

Yes, you need to forward the packets and the replies.

Quoted 2 lines

The result is that the outside world sees the smtp port from the firewall external IP _as well as_ directly from 144.50.50.12.

I don't understand this bit. The fact that you are translating the address
means that to people on the outside, it is only the FW ext address which is
visible, let alone offering any services. In order for the internal address
144.50.50.12 to be visible to the outside world, you would have to be forwarding those through your firewall without any NAT (and this address would need to be routed to you by your ISP too)

Quoted 2 lines

The question is how to hide 144.50.50.12:smtp but still allow firewall external ip:smtp (DNATted port)?

Does my explanation above answer your question ?

Antony.

Signature · 4 lines
Perfection in design is achieved not when there is nothing left to add,
but rather when there is nothing left to take away.

 - Antoine de Saint-Exupery