/proc/net/ip_conntrack trange behavior
Hi, all
When I checked /proc/net/ip_conntrack in my Linux server, I found some
strange tracks like the following:
[normal case]
tcp 6 387113 ESTABLISHED src=219.135.189.40 dst=58.60.9.41
sport=2391 dport=443 src=58.60.9.41 dst=219.135.189.40 sport=443 dport=2391 [ASSURED] use=1
[strange track]
tcp 6 377231 ESTABLISHED src=222.173.17.207 dst=219.135.189.11
sport=19691 dport=3815 [UNREPLIED] src=219.135.189.11 dst=222.173.17.207 sport=3815 dport=19691 use=1
As we kown after SYN->SYN,ACK->ACK. TCP connection is in ESTABLISHED state. and the ip_conntrack "see" the REPLY direction packet, I think the conntrak should be ASSURED. not UNREPLIED.
So, pls help me. My kernel version is 2.4.22
Thanks in advance :-)
From: Dong_Wei <[email protected]>
Date: Fri, 24 Aug 2007 15:43:01 +0800
Quoted 14 lines
Hi, all
When I checked/proc/net/ip_conntrackin my Linux server, I found some
strange tracks like the following:[normal case]
tcp 6 387113 ESTABLISHED src=219.135.189.40 dst=58.60.9.41
sport=2391 dport=443 src=58.60.9.41 dst=219.135.189.40 sport=443 dport=2391 [ASSURED] use=1[strange track]
tcp 6 377231 ESTABLISHED src=222.173.17.207 dst=219.135.189.11
sport=19691 dport=3815 [UNREPLIED] src=219.135.189.11 dst=222.173.17.207 sport=3815 dport=19691 use=1
Quoted 8 lines
As we kown after SYN->SYN,ACK->ACK. TCP connection is in ESTABLISHED state. and the
ip_conntrack"see" the REPLY direction packet, I think the conntrak should be ASSURED. not UNREPLIED.So, pls help me. My kernel version is 2.4.22
Thanks in advance :-)
When only SYN and SYN/ACK are detected by ip_conntrack, the state of the connection is ESTABLISHED. Please note that 'ESTABLISHED' is not TCP state, but generic connection state.
-- Yasuyuki Kozakai
Quoted 21 lines · Yasuyuki KOZAKAI
From:
Dong_Wei<[email protected]>
Date: Fri, 24 Aug 2007 15:43:01 +0800Quoted 18 lines
Hi, all
When I checked/proc/net/ip_conntrackin my Linux server, I found some
strange tracks like the following:[normal case]
tcp 6 387113 ESTABLISHED src=219.135.189.40 dst=58.60.9.41
sport=2391 dport=443 src=58.60.9.41 dst=219.135.189.40 sport=443 dport=2391 [ASSURED] use=1[strange track]
tcp 6 377231 ESTABLISHED src=222.173.17.207 dst=219.135.189.11
sport=19691 dport=3815 [UNREPLIED] src=219.135.189.11 dst=222.173.17.207 sport=3815 dport=19691 use=1As we kown after SYN->SYN,ACK->ACK. TCP connection is in ESTABLISHED state. and the
ip_conntrack"see" the REPLY direction packet, I think the conntrak should be ASSURED. not UNREPLIED.
Quoted 8 lines
Quoted 4 lines
So, pls help me. My kernel version is 2.4.22
Thanks in advance :-)
When only SYN and SYN/ACK are detected by
ip_conntrack, the state of the connection is ESTABLISHED. Please note that 'ESTABLISHED' is not TCP state, but generic connection state.
Well, its TCP connection state. Whats probably happening is that you have connection pickup enabled, in which case a single ACK can lead to TCP ESTABLISHED state. It won't match "-m state --state ESTABLISHED" though.
Thanks a lot. Yasuyuki and kaber
I have looked the 2.6.20 kernel and found that the reason.
When ip_conntrack try to pick up an ESTABLISHED TCP connection, this issue will happen.
2.6 set an 'sysctl' value to deal with this situation
static int tcp_new()
{
...snip...
if (new_state == TCP_CONNTRACK_SYN_SENT) {
do_something();
} else if (ip_ct_tcp_loose == 0) {
/* Don't try to pick up connections. */
return 0;
} else {
do_something();
}
}And we can't avoid this issue on 2.4, because no code deal with the special case.
Thanks!
Quoted 37 lines
Quoted 21 lines · Yasuyuki KOZAKAI
From:
Dong_Wei<[email protected]>
Date: Fri, 24 Aug 2007 15:43:01 +0800Quoted 18 lines
Hi, all
When I checked/proc/net/ip_conntrackin my Linux server, I found
some strange tracks like the following:[normal case]
tcp 6 387113 ESTABLISHED src=219.135.189.40 dst=58.60.9.41
sport=2391 dport=443 src=58.60.9.41 dst=219.135.189.40 sport=443 dport=2391 [ASSURED] use=1[strange track]
tcp 6 377231 ESTABLISHED src=222.173.17.207 dst=219.135.189.11
sport=19691 dport=3815 [UNREPLIED] src=219.135.189.11 dst=222.173.17.207 sport=3815 dport=19691 use=1As we kown after SYN->SYN,ACK->ACK. TCP connection is in ESTABLISHED state. and the
ip_conntrack"see" the REPLY direction packet, I think the conntrak should be ASSURED. not UNREPLIED.Quoted 8 lines
Quoted 4 lines
So, pls help me. My kernel version is 2.4.22
Thanks in advance :-)
When only SYN and SYN/ACK are detected by
ip_conntrack, the state of the connection is ESTABLISHED. Please note that 'ESTABLISHED' is not TCP state, but generic connection state.Well, its TCP connection state. Whats probably happening is that you have connection pickup enabled, in which case a single ACK can lead to TCP ESTABLISHED state. It won't match "-m state --state ESTABLISHED" though.
Quoted 5 lines · Dong_Wei
Thanks a lot. Yasuyuki and kaber
I have looked the 2.6.20 kernel and found that the reason.
When
ip_conntracktry to pick up an ESTABLISHED TCP connection, this issue will happen.
Exactly.
Quoted 5 lines
2.6 set an 'sysctl' value to deal with this situation
[..]
And we can't avoid this issue on 2.4, because no code deal with the special case.
Thats correct. Is there a problem with this behaviour?
Hi Yasuyuki san
Quoted 10 lines
Quoted 5 lines · Dong_Wei
Thanks a lot. Yasuyuki and kaber
I have looked the 2.6.20 kernel and found that the reason.
When
ip_conntracktry to pick up an ESTABLISHED TCP connection, this issue will happen.Exactly.
Quoted 8 lines
Quoted 5 lines
2.6 set an 'sysctl' value to deal with this situation
[..]
And we can't avoid this issue on 2.4, because no code deal with the special case.
Thats correct. Is there a problem with this behaviour?
As we know, ip_conntrack has a hash_size to control the ip_conntrack record size. and if tcp in ESTABLISH, and ip_conntrack will keep it for 5 DAYs.
For exsample, a NAT server can handle 8000 connections, and if sometime, NAT server need reboot(6000 conntrack in ESTBLISHED state now). Also we set ip_conntrack allowing pickup ESTABLISHED tcp connection, when NAT server available again, ip_conntrack will take 6000 conntracks for the original connections. but actully these connections are INVALID for the web server, because the source ip is the private IPs,such as 192.168.0.1. and web server will not answer the client's request. But still the NAT server will keep the 6000 conntrack for 5 DAYs. And just 2000 conntracks can be used for the clients. If more than 2000 client want connect to some websites, some ip_conntrack will be droped.
BR. DongWei
Quoted 8 lines · Dong_Wei
Quoted 4 lines
Quoted 1 line
And we can't avoid this issue on 2.4, because no code deal with the special case.
Thats correct. Is there a problem with this behaviour?
As we know,
ip_conntrackhas ahash_sizeto control theip_conntrackrecord size. and if tcp in ESTABLISH, andip_conntrackwill keep it for 5 DAYs.For exsample, a NAT server can handle 8000 connections, and if sometime, NAT server need reboot(6000 conntrack in ESTBLISHED state now). Also we set
ip_conntrackallowing pickup ESTABLISHED tcp connection, when NAT server available again,ip_conntrackwill take 6000 conntracks for the original connections. but actully these connections are INVALID for the web server, because the source ip is the private IPs,such as 192.168.0.1. and web server will not answer the client's request. But still the NAT server will keep the 6000 conntrack for 5 DAYs. And just 2000 conntracks can be used for the clients. If more than 2000 client want connect to some websites, someip_conntrackwill be droped.
You can drop ACK packets in state NEW to avoid connection pickup.
Hi Patrick
Quoted 5 lines · Dong_Wei
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines
And we can't avoid this issue on 2.4, because no code deal with the special case.
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
Thats correct. Is there a problem with this behaviour?
As we know,
ip_conntrackhas ahash_sizeto control theip_conntrackrecord size. and if tcp in ESTABLISH, andip_conntrackwill keep it for 5 DAYs.For exsample, a NAT server can handle 8000 connections, and if sometime, NAT server need reboot(6000 conntrack in ESTBLISHED state now). Also we set
ip_conntrackallowing pickup ESTABLISHED tcp connection, when NAT server available again,ip_conntrackwill take 6000 conntracks for the original connections. but actully these connections are INVALID for the web server, because the source ip is the private IPs,such as 192.168.0.1. and web server will not answer the client's request. But still the NAT server will keep the 6000 conntrack for 5 DAYs. And just 2000 conntracks can be used for the clients. If more than 2000 client want connect to some websites, someip_conntrackwill be droped.You can drop ACK packets in state NEW to avoid connection pickup.
That's a good idea, I will make a patch for my own 2.4 Linux NAT server, thanks a lot :-)
Quoted 9 lines · Dong_Wei
Hi Patrick
Quoted 7 lines · Dong_Wei
Quoted 6 lines
Quoted 5 lines
Quoted 2 lines
And we can't avoid this issue on 2.4, because no code deal with the special case.
Thats correct. Is there a problem with this behaviour?
Quoted 7 lines
Quoted 6 lines
Quoted 3 lines
As we know,
ip_conntrackhas ahash_sizeto control theip_conntrackrecord size. and if tcp in ESTABLISH, andip_conntrackwill keep it for 5 DAYs.For exsample, a NAT server can handle 8000 connections, and if sometime, NAT server need reboot(6000 conntrack in ESTBLISHED state now). Also we set
ip_conntrackallowing pickup ESTABLISHED tcp connection, when NAT server available again,ip_conntrackwill take 6000 conntracks for the original connections. but actully these connections are INVALID for the web server, because the source ip is the private IPs,such as 192.168.0.1. and web server will not answer the client's request. But still the NAT server will keep the 6000 conntrack for 5 DAYs. And just 2000 conntracks can be used for the clients. If more than 2000 client want connect to some websites, someip_conntrackwill be droped.You can drop ACK packets in state NEW to avoid connection pickup.
That's a good idea, I will make a patch for my own 2.4 Linux NAT server, thanks a lot :-)
No need to, as all you should do is a proper iptables rule.
Best regards,
Krzysztof Olędzki
Hi
Quoted 13 lines · Dong_Wei
Quoted 12 lines
Hi Patrick
Quoted 9 lines · Dong_Wei
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
And we can't avoid this issue on 2.4, because no code deal with the special case.
Thats correct. Is there a problem with this behaviour?
As we know,
ip_conntrackhas ahash_sizeto control theip_conntrackrecord size. and if tcp in ESTABLISH, andip_conntrackwill keep it for 5 DAYs.
Quoted 7 lines
Quoted 5 lines
Quoted 4 lines
Quoted 1 line
For exsample, a NAT server can handle 8000 connections, and if sometime, NAT server need reboot(6000 conntrack in ESTBLISHED state now). Also we set
ip_conntrackallowing pickup ESTABLISHED tcp connection, when NAT server available again,ip_conntrackwill take 6000 conntracks for the original connections. but actully these connections are INVALID for the web server, because the source ip is the private IPs,such as 192.168.0.1. and web server will not answer the client's request. But still the NAT server will keep the 6000 conntrack for 5 DAYs. And just 2000 conntracks can be used for the clients. If more than 2000 client want connect to some websites, someip_conntrackwill be droped.You can drop ACK packets in state NEW to avoid connection pickup.
That's a good idea, I will make a patch for my own 2.4 Linux NAT server, thanks a lot :-)
No need to, as all you should do is a proper iptables rule.
what kind of rules should I take? It's seemed that there is no rule to deal with this special case on 2.4 :(
Quoted 3 lines
Best regards,
Krzysztof Olędzki
Quoted 2 lines · Dong_Wei
what kind of rules should I take? It's seemed that there is no rule to deal with this special case on 2.4 :(
$IPTABLES -A INPUT -p tcp ! --syn -m state --state NEW -j DROP
(From http://iptables-tutorial.frozentux.net/iptables-tutorial.html#NEWNOTSYN)
Quoted 5 lines
Quoted 1 line · Dong_Wei
what kind of rules should I take? It's seemed that there is no rule to deal with this special case on 2.4 :(
$IPTABLES -A INPUT -p tcp ! --syn -m state --state NEW -j DROP
Thanks a lot Philip :)