요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.
1. 요약·해설
원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.
2. 영어 원문 전체
번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.
원문 전체 펼치기
.. 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.
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.
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.
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.
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.
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.
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입니다.
기본값과 접근 특성을 정리했습니다.
.. 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초입니다.
단위가 명시된 기본값입니다.
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를 시작합니다.
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-164TCP 상태별 기본 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를 기록합니다.
상태별 기본 초 값을 보존했습니다.
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-211SCTP 기본 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을 사용합니다.
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.
요약·해설
nf_conntrack-sysctl.rst:1-231Flow accounting과 hash table, invalid 판정, TCP·SCTP·UDP·GRE 상태별 aging 값을 운영 환경에 맞게 조정합니다.