← Documents Documentation/networking/nf_conntrack-sysctl.rst GitHub 원문 ↗

Linux 6.18.37 · Networking

Netfilter Conntrack Sysfs variables

Conntrack table 용량, event, 검증과 protocol별 timeout sysctl입니다.

Source pathDocumentation/networking/nf_conntrack-sysctl.rst
Source versionLinux v6.18.37
TranslationDUJINLABS 전문 번역 + 해설

요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.

1. 요약·해설

원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.

요약·해설

nf_conntrack-sysctl.rst:1-231

Flow accounting과 hash table, invalid 판정, TCP·SCTP·UDP·GRE 상태별 aging 값을 운영 환경에 맞게 조정합니다.

2. 영어 원문 전체

번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.

원문 전체 펼치기
1 .. SPDX-License-Identifier: GPL-2.0
2
3 ===================================
4 Netfilter Conntrack Sysfs variables
5 ===================================
6
7 /proc/sys/net/netfilter/nf_conntrack_* Variables:
8 =================================================
9
10 nf_conntrack_acct - BOOLEAN
11 - 0 - disabled (default)
12 - not 0 - enabled
13
14 Enable connection tracking flow accounting. 64-bit byte and packet
15 counters per flow are added.
16
17 nf_conntrack_buckets - INTEGER
18 Size of hash table. If not specified as parameter during module
19 loading, the default size is calculated by dividing total memory
20 by 16384 to determine the number of buckets. The hash table will
21 never have fewer than 1024 and never more than 262144 buckets.
22 This sysctl is only writeable in the initial net namespace.
23
24 nf_conntrack_checksum - BOOLEAN
25 - 0 - disabled
26 - not 0 - enabled (default)
27
28 Verify checksum of incoming packets. Packets with bad checksums are
29 in INVALID state. If this is enabled, such packets will not be
30 considered for connection tracking.
31
32 nf_conntrack_count - INTEGER (read-only)
33 Number of currently allocated flow entries.
34
35 nf_conntrack_events - BOOLEAN
36 - 0 - disabled
37 - 1 - enabled
38 - 2 - auto (default)
39
40 If this option is enabled, the connection tracking code will
41 provide userspace with connection tracking events via ctnetlink.
42 The default allocates the extension if a userspace program is
43 listening to ctnetlink events.
44
45 nf_conntrack_expect_max - INTEGER
46 Maximum size of expectation table. Default value is
47 nf_conntrack_buckets / 256. Minimum is 1.
48
49 nf_conntrack_frag6_high_thresh - INTEGER
50 default 262144
51
52 Maximum memory used to reassemble IPv6 fragments. When
53 nf_conntrack_frag6_high_thresh bytes of memory is allocated for this
54 purpose, the fragment handler will toss packets until
55 nf_conntrack_frag6_low_thresh is reached.
56
57 nf_conntrack_frag6_low_thresh - INTEGER
58 default 196608
59
60 See nf_conntrack_frag6_low_thresh
61
62 nf_conntrack_frag6_timeout - INTEGER (seconds)
63 default 60
64
65 Time to keep an IPv6 fragment in memory.
66
67 nf_conntrack_generic_timeout - INTEGER (seconds)
68 default 600
69
70 Default for generic timeout. This refers to layer 4 unknown/unsupported
71 protocols.
72
73 nf_conntrack_icmp_timeout - INTEGER (seconds)
74 default 30
75
76 Default for ICMP timeout.
77
78 nf_conntrack_icmpv6_timeout - INTEGER (seconds)
79 default 30
80
81 Default for ICMP6 timeout.
82
83 nf_conntrack_log_invalid - INTEGER
84 - 0 - disable (default)
85 - 1 - log ICMP packets
86 - 6 - log TCP packets
87 - 17 - log UDP packets
88 - 41 - log ICMPv6 packets
89 - 136 - log UDPLITE packets
90 - 255 - log packets of any protocol
91
92 Log invalid packets of a type specified by value.
93
94 nf_conntrack_max - INTEGER
95 Maximum number of allowed connection tracking entries. This value is set
96 to nf_conntrack_buckets by default.
97 Note that connection tracking entries are added to the table twice -- once
98 for the original direction and once for the reply direction (i.e., with
99 the reversed address). This means that with default settings a maxed-out
100 table will have a average hash chain length of 2, not 1.
101
102 nf_conntrack_tcp_be_liberal - BOOLEAN
103 - 0 - disabled (default)
104 - not 0 - enabled
105
106 Be conservative in what you do, be liberal in what you accept from others.
107 If it's non-zero, we mark only out of window RST segments as INVALID.
108
109 nf_conntrack_tcp_ignore_invalid_rst - BOOLEAN
110 - 0 - disabled (default)
111 - 1 - enabled
112
113 If it's 1, we don't mark out of window RST segments as INVALID.
114
115 nf_conntrack_tcp_loose - BOOLEAN
116 - 0 - disabled
117 - not 0 - enabled (default)
118
119 If it is set to zero, we disable picking up already established
120 connections.
121
122 nf_conntrack_tcp_max_retrans - INTEGER
123 default 3
124
125 Maximum number of packets that can be retransmitted without
126 received an (acceptable) ACK from the destination. If this number
127 is reached, a shorter timer will be started.
128
129 nf_conntrack_tcp_timeout_close - INTEGER (seconds)
130 default 10
131
132 nf_conntrack_tcp_timeout_close_wait - INTEGER (seconds)
133 default 60
134
135 nf_conntrack_tcp_timeout_established - INTEGER (seconds)
136 default 432000 (5 days)
137
138 nf_conntrack_tcp_timeout_fin_wait - INTEGER (seconds)
139 default 120
140
141 nf_conntrack_tcp_timeout_last_ack - INTEGER (seconds)
142 default 30
143
144 nf_conntrack_tcp_timeout_max_retrans - INTEGER (seconds)
145 default 300
146
147 nf_conntrack_tcp_timeout_syn_recv - INTEGER (seconds)
148 default 60
149
150 nf_conntrack_tcp_timeout_syn_sent - INTEGER (seconds)
151 default 120
152
153 nf_conntrack_tcp_timeout_time_wait - INTEGER (seconds)
154 default 120
155
156 nf_conntrack_tcp_timeout_unacknowledged - INTEGER (seconds)
157 default 300
158
159 nf_conntrack_timestamp - BOOLEAN
160 - 0 - disabled (default)
161 - not 0 - enabled
162
163 Enable connection tracking flow timestamping.
164
165 nf_conntrack_sctp_timeout_closed - INTEGER (seconds)
166 default 10
167
168 nf_conntrack_sctp_timeout_cookie_wait - INTEGER (seconds)
169 default 3
170
171 nf_conntrack_sctp_timeout_cookie_echoed - INTEGER (seconds)
172 default 3
173
174 nf_conntrack_sctp_timeout_established - INTEGER (seconds)
175 default 210
176
177 Default is set to (hb_interval * path_max_retrans + rto_max)
178
179 nf_conntrack_sctp_timeout_shutdown_sent - INTEGER (seconds)
180 default 3
181
182 nf_conntrack_sctp_timeout_shutdown_recd - INTEGER (seconds)
183 default 3
184
185 nf_conntrack_sctp_timeout_shutdown_ack_sent - INTEGER (seconds)
186 default 3
187
188 nf_conntrack_sctp_timeout_heartbeat_sent - INTEGER (seconds)
189 default 30
190
191 This timeout is used to setup conntrack entry on secondary paths.
192 Default is set to hb_interval.
193
194 nf_conntrack_udp_timeout - INTEGER (seconds)
195 default 30
196
197 nf_conntrack_udp_timeout_stream - INTEGER (seconds)
198 default 120
199
200 This extended timeout will be used in case there is an UDP stream
201 detected.
202
203 nf_conntrack_gre_timeout - INTEGER (seconds)
204 default 30
205
206 nf_conntrack_gre_timeout_stream - INTEGER (seconds)
207 default 180
208
209 This extended timeout will be used in case there is an GRE stream
210 detected.
211
212 nf_hooks_lwtunnel - BOOLEAN
213 - 0 - disabled (default)
214 - not 0 - enabled
215
216 If this option is enabled, the lightweight tunnel netfilter hooks are
217 enabled. This option cannot be disabled once it is enabled.
218
219 nf_flowtable_tcp_timeout - INTEGER (seconds)
220 default 30
221
222 Control offload timeout for tcp connections.
223 TCP connections may be offloaded from nf conntrack to nf flow table.
224 Once aged, the connection is returned to nf conntrack.
225
226 nf_flowtable_udp_timeout - INTEGER (seconds)
227 default 30
228
229 Control offload timeout for udp connections.
230 UDP connections may be offloaded from nf conntrack to nf flow table.
231 Once aged, the connection is returned to nf conntrack.
232

3. 한국어 전문 번역

영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.

Accounting, hash table과 event

1-48

`/proc/sys/net/netfilter/nf_conntrack_*` 아래의 변수는 connection tracking의 용량, 검증, event와 protocol별 timeout을 제어합니다. `nf_conntrack_acct`를 0이 아닌 값으로 켜면 flow마다 64비트 byte·packet counter를 추가합니다. 기본값은 0입니다.

`nf_conntrack_buckets`는 hash table 크기입니다. module load parameter로 지정하지 않으면 전체 메모리를 16384로 나눈 값으로 계산하되 최소 1024, 최대 262144 bucket으로 제한합니다. 이 sysctl은 초기 network namespace에서만 쓸 수 있습니다.

`nf_conntrack_checksum`은 기본 활성화되어 수신 패킷의 checksum을 검증합니다. 잘못된 checksum은 `INVALID` 상태이며 활성 상태에서는 connection tracking 대상으로 삼지 않습니다. 읽기 전용 `nf_conntrack_count`는 현재 할당된 flow entry 수입니다.

`nf_conntrack_events`는 0 비활성, 1 활성, 2 자동이며 기본값은 자동입니다. 활성화하면 ctnetlink로 userspace에 conntrack event를 제공합니다. 자동 모드는 userspace program이 ctnetlink event를 듣고 있을 때만 extension을 할당합니다. `nf_conntrack_expect_max`는 expectation table 최대 크기로 기본 `nf_conntrack_buckets / 256`, 최솟값은 1입니다.

Conntrack 핵심 용량·event
변수기본값의미
nf_conntrack_acct0flow별 64비트 byte·packet accounting
nf_conntrack_bucketsRAM/163841024~262144 hash buckets
nf_conntrack_checksum활성수신 checksum 검증
nf_conntrack_count읽기 전용현재 flow entry 수
nf_conntrack_events2 (auto)ctnetlink listener가 있을 때 event extension
nf_conntrack_expect_maxbuckets/256expectation table 한도

기본값과 접근 특성을 정리했습니다.

.. SPDX-License-Identifier: GPL-2.0

===================================
Netfilter Conntrack Sysfs variables
===================================

/proc/sys/net/netfilter/nf_conntrack_* Variables:
=================================================

nf_conntrack_acct - BOOLEAN
        - 0 - disabled (default)
        - not 0 - enabled

        Enable connection tracking flow accounting. 64-bit byte and packet
        counters per flow are added.

nf_conntrack_buckets - INTEGER
        Size of hash table. If not specified as parameter during module
        loading, the default size is calculated by dividing total memory
        by 16384 to determine the number of buckets. The hash table will
        never have fewer than 1024 and never more than 262144 buckets.
        This sysctl is only writeable in the initial net namespace.

nf_conntrack_checksum - BOOLEAN
        - 0 - disabled
        - not 0 - enabled (default)

        Verify checksum of incoming packets. Packets with bad checksums are
        in INVALID state. If this is enabled, such packets will not be
        considered for connection tracking.

nf_conntrack_count - INTEGER (read-only)
        Number of currently allocated flow entries.

nf_conntrack_events - BOOLEAN
        - 0 - disabled
        - 1 - enabled
        - 2 - auto (default)

        If this option is enabled, the connection tracking code will
        provide userspace with connection tracking events via ctnetlink.
        The default allocates the extension if a userspace program is
        listening to ctnetlink events.

nf_conntrack_expect_max - INTEGER
        Maximum size of expectation table.  Default value is
        nf_conntrack_buckets / 256. Minimum is 1.

IPv6 fragment와 일반 protocol timeout

49-82

`nf_conntrack_frag6_high_thresh` 기본값은 262144바이트입니다. IPv6 fragment 재조립 메모리가 이 값에 이르면 handler가 packet을 버리기 시작하며 사용량이 low threshold로 내려갈 때까지 계속합니다. `nf_conntrack_frag6_low_thresh` 기본값은 196608바이트입니다. 원문은 이 항목에서 같은 변수 설명을 참조하도록 표기합니다.

`nf_conntrack_frag6_timeout`은 IPv6 fragment를 메모리에 유지하는 시간이며 기본 60초입니다. 알 수 없거나 지원하지 않는 layer 4 protocol의 `nf_conntrack_generic_timeout`은 600초, ICMP와 ICMPv6 timeout은 각각 30초입니다.

Fragment와 일반 timeout
변수기본값
frag6_high_thresh262144 bytes
frag6_low_thresh196608 bytes
frag6_timeout60 s
generic_timeout600 s
icmp_timeout30 s
icmpv6_timeout30 s

단위가 명시된 기본값입니다.

nf_conntrack_frag6_high_thresh - INTEGER
        default 262144

        Maximum memory used to reassemble IPv6 fragments.  When
        nf_conntrack_frag6_high_thresh bytes of memory is allocated for this
        purpose, the fragment handler will toss packets until
        nf_conntrack_frag6_low_thresh is reached.

nf_conntrack_frag6_low_thresh - INTEGER
        default 196608

        See nf_conntrack_frag6_low_thresh

nf_conntrack_frag6_timeout - INTEGER (seconds)
        default 60

        Time to keep an IPv6 fragment in memory.

nf_conntrack_generic_timeout - INTEGER (seconds)
        default 600

        Default for generic timeout.  This refers to layer 4 unknown/unsupported
        protocols.

nf_conntrack_icmp_timeout - INTEGER (seconds)
        default 30

        Default for ICMP timeout.

nf_conntrack_icmpv6_timeout - INTEGER (seconds)
        default 30

        Default for ICMP6 timeout.

Invalid logging, table 한도와 TCP 판정

83-128

`nf_conntrack_log_invalid`는 값에 해당하는 invalid packet을 기록합니다. 0은 비활성, 1은 ICMP, 6은 TCP, 17은 UDP, 41은 ICMPv6, 136은 UDPLITE, 255는 모든 protocol입니다.

`nf_conntrack_max`는 허용하는 conntrack entry 최대 수이며 기본값은 bucket 수와 같습니다. 각 connection은 원래 방향과 주소를 뒤집은 reply 방향으로 table에 두 번 들어가므로 기본 설정에서 table이 가득 차면 평균 hash chain 길이는 1이 아니라 2입니다.

`nf_conntrack_tcp_be_liberal`은 기본 0입니다. 0이 아니면 window 밖 RST만 `INVALID`로 표시하여 수신 판단을 느슨하게 합니다. `nf_conntrack_tcp_ignore_invalid_rst=1`은 window 밖 RST도 `INVALID`로 표시하지 않습니다. `nf_conntrack_tcp_loose`는 기본 활성 상태로 이미 성립한 connection을 중간에서 추적할 수 있으며 0이면 이를 막습니다.

`nf_conntrack_tcp_max_retrans` 기본값은 3입니다. 상대에게 허용 가능한 ACK를 받지 못한 채 재전송할 수 있는 최대 packet 수이며, 한도에 이르면 더 짧은 timer를 시작합니다.

invalid protocol logging 값
대상
0비활성
1ICMP
6TCP
17UDP
41ICMPv6
136UDPLITE
255모든 protocol

nf_conntrack_log_invalid의 protocol 번호입니다.

nf_conntrack_log_invalid - INTEGER
        - 0   - disable (default)
        - 1   - log ICMP packets
        - 6   - log TCP packets
        - 17  - log UDP packets
        - 41  - log ICMPv6 packets
        - 136 - log UDPLITE packets
        - 255 - log packets of any protocol

        Log invalid packets of a type specified by value.

nf_conntrack_max - INTEGER
        Maximum number of allowed connection tracking entries. This value is set
        to nf_conntrack_buckets by default.
        Note that connection tracking entries are added to the table twice -- once
        for the original direction and once for the reply direction (i.e., with
        the reversed address). This means that with default settings a maxed-out
        table will have a average hash chain length of 2, not 1.

nf_conntrack_tcp_be_liberal - BOOLEAN
        - 0 - disabled (default)
        - not 0 - enabled

        Be conservative in what you do, be liberal in what you accept from others.
        If it's non-zero, we mark only out of window RST segments as INVALID.

nf_conntrack_tcp_ignore_invalid_rst - BOOLEAN
        - 0 - disabled (default)
        - 1 - enabled

        If it's 1, we don't mark out of window RST segments as INVALID.

nf_conntrack_tcp_loose - BOOLEAN
        - 0 - disabled
        - not 0 - enabled (default)

        If it is set to zero, we disable picking up already established
        connections.

nf_conntrack_tcp_max_retrans - INTEGER
        default 3

        Maximum number of packets that can be retransmitted without
        received an (acceptable) ACK from the destination. If this number
        is reached, a shorter timer will be started.

TCP 상태별 timeout과 timestamp

129-164

TCP 상태별 기본 timeout은 close 10초, close_wait 60초, established 432000초(5일), fin_wait 120초, last_ack 30초입니다. max_retrans와 unacknowledged는 각각 300초, syn_recv 60초, syn_sent 120초, time_wait 120초입니다.

`nf_conntrack_timestamp`는 기본 0이며 0이 아닌 값으로 켜면 conntrack flow timestamp를 기록합니다.

TCP conntrack timeout
상태
close10
close_wait60
established432000
fin_wait120
last_ack30
max_retrans300
syn_recv60
syn_sent120
time_wait120
unacknowledged300

상태별 기본 초 값을 보존했습니다.

nf_conntrack_tcp_timeout_close - INTEGER (seconds)
        default 10

nf_conntrack_tcp_timeout_close_wait - INTEGER (seconds)
        default 60

nf_conntrack_tcp_timeout_established - INTEGER (seconds)
        default 432000 (5 days)

nf_conntrack_tcp_timeout_fin_wait - INTEGER (seconds)
        default 120

nf_conntrack_tcp_timeout_last_ack - INTEGER (seconds)
        default 30

nf_conntrack_tcp_timeout_max_retrans - INTEGER (seconds)
        default 300

nf_conntrack_tcp_timeout_syn_recv - INTEGER (seconds)
        default 60

nf_conntrack_tcp_timeout_syn_sent - INTEGER (seconds)
        default 120

nf_conntrack_tcp_timeout_time_wait - INTEGER (seconds)
        default 120

nf_conntrack_tcp_timeout_unacknowledged - INTEGER (seconds)
        default 300

nf_conntrack_timestamp - BOOLEAN
        - 0 - disabled (default)
        - not 0 - enabled

        Enable connection tracking flow timestamping.

SCTP, UDP와 GRE timeout

165-211

SCTP 기본 timeout은 closed 10초, cookie_wait 3초, cookie_echoed 3초, established 210초입니다. Established 기본값은 `hb_interval * path_max_retrans + rto_max`로 정합니다. shutdown_sent, shutdown_recd, shutdown_ack_sent는 모두 3초입니다.

`nf_conntrack_sctp_timeout_heartbeat_sent`는 30초이며 secondary path에 conntrack entry를 만들 때 사용합니다. 기본값은 heartbeat interval입니다.

UDP 기본 timeout은 30초이고 stream이 감지되면 `nf_conntrack_udp_timeout_stream` 120초를 사용합니다. GRE도 일반 30초, stream 감지 시 180초의 연장 timeout을 사용합니다.

SCTP·UDP·GRE timeout
Protocol·상태
SCTP closed10
SCTP cookie_wait / cookie_echoed3 / 3
SCTP established210
SCTP shutdown 계열3
SCTP heartbeat_sent30
UDP / UDP stream30 / 120
GRE / GRE stream30 / 180

protocol 상태별 기본값입니다.

nf_conntrack_sctp_timeout_closed - INTEGER (seconds)
        default 10

nf_conntrack_sctp_timeout_cookie_wait - INTEGER (seconds)
        default 3

nf_conntrack_sctp_timeout_cookie_echoed - INTEGER (seconds)
        default 3

nf_conntrack_sctp_timeout_established - INTEGER (seconds)
        default 210

        Default is set to (hb_interval * path_max_retrans + rto_max)

nf_conntrack_sctp_timeout_shutdown_sent - INTEGER (seconds)
        default 3

nf_conntrack_sctp_timeout_shutdown_recd - INTEGER (seconds)
        default 3

nf_conntrack_sctp_timeout_shutdown_ack_sent - INTEGER (seconds)
        default 3

nf_conntrack_sctp_timeout_heartbeat_sent - INTEGER (seconds)
        default 30

        This timeout is used to setup conntrack entry on secondary paths.
        Default is set to hb_interval.

nf_conntrack_udp_timeout - INTEGER (seconds)
        default 30

nf_conntrack_udp_timeout_stream - INTEGER (seconds)
        default 120

        This extended timeout will be used in case there is an UDP stream
        detected.

nf_conntrack_gre_timeout - INTEGER (seconds)
        default 30

nf_conntrack_gre_timeout_stream - INTEGER (seconds)
        default 180

        This extended timeout will be used in case there is an GRE stream
        detected.

Lightweight tunnel hook과 flowtable aging

212-231

`nf_hooks_lwtunnel`은 기본 0입니다. 0이 아닌 값으로 켜면 lightweight tunnel Netfilter hook을 활성화하며, 한 번 활성화한 뒤에는 다시 끌 수 없습니다.

`nf_flowtable_tcp_timeout`과 `nf_flowtable_udp_timeout`은 모두 기본 30초로, conntrack에서 Netfilter flow table로 offload한 TCP·UDP connection의 aging 시간을 제어합니다. 시간이 지나면 connection은 flow table에서 conntrack으로 돌아옵니다.

nf_hooks_lwtunnel - BOOLEAN
        - 0 - disabled (default)
        - not 0 - enabled

        If this option is enabled, the lightweight tunnel netfilter hooks are
        enabled. This option cannot be disabled once it is enabled.

nf_flowtable_tcp_timeout - INTEGER (seconds)
        default 30

        Control offload timeout for tcp connections.
        TCP connections may be offloaded from nf conntrack to nf flow table.
        Once aged, the connection is returned to nf conntrack.

nf_flowtable_udp_timeout - INTEGER (seconds)
        default 30

        Control offload timeout for udp connections.
        UDP connections may be offloaded from nf conntrack to nf flow table.
        Once aged, the connection is returned to nf conntrack.