INVALID state
iptables allows querying for 4 states: NEW, ESTABLISHED, RELATED, INVALID The first three are pretty obvious.
What exactly are the semantics of the INVALID state ?
My setup involves a firewall on a bridge and a dual-NIC protected machine
Network A -- Protected machine -- Network B -- Firewall
The protected machine has asymmetric routing. A ping arriving via network A is replied via network B. The reply packet is seen as part of an INVALID connection.
Same thing happens for a SYN packet from network A, which leads to a SYN-ACK on network B.
I read somewhere that an ACK packet belonging to a non-existing connection, for example, will be in NEW state. I was assuming that SYN-ACK will behave the same.
So when is a connection considered INVALID ?
P.S: By now this is a theoretical question, as the asymmetric routing was a misconfiguration. Nevertheless, I am trying to understand what happened.
I don't really understand your setup description, but asymmetric routing often leads to problems with stateful inspection firewalls, as both directions of a conversation need to go through the same firewall for connection tracking to work.
For instance, if your ICMP echo request doesn't go through your firewall, how can the stateful inspection know
about the echo reply to be expected? Also, if the firewall doesn't see the initial TCP SYN packet, but the SYN-ACK goes through the firewall, it clearly shouldn't allow that through.
The iptables connection pickup feature is, depending on your point of view, a bad hack to make up for iptables' (now historic) lack of a state synching mechanism like OpenBSD's pfsync.
Or a rather nice feature that keeps the scalability of independent netfilter boxen running in parallel, while allowing some kind of fail over capability that works in many to most cases while incurring only small security drawbacks.
It's definitely not a mechanism to deal with asymmetric routing though, AFAIK a pickup only happens when you see traffic in both directions, which doesn't happen when one part of your conversation doesn't go through your filtering box.
Quoted 27 lines · Gilad Benjamini
iptables allows querying for 4 states: NEW, ESTABLISHED, RELATED, INVALID The first three are pretty obvious.
What exactly are the semantics of the INVALID state ?My setup involves a firewall on a bridge and a dual-NIC protected machine
Network A -- Protected machine -- Network B -- Firewall
The protected machine has asymmetric routing. A ping arriving via network A is replied via network B. The reply packet is seen as part of an INVALID connection.
Same thing happens for a SYN packet from network A, which leads to a SYN-ACK on network B.I read somewhere that an ACK packet belonging to a non-existing connection, for example, will be in NEW state. I was assuming that SYN-ACK will behave the same.
So when is a connection considered INVALID ?
P.S: By now this is a theoretical question, as the asymmetric routing was a misconfiguration. Nevertheless, I am trying to understand what happened.--
To unsubscribe from this list: send the line "unsubscribe netfilter" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Hi,
Quoted 5 lines · Thomas Jacob
For instance, if your ICMP echo request doesn't go through your firewall, how can the stateful inspection know
about the echo reply to be expected? Also, if the firewall doesn't see the initial TCP SYN packet, but the SYN-ACK goes through the firewall, it clearly shouldn't allow that through.
as I'm currently trying to understand the netfilter implementation, I tried to find the point, where the ICMP-Echo-Reply gets filtered.
In xt_state.c->match(...) I saw, that it detects the state XT_STATE_INVALID if there is no connection associated to the packet (skb->nfct). But in the ICMP connection tracker I don't find the point, that it doesn't tracks the echo- reply packets if no echo-request packet passed. I have the impression, that it will track the echo-reply as a NEW connection.
Could someone please point me to the code?
Thanks in advance,
--
Christoph Paasch
www.rollerbulls.be
--
Quoted 2 lines
In
xt_state.c->match(...)I saw, that it detects the stateXT_STATE_INVALIDif there is no connection associated to the packet (skb->nfct). But in the ICMP
To clarify, I wasn't making any specific claims related to Gilad's problem on how exactly ICMP connections fail with an asymmetric routing setup, just that asymmetric routing causes problems like this in general.
However, an initial SYN-ACK packet in a TCP connection for instance, definitely is considered invalid (see the tcp_conntracks array in netfilter/nf_conntrack_proto_tcp.c).
For ICMP packets, I think icmp_new in nf_conntrack_proto_icmp.c doesn't allow an echo request for the creation of a new conntrack, but I'm not so sure.
But I was also having something like this in mind:
-P FORWARD DROP
-A FORWARD -m state --state ESTABLISHED, RELATED -j ACCEPT -A FORWARD --state NEW -p icmp --icmp-type echo-request
If your initial packet echo-request doesn't pass through the firewall, the echo reply will be blocked, even if the conntrack code wouldn't classify a sole echo reply as INVALID.
Hi,
thanks for the fast answer...
Quoted 3 lines · Thomas Jacob
For ICMP packets, I think
icmp_newinnf_conntrack_proto_icmp.cdoesn't allow an echo request for the creation of a new conntrack, but I'm not so sure.
That's true, it checks, if the type of the ICMP is one of valid_new (containing ECHO, TIMESTAMP, INFO_REQUEST and ADDRESS)
--
Christoph Paasch
www.rollerbulls.be
--