Skip to contentSkip to conversation

nat drop the icmp redirect packet

DISCUSSION Gao feng 2 participants 9 messages Nov 28, 2011 – Dec 5, 2011 netfilter

lore
Share & tools
lore

Gao feng

author
#0 lore raw

Hi

In func nf_nat_icmp_reply_translation,the icmp packet will be droped when the nat is not finished. pc A(whose gateway is C) send a icmp request to pc B.
When gw C receive this packet,it may return a icmp redirect packet to A.
BUT now,the icmp request packet has not go to POSTROUTING,So the nat is not finished. Finally,the icmp redirect packet will be droped no matter the conn has nat or not.

of course,the icmp redirect packet will be correct handled when nat is finished.

Can somebody will give me some suggestion,
or should I just add a sysctl to let the user decide drop or receive this icmp redirect packet when nat is not finished?

author
#1 lore raw
Quoted 8 lines · Gao feng

Hi

In func nf_nat_icmp_reply_translation,the icmp packet will be droped when the nat is not finished. pc A(whose gateway is C) send a icmp request to pc B.
When gw C receive this packet,it may return a icmp redirect packet to A.
BUT now,the icmp request packet has not go to POSTROUTING,So the nat is not finished. Finally,the icmp redirect packet will be droped no matter the conn has nat or not.

Quoted 9 lines

of course,the icmp redirect packet will be correct handled when nat is finished.

Can somebody will give me some suggestion,
or should I just add a sysctl to let the user decide drop or receive this icmp redirect packet when nat is not finished? --
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

or maybe we can move the ip_rt_send_redirect from FORWARD to POSTROUTING? --
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

author
#2 lore raw

Hi pablo
what's your idea?

Quoted 3 lines

or maybe we can move the ip_rt_send_redirect from FORWARD to POSTROUTING? --

#3 lore raw
In reply to Gao feng
Quoted 8 lines · Gao feng

Hi

In func nf_nat_icmp_reply_translation,the icmp packet will be droped when the nat is not finished. pc A(whose gateway is C) send a icmp request to pc B.
When gw C receive this packet,it may return a icmp redirect packet to A.
BUT now,the icmp request packet has not go to POSTROUTING,So the nat is not finished. Finally,the icmp redirect packet will be droped no matter the conn has nat or not.

Quoted 4 lines

of course,the icmp redirect packet will be correct handled when nat is finished.

Can somebody will give me some suggestion,
or should I just add a sysctl to let the user decide drop or receive this icmp redirect packet when nat is not finished?

It doesn't matter whether the ICMP packet has gone through POST_ROUTING, the conntrack associated with the packet is that of the original packet causing the ICMP REDIRECT (or any other kind of ICMP error).

Basically, we don't want hosts talking directly to each other *if* NAT has been set up since that would obviously break things. In the case you describe (only destination NAT setup completed, but null mapping) instead of dropping the packet, we could set up a null source mapping and let the packet through under the assumption that the hosts will then start communicating directly.

This will break if the host receiving the ICMP REDIRECT ignores it though. What is the specific problem you're trying to solve?

author
#4 lore raw
Quoted 27 lines · Patrick McHardy
Quoted 8 lines · Gao feng

Hi

In func nf_nat_icmp_reply_translation,the icmp packet will be droped when the nat is not finished. pc A(whose gateway is C) send a icmp request to pc B.
When gw C receive this packet,it may return a icmp redirect packet to A.
BUT now,the icmp request packet has not go to POSTROUTING,So the nat is not finished. Finally,the icmp redirect packet will be droped no matter the conn has nat or not.

Quoted 4 lines

of course,the icmp redirect packet will be correct handled when nat is finished.

Can somebody will give me some suggestion,
or should I just add a sysctl to let the user decide drop or receive this icmp redirect packet when nat is not finished?

It doesn't matter whether the ICMP packet has gone through POST_ROUTING, the conntrack associated with the packet is that of the original packet causing the ICMP REDIRECT (or any other kind of ICMP error).

Basically, we don't want hosts talking directly to each other *if* NAT has been set up since that would obviously break things. In the case you describe (only destination NAT setup completed, but null mapping) instead of dropping the packet, we could set up a null source mapping and let the packet through under the assumption that the hosts will then start communicating directly.

Quoted 3 lines

This will break if the host receiving the ICMP REDIRECT ignores it though. What is the specific problem you're trying to solve?

Thanks Patrick!

As I said,in my case,the *first* ICMP REDIRECT packet will be dropped even the system has no nat rules,because this REDIRECT packet is triggered by the original packet in FORWARD chain(ip_forward),and when this REDIRECT packet goto POSTROUTING chian(nf_nat_fn->nf_nat_icmp_reply_translation),the original packet is still in FORWARD chain.So the original packet's conntrack ONLY has IPS_DST_NAT_DONE.

I understand your mean,we should not let REDIRECT to take effect when this conntrack has nat rule.

I just want to know is there some idea to avoid the first ICMP_REDIRECT packet being dropped?

--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#5 lore raw
Quoted 39 lines · Gao feng
Quoted 26 lines · Patrick McHardy
Quoted 8 lines · Gao feng

Hi

In func nf_nat_icmp_reply_translation,the icmp packet will be droped when the nat is not finished. pc A(whose gateway is C) send a icmp request to pc B.
When gw C receive this packet,it may return a icmp redirect packet to A.
BUT now,the icmp request packet has not go to POSTROUTING,So the nat is not finished. Finally,the icmp redirect packet will be droped no matter the conn has nat or not.

Quoted 4 lines

of course,the icmp redirect packet will be correct handled when nat is finished.

Can somebody will give me some suggestion,
or should I just add a sysctl to let the user decide drop or receive this icmp redirect packet when nat is not finished?

It doesn't matter whether the ICMP packet has gone through POST_ROUTING, the conntrack associated with the packet is that of the original packet causing the ICMP REDIRECT (or any other kind of ICMP error).

Basically, we don't want hosts talking directly to each other *if* NAT has been set up since that would obviously break things. In the case you describe (only destination NAT setup completed, but null mapping) instead of dropping the packet, we could set up a null source mapping and let the packet through under the assumption that the hosts will then start communicating directly.

Quoted 3 lines

This will break if the host receiving the ICMP REDIRECT ignores it though. What is the specific problem you're trying to solve?

Thanks Patrick!

As I said,in my case,the *first* ICMP REDIRECT packet will be dropped even the system has no nat rules,because this REDIRECT packet is triggered by the original packet in FORWARD chain(ip_forward),and when this REDIRECT packet goto POSTROUTING chian(nf_nat_fn->nf_nat_icmp_reply_translation),the original packet is still in FORWARD chain.So the original packet's conntrack ONLY has IPS_DST_NAT_DONE.

Quoted 4 lines

I understand your mean,we should not let REDIRECT to take effect when this conntrack has nat rule.

I just want to know is there some idea to avoid the first ICMP_REDIRECT packet being dropped

Yes, as I said, we could set up a NULL source mapping on the conntrack of the original packet and let the REDIRECT through. The user might have configured a source NAT rule though which would become ineffective by this.

--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

author
#6 lore raw
Quoted 5 lines · Patrick McHardy

Yes, as I said, we could set up a NULL source mapping on the conntrack of the original packet and let the REDIRECT through. The user might have configured a source NAT rule though which would become ineffective by this.

Hi Patrick:

Yes,you are right.

You mean we have no idea of the ICMP REDIRECT packet being droppen when nat is not finished?

--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#7 lore raw
Quoted 7 lines · Gao feng
Quoted 5 lines · Patrick McHardy

Yes, as I said, we could set up a NULL source mapping on the conntrack of the original packet and let the REDIRECT through. The user might have configured a source NAT rule though which would become ineffective by this.

Quoted 6 lines

Hi Patrick:

Yes,you are right.

You mean we have no idea of the ICMP REDIRECT packet being droppen when nat is not finished?

We can't determine whether we could let it through at that point. The safe choice is to drop it.
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

author
#8 lore raw
Quoted 10 lines · Patrick McHardy
Quoted 9 lines · Gao feng
Quoted 5 lines · Patrick McHardy

Yes, as I said, we could set up a NULL source mapping on the conntrack of the original packet and let the REDIRECT through. The user might have configured a source NAT rule though which would become ineffective by this.

Hi Patrick:

Quoted 8 lines
Quoted 4 lines

Yes,you are right.

You mean we have no idea of the ICMP REDIRECT packet being droppen when nat is not finished?

We can't determine whether we could let it through at that point. The safe choice is to drop it.
--

Good Morning Patrick

I got it,thank you very much.

--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html