@@ -10,7 +10,22 @@ Libnetfilter_queue (the netfilter library, not this module) is part of the `Netf
1010Example
1111=======
1212
13- Coming soon...
13+ The following script prints a short description of each packet before accepting it::
14+
15+ from netfilterqueue import NetfilterQueue
16+
17+ class PacketPrinter(NetfilterQueue):
18+ def handle(self, packet):
19+ print packet
20+ packet.accept()
21+
22+ p = PacketPrinter()
23+ p.bind(1)
24+ p.run()
25+
26+ To send packets destined for your LAN to the script, type something like::
27+
28+ iptables -I INPUT -d 192.168.0.0/24 -j NFQUEUE --queue-num 1
1429
1530Installation
1631============
@@ -46,20 +61,53 @@ To install from source::
4661
4762Setup will use Cython if it is installed, regenerating the .c source from the .pyx before compiling the .so.
4863
64+ API
65+ ===
66+
67+ Coming soon...
68+
4969Usage
5070=====
5171
52- Coming soon...
72+ To route packets to the queue::
5373
54- Now route packets to the queue::
74+ iptables -I <table or chain> <match specification> -j NFQUEUE --queue-num <queue number>
75+
76+ For example::
5577
56- # iptables -I INPUT -p tcp --dport 80 -j NFQUEUE --queue-num 1
78+ iptables -I INPUT -d 192.168.0.0/24 -j NFQUEUE --queue-num 1
5779
5880The only special part of the rule is the target. Rules can have any match and
5981can be added to any table or chain.
6082
6183Valid queue numbers are integers from 0 to 65,536 inclusive.
6284
85+ To view libnetfilter_queue stats, refer to /proc/net/netfilter/nfnetlink_queue::
86+
87+ cat /proc/net/netfilter/nfnetlink_queue
88+ 1 31621 0 2 4016 0 0 2 1
89+
90+ The fields are:
91+
92+ 1. Queue ID
93+
94+ 2. Bound process ID
95+
96+ 3. Number of currently queued packets
97+
98+ 4. Copy mode
99+
100+ 5. Copy size
101+
102+ 6. Number of packets dropped due to reaching max queue size
103+
104+ 7. Number of packets dropped due to netlink socket failure
105+
106+ 8. Total number of packets sent to queue
107+
108+ 9. Libnetfilter_queue internal use
109+
110+
63111Limitations
64112===========
65113
0 commit comments