Packet Flow Diagram

Started by Monviech (Cedrik), October 07, 2023, 06:57:19 PM

Previous topic - Next topic
October 07, 2023, 06:57:19 PM Last Edit: October 15, 2023, 08:35:44 PM by Monviech
Attention:
This is a community effort. This is not an official packet flow diagram. Please leave a comment if something is wrong.


Quote
Ingress Traffic:
1. Ingress Interface
   |
2. Next Generation Firewall (Ingress)
   |----> 2.1 Suricata (IPS mode) (depends on selected Interfaces)
   |      |----> If Block Rule Matches, Drop Packet
   |      |----> Else, Continue
   |----> 2.2 Zenarmor (depends on selected Interfaces)
   |      |----> If Block Rule Matches, Drop Packet
   |      |----> Else, Continue
   |
3. Scrub (normalize, reassemble fragments, etc.) ~PF~
   |
4. 1:1 NAT (Bi-directional NAT) ~PF~
   |----> 4.1 Match Rules (Static NAT - BINAT - 1:1 NAT)
   |
5. Destination NAT (Port Forward or Redirection) ~PF~
   |----> 5.1 Match Rules (DNAT - Port Forward)
   |
6. Source NAT (Outbound NAT) ~PF~
   |----> 6.1 Match Rules (SNAT - Outbound)
   |
7. Is Packet First in Flow? ~PF~
   |----> Yes:
   |      |----> 7.1 Filter Rules
   |      |       |----> 7.1.1 Block/Pass (Quick) in order of rules until
   |      |                          first match, then terminates further
   |      |                          evaluation
   |      |       |----> 7.1.2 Block/Pass (without Quick) until best
   |      |                          match, if no prior quick rule matched
   |      |----> 7.2 Create State Entry (if rule has state tracking)
   |----> No:
   |      |----> 7.3 Use Existing State Entry
   |
8. Routing Decision (determine egress interface)
   |
9. Traffic Shaping ~IPFW with dummynet~
   |
10. Next Generation Firewall (Egress)
   |----> 10.1 Suricata (IPS mode) (depends on selected Interfaces)
   |      |----> If Block Rule Matches, Drop Packet
   |      |----> Else, Continue
   |----> 10.2 Zenarmor (depends on selected Interfaces)
   |      |----> If Block Rule Matches, Drop Packet
   |      |----> Else, Continue
   |
11. Egress Interface

- Added Block and Pass filter rule differentiation with "Quick" enabled, feeback from @CJ
- Added Suricata and Zenarmor to the right spots with feedback from @mb: https://forum.opnsense.org/index.php?topic=36369.0
Hardware:
DEC740

The only note I have is that it's not Block and then Pass rules.  It's all rules in order until satisfying one that has a Quick tag or reaching the bottom.

Quote from: CJ on October 08, 2023, 03:37:18 PM
The only note I have is that it's not Block and then Pass rules.  It's all rules in order until satisfying one that has a Quick tag or reaching the bottom.

Thank you CJ I adjusted the diagram. Do you know where Zenarmor would match here? Same spot as Suricata?
Hardware:
DEC740

October 08, 2023, 05:19:08 PM #3 Last Edit: October 08, 2023, 05:21:53 PM by lilsense
I would love to see one that looks like the netfilter shown below:


your process does not include the suricata and/or Zenarmor integration packet flows

October 08, 2023, 07:33:19 PM #4 Last Edit: October 08, 2023, 07:34:50 PM by Monviech
@lilsense

I know what you mean. I would like something like the junos packet flow:

But since I'm fishing for feedback, I'm keeping it as a simple ASCII so I can adjust it quickly to new information. Once it's solid, I'm going to do a proper one, I promise :)

Hardware:
DEC740

Quote from: Monviech on October 08, 2023, 04:04:01 PM
Quote from: CJ on October 08, 2023, 03:37:18 PM
The only note I have is that it's not Block and then Pass rules.  It's all rules in order until satisfying one that has a Quick tag or reaching the bottom.

Thank you CJ I adjusted the diagram. Do you know where Zenarmor would match here? Same spot as Suricata?

Unfortunately, I don't.  I haven't really dug into the guts of the packet flow.  I only wanted to point out the bit about the Quick rules because I've seen that trip people up.

October 15, 2023, 08:32:29 PM #6 Last Edit: October 15, 2023, 08:36:46 PM by Monviech
Ive updated the diagram since I found out by reading old forum posts that Opnsense uses PF and IPFW in conjunction. PF is for NAT and Packet Filtering, and IPFW with dummynet is used for traffic shaping and captive portal.

I have also reached out to SunnyValley about Zenarmor and implemented their response into the packet flow, together with Suricata at the right spot.
Hardware:
DEC740

August 30, 2024, 05:00:22 AM #7 Last Edit: August 30, 2024, 05:03:27 AM by krishcomment
Your packet flow diagram is thorough and seems well-structured. It's great that you're inviting feedback from the community to ensure accuracy.

For those working on similar projects, I've found that tools like Creately can be really helpful in visualizing complex flow diagrams like this. It's user-friendly and can make these processes easier to map out.

https://creately.com/diagram-community/popular/t/flowchart- packet flow diagrams and more community flowcharts

Where would be Suricata in IDS mode?
kind regards
chemlud
____
"The price of reliability is the pursuit of the utmost simplicity."
C.A.R. Hoare

felix eichhorns premium katzenfutter mit der extraportion energie

A router is not a switch - A router is not a switch - A router is not a switch - A rou....

Well same, but instead of dropping the packet it will just log.
Hardware:
DEC740

in my head IDS was only after (!) packages were handled already by pf, but maybe I mix things up with Snort and the other sense...
kind regards
chemlud
____
"The price of reliability is the pursuit of the utmost simplicity."
C.A.R. Hoare

felix eichhorns premium katzenfutter mit der extraportion energie

A router is not a switch - A router is not a switch - A router is not a switch - A rou....

Before or after, does not matter. Suricata as IDS does not block anything via pf on OPNsense.

Quote from: doktornotor on August 30, 2024, 07:33:25 PM
Before or after, does not matter. Suricata as IDS does not block anything via pf on OPNsense.
Disagree because if it's after pf, then packets blocked by pf won't be inspected by the IDS.
Deciso DEC750
People who think they know everything are a great annoyance to those of us who do. (Isaac Asimov)

Ok. I don't particularly care about inspecting what's already been inspected and blocked elsewhere.

Packet Flow Diagram -> documentation purposes ;-)
kind regards
chemlud
____
"The price of reliability is the pursuit of the utmost simplicity."
C.A.R. Hoare

felix eichhorns premium katzenfutter mit der extraportion energie

A router is not a switch - A router is not a switch - A router is not a switch - A rou....