You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: desktop/l2/firewall.md
+47-10Lines changed: 47 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@
4
4
5
5
This document outlines the design and principles of the `nftables` firewall configuration for the L2 WiFi access point. The primary goals are to provide robust security for the router and its clients, ensure correct network functionality, and maintain a clear, auditable ruleset with maximum performance.
6
6
7
-
The firewall leverages `nftables` for its modern syntax, performance, and ability to handle both IPv4 and IPv6 within a unified `inet` table family where possible. The configuration is optimized for performance through extensive use of nftables sets and strategic rule ordering.
7
+
The firewall leverages `nftables` for its modern syntax, performance, and ability to handle both IPv4 and IPv6 within a unified `inet` table family where possible. The configuration is optimized for performance through extensive use of nftables sets and strategic rule ordering, including early processing of trusted traffic like loopback communication.
8
8
9
9
### 1.1. Configuration Variables
10
10
@@ -49,6 +49,9 @@ The firewall extensively uses nftables sets for optimal performance and maintain
49
49
***`special_purpose_ipv6`**: Contains all RFC 6890 special-purpose IPv6 ranges
***Allows** fragment reassembly for outgoing packets
128
+
***Loopback Protection** (Early):
116
129
***Drops** any packet with loopback addresses on physical interfaces using set-based filtering
130
+
***Performance**: Early placement ensures loopback spoofing is detected before expensive rule evaluation
131
+
***TCP Flag Validation**:
132
+
***Drops** packets with invalid TCP flag combinations
117
133
***Global Egress Filtering**:
118
134
***Drops** any packet destined for special-purpose ranges using set-based filtering
119
135
***Interface-Specific Egress Filtering**:
@@ -139,6 +155,8 @@ The firewall employs several advanced optimization techniques:
139
155
140
156
#### 3.6.2. Rule Ordering Optimization
141
157
***Early Drops**: Invalid packets and spoofed traffic are dropped as early as possible
158
+
***Fragment Reassembly**: Fragments are accepted for reassembly before applying security rules
159
+
***Loopback Fast Path**: Loopback traffic is accepted immediately as it's inherently trusted, bypassing expensive rule evaluation and providing maximum performance for localhost communication
142
160
***Fast Path**: Established connections are accepted early to avoid expensive rule evaluation
143
161
***Global Filters**: Non-interface-specific drops (like special-purpose IP blocking) are applied before interface-specific rules
144
162
***Most Common Traffic First**: Return traffic and established connections are prioritized
@@ -253,17 +271,32 @@ The CrowdSec integration makes several deliberate architectural choices:
253
271
- Internal clients cannot spoof upstream LAN addresses
254
272
- Fragment and TCP flag filtering prevents evasion techniques
255
273
256
-
### 4.3. Network Segmentation
274
+
### 4.3. Fragment Handling Strategy
275
+
-**Fragment Reassembly**: Instead of dropping fragments, the router reassembles them and applies security rules to the complete packets
276
+
-**Security Benefits**: Prevents fragment-based attacks while maintaining compatibility with legitimate applications
277
+
-**Compatibility**: Supports applications that rely on fragmentation (VPNs, streaming, large packet transfers)
278
+
-**Performance**: Reassembly happens at the kernel level with minimal overhead
279
+
-**Attack Prevention**: Fragment-based evasion techniques are neutralized since security rules are applied to reassembled packets
280
+
281
+
### 4.4. Network Segmentation
257
282
- Clear separation between internal (br0) and external (enp1s0) interfaces
258
283
- Service access is restricted to internal interfaces only
0 commit comments