Skip to content

Commit 461e2e6

Browse files
GitHub CopilotCopilot
authored andcommitted
docs: fix iptables logging references after simplification
- Correct LOG rule attribution from setup-iptables.sh to src/host-iptables.ts (FW_BLOCKED_UDP, FW_BLOCKED_OTHER are host-level DOCKER-USER chain rules) - Remove FW_DNS_QUERY section from logging quickref (prefix no longer exists) - Remove incorrect docker exec awf-agent dmesg commands (host kernel logs are not visible from inside the container) - Remove incorrect --log-uid reference (flag not used in host-iptables.ts) - Remove stale UID=0 field from iptables log example - Remove stale line number reference (src/squid-config.ts:40) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 5d2ef18 commit 461e2e6

3 files changed

Lines changed: 11 additions & 37 deletions

File tree

AGENTS.md

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -609,12 +609,12 @@ The firewall implements comprehensive logging at two levels:
609609
### Key Files
610610
611611
- `src/squid-config.ts` - Generates Squid config with custom `firewall_detailed` logformat
612-
- `containers/agent/setup-iptables.sh` - Configures iptables LOG rules for rejected traffic
612+
- `src/host-iptables.ts` - Configures host-level iptables LOG rules for rejected traffic
613613
- `src/squid-config.test.ts` - Tests for logging configuration
614614

615615
### Squid Log Format
616616

617-
Custom format defined in `src/squid-config.ts:40`:
617+
Custom format defined in `src/squid-config.ts`:
618618
```
619619
logformat firewall_detailed %ts.%03tu %>a:%>p %{Host}>h %<a:%<p %rv %rm %>Hs %Ss:%Sh %ru "%{User-Agent}>h"
620620
```
@@ -633,12 +633,10 @@ Captures:
633633

634634
### iptables Logging
635635

636-
Two LOG rules in `setup-iptables.sh`:
636+
Two LOG rules in `src/host-iptables.ts` (applied on the host via the DOCKER-USER chain):
637637

638-
1. **Line 80** - `[FW_BLOCKED_UDP]` prefix for blocked UDP traffic
639-
2. **Line 95** - `[FW_BLOCKED_OTHER]` prefix for other blocked traffic
640-
641-
Both use `--log-uid` flag to capture process UID.
638+
1. `[FW_BLOCKED_UDP]` prefix for blocked UDP traffic
639+
2. `[FW_BLOCKED_OTHER]` prefix for other blocked traffic
642640

643641
### Testing Logging
644642

@@ -661,5 +659,4 @@ docker exec awf-squid cat /var/log/squid/access.log
661659
- Squid logs use Unix timestamps (convert with `date -d @TIMESTAMP`)
662660
- Decision codes: `TCP_DENIED:HIER_NONE` = blocked, `TCP_TUNNEL:HIER_DIRECT` = allowed
663661
- SNI is captured via CONNECT method for HTTPS (no SSL inspection)
664-
- iptables logs go to kernel buffer (view with `dmesg`)
665-
- PID not directly available (UID can be used for correlation)
662+
- iptables logs go to kernel buffer on the **host** (view with `sudo dmesg | grep FW_BLOCKED`)

docs/logging_quickref.md

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -98,37 +98,17 @@ docker exec awf-squid grep "TCP_TUNNEL\|TCP_MISS" /var/log/squid/access.log
9898
```
9999

100100
### Non-HTTP Traffic (iptables)
101+
102+
These logs are generated by host-level iptables rules in the DOCKER-USER chain and appear in the **host** kernel log, not inside the container:
103+
101104
```bash
102105
# From host (requires sudo)
103106
sudo dmesg | grep FW_BLOCKED
104107

105-
# From agent container
106-
docker exec awf-agent dmesg | grep FW_BLOCKED
107-
108108
# Using journalctl (systemd)
109109
sudo journalctl -k | grep FW_BLOCKED
110110
```
111111

112-
### DNS Query Logging (Audit Trail)
113-
```bash
114-
# View all DNS queries made by containers
115-
sudo dmesg | grep FW_DNS_QUERY
116-
117-
# Using journalctl (systemd)
118-
sudo journalctl -k | grep FW_DNS_QUERY
119-
120-
# Real-time DNS query monitoring
121-
sudo dmesg -w | grep FW_DNS_QUERY
122-
123-
# Count DNS queries by destination
124-
sudo dmesg | grep FW_DNS_QUERY | grep -oP 'DST=\K[^ ]+' | sort | uniq -c | sort -rn
125-
126-
# Show DNS queries to specific resolver (e.g., 8.8.8.8)
127-
sudo dmesg | grep FW_DNS_QUERY | grep 'DST=8.8.8.8'
128-
```
129-
130-
**Note:** DNS queries are logged for audit trail purposes. This helps detect potential DNS tunneling attempts or unusual DNS activity. The log prefix `[FW_DNS_QUERY]` is used to identify DNS traffic.
131-
132112
## Log Format
133113

134114
### Squid Log Entry
@@ -153,7 +133,7 @@ timestamp client_ip:port domain dest_ip:port proto method status decision url us
153133

154134
**Example (blocked UDP):**
155135
```
156-
[1234567.890] [FW_BLOCKED_UDP] IN= OUT=eth0 SRC=172.20.98.20 DST=1.1.1.1 PROTO=UDP SPT=12345 DPT=443 UID=0
136+
[1234567.890] [FW_BLOCKED_UDP] IN= OUT=eth0 SRC=172.20.98.20 DST=1.1.1.1 PROTO=UDP SPT=12345 DPT=443
157137
```
158138

159139
## Common Queries

docs/troubleshooting.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -234,14 +234,11 @@ sudo cat /tmp/squid-logs-<timestamp>/access.log
234234

235235
### Checking iptables Logs
236236

237-
Blocked UDP and non-standard protocols are logged to kernel logs:
237+
Blocked UDP and non-standard protocols are logged to the **host** kernel log via the DOCKER-USER chain:
238238

239239
```bash
240240
# From host (requires sudo)
241241
sudo dmesg | grep FW_BLOCKED
242-
243-
# From within container
244-
docker exec awf-agent dmesg | grep FW_BLOCKED
245242
```
246243

247244
## Network Issues

0 commit comments

Comments
 (0)