Skip to contentSkip to conversation

nat "regression" in 2.4.23-pre and 2.5/6

DISCUSSION Duncan Sands 3 participants 4 messages Sep 24, 2003

lore
Share & tools
lore
#0 lore raw

It used to be possible to use the masquerade target with user defined chains in the nat table. For example, shorewall does

iptables -t nat -A ppp0_masq -s 192.168.0.0/24 -d 0.0.0.0/0 -j MASQUERADE

where ppp0_masq is a user defined chain. This no longer works with the 2.4.23-pre kernels (it hasn't worked with 2.5 for a while): iptables: invalid argument.

All is OK if you substitute POSTROUTING for the user defined chain ppp0_masq. The man page for iptables states:

MASQUERADE
This target is only valid in the nat table, in the POSTROUTING chain.

So it looks like a check has been put into the netfilter code to enforce what the documentation states: only the POSTROUTING chain may be used.

But why? Is there any harm in using masquerade with user defined chains?

Here is a comment from Tom Eastep (shorewall author):

"It might be worth pointing out that by taking this strict interpretation of the documented behavior, user chains in the nat table are rendered useless. If the SNAT, DNAT and MASQUERADE targets can only be placed in the appropriate netfilter-define chains then there is no conceivable use for user-defined chains in that table."

Duncan.

#1 lore raw

I also encountered this sort of problem, but in a vanilla shorewall; As I recall, it turned out that something is/was screwy with the way modules.dep is created... a lot of the iptables modules became dependent on ipchains.o. I recompiled my kernel without the ipchains and ipfwadm modules and things appear to work again.

Note: I only *think* this is what was wrong! :-) :-)

- david

Quoted 30 lines · Duncan Sands

It used to be possible to use the masquerade target with user defined chains in the nat table. For example, shorewall does

iptables -t nat -A ppp0_masq -s 192.168.0.0/24 -d 0.0.0.0/0 -j MASQUERADE

where ppp0_masq is a user defined chain. This no longer works with the 2.4.23-pre kernels (it hasn't worked with 2.5 for a while): iptables: invalid argument.

All is OK if you substitute POSTROUTING for the user defined chain ppp0_masq. The man page for iptables states:

MASQUERADE
This target is only valid in the nat table, in the POSTROUTING chain.

So it looks like a check has been put into the netfilter code to enforce what the documentation states: only the POSTROUTING chain may be used.

But why? Is there any harm in using masquerade with user defined chains?

Here is a comment from Tom Eastep (shorewall author):

"It might be worth pointing out that by taking this strict interpretation of the documented behavior, user chains in the nat table are rendered useless. If the SNAT, DNAT and MASQUERADE targets can only be placed in the appropriate netfilter-define chains then there is no conceivable use for user-defined chains in that table."

Duncan.

Signature · 12 lines
------------------------------------------
David Chambers
Core Cytometry and Molecular Imaging
The Salk Institute
10010 North Torrey Pines Road
La Jolla, CA  92037-1099

Tel:	(858) 453-4100 x1728
Fax:	(858) 453-9681
Email:	[email protected]
Web:	http://pingu.salk.edu/~davidc/
------------------------------------------
#2 lore raw
In reply to Duncan Sands
Quoted 4 lines · Duncan Sands

where ppp0_masq is a user defined chain. This no longer works with the 2.4.23-pre kernels (it hasn't worked with 2.5 for a while): iptables: invalid argument.

I've now caught up with Duncan and have built a 2.4.23-pre5 kernel. Running that kernel on my firewall, I'm not seeing the behavior that Duncan is experiencing. My iptables is from RH Rawhide (1.2.8-8.80.2).

-Tom
--
Tom Eastep \ Nothing is foolproof to a sufficiently talented fool
Shoreline, \ http://shorewall.net
Washington USA \ [email protected]

#3 lore raw
Quoted 8 lines · Tom Eastep
Quoted 3 lines · Duncan Sands

where ppp0_masq is a user defined chain. This no longer works with the 2.4.23-pre kernels (it hasn't worked with 2.5 for a while): iptables:
invalid argument.

I've now caught up with Duncan and have built a 2.4.23-pre5 kernel. Running that kernel on my firewall, I'm not seeing the behavior that Duncan is experiencing. My iptables is from RH Rawhide (1.2.8-8.80.2).

Interesting - I will look into it tomorrow. Maybe it is just a bug after all.

Good night!

Duncan.