Skip to contentSkip to conversation

FORWARDING and NAT chains

DISCUSSION Srinivasa Hebbar 4 participants 6 messages Jan 29, 2004 – Jan 30, 2004

lore
Share & tools
lore
#0 lore raw

Hello,

I believe that the NAT PREROUTING and POSTROUTING will always takes place for all the incoming/outgoing packets irrespective of whether the packet is destined to the node or not.

I have a situvation that if the dest. IP address of the packet is for the local node, then apply NAT rule, otherwise it should simply forward the packet according to the routing table.

How can I achive the above?

Any help is very much appreciated.

Regards,
S. Hebbar.

#1 lore raw
Quoted 6 lines · Srinivasa Hebbar

Hello,

I believe that the NAT PREROUTING and POSTROUTING will always takes place for all the incoming/outgoing packets irrespective of whether the packet is destined to the node or not.

Quoted 6 lines

I have a situvation that if the dest. IP address of the packet is for the local node, then apply NAT rule, otherwise it should simply forward the packet according to the routing table.

How can I achive the above?

Use the INPUT chain of the nat table.

Quoted 4 lines

Any help is very much appreciated.

Regards,
S. Hebbar.

Signature · 7 lines
--
Raymond Leach <[email protected]>
Network Support Specialist
http://www.knowledgefactory.co.za
"lynx -source http://www.rchq.co.za/raymondl.asc | gpg --import"
Key fingerprint = 7209 A695 9EE0 E971 A9AD  00EE 8757 EE47 F06F FB28
--
#2 lore raw
Quoted 7 lines · Ray Leach
Quoted 6 lines · Srinivasa Hebbar

Hello,

I believe that the NAT PREROUTING and POSTROUTING will always takes place for all the incoming/outgoing packets irrespective of whether the packet is destined to the node or not.

Quoted 7 lines
Quoted 5 lines

I have a situvation that if the dest. IP address of the packet is for the local node, then apply NAT rule, otherwise it should simply forward the packet according to the routing table.

How can I achive the above?

Use the INPUT chain of the nat table.

What does this mean? nat can be done in PREROUTING or POSTROUTING (as
Srinivasa correctly said). You cannot do nat in INPUT.

Antony.

Signature · 6 lines
Anything that improbable is effectively impossible.

 - Murray Gell-Mann, Novel Prizewinner in Physics

                                                     Please reply to the list;
                                                           please don't CC me.
#3 lore raw
In reply to Srinivasa Hebbar
Quoted 11 lines · Srinivasa Hebbar

Hello,

I believe that the NAT PREROUTING and POSTROUTING will always takes place for all the incoming/outgoing packets irrespective of whether the packet is destined to the node or not.

I have a situvation that if the dest. IP address of the packet is for the local node, then apply NAT rule, otherwise it should simply forward the packet according to the routing table.

How can I achive the above?

Place the destination address in the nat rule, eg:

iptables -A PREROUTING -t nat -d ! my.ip.add.ress -j DNAT --to a.b.c.d

This means "destination nat all packets which are not addressed to my.ip.add.ress and send them to a.b.c.d".

Regards,

Antony.

Signature · 7 lines
"The joy of X!!??  I've always hated compiling graphical shite.  You have a 10 
line program, and it ends up depending on the entire known universe."

 - Philip Hands

                                                     Please reply to the list;
                                                           please don't CC me.
#4 lore raw
Quoted 16 lines · Antony Stone
Quoted 11 lines · Srinivasa Hebbar

Hello,

I believe that the NAT PREROUTING and POSTROUTING will always takes place for all the incoming/outgoing packets irrespective of whether the packet is destined to the node or not.

I have a situvation that if the dest. IP address of the packet is for the local node, then apply NAT rule, otherwise it should simply forward the packet according to the routing table.

How can I achive the above?

Place the destination address in the nat rule, eg:

Quoted 8 lines

iptables -A PREROUTING -t nat -d ! my.ip.add.ress -j DNAT --to a.b.c.d

This means "destination nat all packets which are not addressed to my.ip.add.ress and send them to a.b.c.d".

Regards,

Antony.

This is true but she went on to state in a later e-mail that she has many interfaces and needs to exclude two. That's a knarly problem I've run into many times with the limitation of only being able to specify a single address/subnet (or a contiguous range with iprange) in destination and source.

I suggested using a RETURN target to bypass processing for the two excluded interfaces although I was surprised to not find RETURN in my man page. I hope I wasn't having a premature senior moment when I recalled the RETURN target! Thanks - John

Signature · 5 lines
John A. Sullivan III
Chief Technology Officer
Nexus Management
+1 207-985-7880
[email protected]
#5 lore raw
Quoted 15 lines · John A. Sullivan III
Quoted 7 lines · Antony Stone

Place the destination address in the nat rule, eg:

iptables -A PREROUTING -t nat -d ! my.ip.add.ress -j DNAT --to a.b.c.d

This means "destination nat all packets which are not addressed to my.ip.add.ress and send them to a.b.c.d".

This is true but she went on to state in a later e-mail that she has many interfaces and needs to exclude two. That's a knarly problem I've run into many times with the limitation of only being able to specify a single address/subnet (or a contiguous range with iprange) in destination and source.

Quoted 4 lines

I suggested using a RETURN target to bypass processing for the two excluded interfaces although I was surprised to not find RETURN in my man page. I hope I wasn't having a premature senior moment when I recalled the RETURN target! Thanks - John

Oh, okay - try using ACCEPT in the nat table to stop packets continuing to later rules..

RETURN is only valid for user-defined chains (I think).

Regards,

Antony.

Signature · 7 lines
Behind the counter a boy with a shaven head stared vacantly into space,
a dozen spikes of microsoft protruding from the socket behind his ear.

 - William Gibson, Neuromancer (1984)

                                                     Please reply to the list;
                                                           please don't CC me.