| 1 |
.TH XTABLES\-MONITOR 8 "" "iptables 1.8.13" "iptables 1.8.13" |
| 2 |
.SH NAME |
| 3 |
xtables-monitor \(em show changes to rule set and trace-events |
| 4 |
.SH SYNOPSIS |
| 5 |
\fBxtables\-monitor\fP [\fB\-t\fP] [\fB\-e\fP] [\fB\-4\fP|\fB|\-6\fB] |
| 6 |
.PP |
| 7 |
\ |
| 8 |
.SH DESCRIPTION |
| 9 |
.PP |
| 10 |
.B xtables-monitor |
| 11 |
is used to monitor changes to the ruleset or to show rule evaluation events |
| 12 |
for packets tagged using the TRACE target. |
| 13 |
.B xtables-monitor |
| 14 |
will run until the user aborts execution, typically by using CTRL-C. |
| 15 |
.RE |
| 16 |
.SH OPTIONS |
| 17 |
\fB\-e\fP, \fB\-\-event\fP |
| 18 |
.TP |
| 19 |
Watch for updates to the rule set. |
| 20 |
Updates include creation of new tables, chains and rules and |
| 21 |
the name of the program that caused the rule update. |
| 22 |
.TP |
| 23 |
\fB\-t\fP, \fB\-\-trace\fP |
| 24 |
Watch for trace events generated by packets that have been tagged |
| 25 |
using the TRACE target. |
| 26 |
.TP |
| 27 |
\fB\-4\fP |
| 28 |
Restrict output to IPv4. |
| 29 |
.TP |
| 30 |
\fB\-6\fP |
| 31 |
Restrict output to IPv6. |
| 32 |
.SH EXAMPLE OUTPUT |
| 33 |
.TP |
| 34 |
.B xtables-monitor \-\-trace |
| 35 |
|
| 36 |
1 TRACE: 2 fc475095 raw:PREROUTING:rule:0x3:CONTINUE \-4 \-t raw \-A PREROUTING \-p icmp \-j TRACE |
| 37 |
2 PACKET: 0 fc475095 IN=lo LL=0x304 0000000000000000000000000800 SRC=127.0.0.1 DST=127.0.0.1 LEN=84 TOS=0x0 TTL=64 ID=38349DF |
| 38 |
3 TRACE: 2 fc475095 raw:PREROUTING:return: |
| 39 |
4 TRACE: 2 fc475095 raw:PREROUTING:policy:ACCEPT |
| 40 |
5 TRACE: 2 fc475095 filter:INPUT:return: |
| 41 |
6 TRACE: 2 fc475095 filter:INPUT:policy:DROP |
| 42 |
7 TRACE: 2 0df9d3d8 raw:PREROUTING:rule:0x3:CONTINUE \-4 \-t raw \-A PREROUTING \-p icmp \-j TRACE |
| 43 |
.PP |
| 44 |
The first line shows a packet entering rule set evaluation. |
| 45 |
The protocol number is shown (AF_INET in this case), then a packet |
| 46 |
identifier number that allows one to correlate messages coming from rule set evaluation of |
| 47 |
this packet. After this, the rule that was matched by the packet is shown. |
| 48 |
This is the TRACE rule that turns on tracing events for this packet. |
| 49 |
|
| 50 |
The second line dumps information about the packet. Incoming interface |
| 51 |
and packet headers such as source and destination addresses are shown. |
| 52 |
|
| 53 |
The third line shows that the packet completed traversal of the raw table |
| 54 |
PREROUTING chain, and is returning, followed by use of the chain policy to make accept/drop |
| 55 |
decision (the example shows accept being applied). |
| 56 |
The fifth line shows that the packet leaves the filter INPUT chain, i.e., no rules in the filter table's |
| 57 |
INPUT chain matched the packet. |
| 58 |
It then got DROPPED by the policy of the INPUT table, as shown by line six. |
| 59 |
The last line shows another packet arriving \-\- the packet id is different. |
| 60 |
|
| 61 |
When using the TRACE target, it is usually a good idea to only select packets |
| 62 |
that are relevant, for example via |
| 63 |
.nf |
| 64 |
iptables \-t raw \-A PREROUTING \-p tcp \-\-dport 80 \-\-syn \-m limit \-\-limit 1/s \-j TRACE |
| 65 |
.fi |
| 66 |
.TP |
| 67 |
.B xtables-monitor \-\-event |
| 68 |
1 EVENT: nft: NEW table: table filter ip flags 0 use 4 handle 444 |
| 69 |
2 EVENT: # nft: ip filter INPUT use 2 type filter hook input prio 0 policy drop packets 0 bytes 0 |
| 70 |
3 EVENT: # nft: ip filter FORWARD use 0 type filter hook forward prio 0 policy accept packets 0 bytes 0 |
| 71 |
4 EVENT: # nft: ip filter OUTPUT use 0 type filter hook output prio 0 policy accept packets 0 bytes 0 |
| 72 |
5 EVENT: \-4 \-t filter \-N TCP |
| 73 |
6 EVENT: \-4 \-t filter \-A TCP \-s 192.168.0.0/16 \-p tcp \-m tcp \-\-dport 22 \-j ACCEPT |
| 74 |
7 EVENT: \-4 \-t filter \-A TCP \-p tcp \-m multiport \-\-dports 80,443 \-j ACCEPT |
| 75 |
8 EVENT: \-4 \-t filter \-A INPUT \-p tcp \-j TCP |
| 76 |
9 EVENT: \-4 \-t filter \-A INPUT \-m conntrack \-\-ctstate RELATED,ESTABLISHED \-j ACCEPT |
| 77 |
10 NEWGEN: GENID=13904 PID=25167 NAME=iptables-nftables-restore |
| 78 |
.PP |
| 79 |
This example shows event monitoring. Line one shows creation of a table (filter in this case), followed |
| 80 |
by three base hooks INPUT, FORWARD and OUTPUT. The iptables-nftables tools all create tables and base |
| 81 |
chains automatically when needed, so this is expected when a table was not yet initialized or when it is |
| 82 |
re-created from scratch by iptables-nftables-restore. Line five shows a new user-defined chain (TCP) |
| 83 |
being added, followed by addition a few rules. the last line shows that a new ruleset generation has |
| 84 |
become active, i.e., the rule set changes are now active. This also lists the process id and the program name. |
| 85 |
.SH LIMITATIONS |
| 86 |
.B xtables-monitor |
| 87 |
only works with rules added using iptables-nftables, rules added using |
| 88 |
iptables-legacy cannot be monitored. |
| 89 |
.SH BUGS |
| 90 |
Should be reported or by sending email to [email protected] or |
| 91 |
by filing a report on https://bugzilla.netfilter.org/. |
| 92 |
.SH SEE ALSO |
| 93 |
\fBiptables\fP(8), \fBxtables\fP(8), \fBnft\fP(8) |