Skip to content

Commit a3676c4

Browse files
author
Matt
committed
Add details to README.
1 parent f5e0ad8 commit a3676c4

File tree

4 files changed

+1964
-1145
lines changed

4 files changed

+1964
-1145
lines changed

README.rst

Lines changed: 52 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,22 @@ Libnetfilter_queue (the netfilter library, not this module) is part of the `Netf
1010
Example
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

1530
Installation
1631
============
@@ -46,20 +61,53 @@ To install from source::
4661

4762
Setup 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+
4969
Usage
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
5880
The only special part of the rule is the target. Rules can have any match and
5981
can be added to any table or chain.
6082

6183
Valid 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+
63111
Limitations
64112
===========
65113

0 commit comments

Comments
 (0)