blog:linux:connection_tracking_3_state_and_examples
Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| blog:linux:connection_tracking_3_state_and_examples [2021-08-07] – created Andrej Stender | blog:linux:connection_tracking_3_state_and_examples [2023-09-04] (current) – fix typo "UPD" -> "UDP" Andrej Stender | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | {{tag> | + | {{tag> |
| - | ====== Connection tracking (conntrack) - Part 3: Connection | + | ====== Connection tracking (conntrack) - Part 3: State and Examples ====== |
| ~~META: | ~~META: | ||
| date created = 2021-08-07 | date created = 2021-08-07 | ||
| ~~ | ~~ | ||
| - | |||
| - | ~~NOTOC~~ | ||
| With this article series I like to take a closer look at the connection tracking subsystem of the Linux kernel, which provides the basis for features like stateful packet filtering and NAT. I refer to it as the “ct system” throughout the series. In this third article, I like to take a look at how the system analyzes and tracks the state of a connection and in which way IPtables/ | With this article series I like to take a closer look at the connection tracking subsystem of the Linux kernel, which provides the basis for features like stateful packet filtering and NAT. I refer to it as the “ct system” throughout the series. In this third article, I like to take a look at how the system analyzes and tracks the state of a connection and in which way IPtables/ | ||
| Line 12: | Line 10: | ||
| * [[connection_tracking_1_modules_and_hooks|Connection tracking (conntrack) - Part 1: Modules and Hooks]] | * [[connection_tracking_1_modules_and_hooks|Connection tracking (conntrack) - Part 1: Modules and Hooks]] | ||
| * [[connection_tracking_2_core_implementation|Connection tracking (conntrack) - Part 2: Core Implementation]] | * [[connection_tracking_2_core_implementation|Connection tracking (conntrack) - Part 2: Core Implementation]] | ||
| - | * [[connection_tracking_3_state_and_examples|Connection tracking (conntrack) - Part 3: Connection | + | * [[connection_tracking_3_state_and_examples|Connection tracking (conntrack) - Part 3: State and Examples]] |
| ===== Overview ===== | ===== Overview ===== | ||
| Line 56: | Line 54: | ||
| __Iptables/ | __Iptables/ | ||
| in Iptables/ | in Iptables/ | ||
| - | __Conntrack__: | + | __Conntrack__: |
| <figure nfconnstatus_detail> | <figure nfconnstatus_detail> | ||
| Line 84: | Line 82: | ||
| | Nftables | '' | | Nftables | '' | ||
| | Iptables | '' | | Iptables | '' | ||
| - | ^ bit shown in output of command like this (negated!) ^^ | + | ^ bit shown by conntrack |
| - | | '' | + | | '' |
| </ | </ | ||
| ^ bit 2: '' | ^ bit 2: '' | ||
| Line 94: | Line 92: | ||
| | Nftables | '' | | Nftables | '' | ||
| | Iptables | '' | | Iptables | '' | ||
| - | ^ bit shown in output of command like this ^^ | + | ^ bit shown by conntrack |
| - | | '' | + | | '' |
| </ | </ | ||
| ^ bit 3: '' | ^ bit 3: '' | ||
| Line 144: | Line 142: | ||
| ^ bit 14: '' | ^ bit 14: '' | ||
| | < | | < | ||
| - | This tracked connection has been offloaded to flow table. | + | This tracked connection has been offloaded to a [[flowtables_1_a_netfilter_nftables_fastpath|flowtable]]. |
| - | ^ bit shown in output of command like this ^^ | + | ^ bit shown by conntrack |
| - | | '' | + | | '' |
| </ | </ | ||
| ^ bit 15: '' | ^ bit 15: '' | ||
| | < | | < | ||
| - | This tracked connection has been offloaded to hardware. | + | This tracked connection has been offloaded to hardware |
| - | ^ bit shown in output of command like this ^^ | + | ^ bit shown by conntrack |
| - | | '' | + | | '' |
| </ | </ | ||
| < | < | ||
| Line 337: | Line 335: | ||
| ICMP // | ICMP // | ||
| causing tracked connection to be created and later deleted, | causing tracked connection to be created and later deleted, | ||
| - | showing state and timeout changes as those occur. | + | showing state and timeout changes as those occur (click to enlarge). |
| </ | </ | ||
| </ | </ | ||
| Line 349: | Line 347: | ||
| in its //tuples// to do that; see function '' | in its //tuples// to do that; see function '' | ||
| - | ===== UPD Example ===== | + | ===== UDP Example ===== |
| This example demonstrates state changes of a tracked connection in case of a [[wp> | This example demonstrates state changes of a tracked connection in case of a [[wp> | ||
| {{ref> | {{ref> | ||
| Line 388: | Line 386: | ||
| {{ : | {{ : | ||
| < | < | ||
| - | DNS //query// and // | + | DNS //query// and // |
| </ | </ | ||
| </ | </ | ||
| Line 503: | Line 501: | ||
| {{ : | {{ : | ||
| < | < | ||
| - | TCP 3-way handshake: packets traversing ct hook functions, causing tracked connection to be created, confirmed, established and assured. | + | TCP 3-way handshake: packets traversing ct hook functions, causing tracked connection to be created, confirmed, established and assured |
| </ | </ | ||
| </ | </ | ||
| Line 510: | Line 508: | ||
| {{ : | {{ : | ||
| < | < | ||
| - | TCP payload data transfer: packets traversing ct hook functions, adjusting timeout depending on outstanding TCP ACK from peer. | + | TCP payload data transfer: packets traversing ct hook functions, adjusting timeout depending on outstanding TCP ACK from peer (click to enlarge). |
| </ | </ | ||
| </ | </ | ||
| Line 517: | Line 515: | ||
| {{ : | {{ : | ||
| < | < | ||
| - | TCP connection termination((TCP connection termination consists of two independent 2-way handshakes, which can result in 4 packets being exchanged. However, if both sides like to terminate simultaneously, | + | TCP connection termination((TCP connection termination consists of two independent 2-way handshakes, which can result in 4 packets being exchanged. However, if both sides like to terminate simultaneously, |
| </ | </ | ||
| </ | </ | ||
| Line 539: | Line 537: | ||
| * [[https:// | * [[https:// | ||
| - | //published 2021-08-07//, | + | //published 2021-08-07//, |
blog/linux/connection_tracking_3_state_and_examples.1628365542.txt.gz · Last modified: 2021-08-07 by Andrej Stender
