2011-05-01 12:32:22 +01:00
|
|
|
LIBDIR = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
|
|
|
|
$LOAD_PATH.unshift LIBDIR
|
|
|
|
|
|
|
|
require 'pp'
|
2011-05-06 09:49:47 +01:00
|
|
|
require 'linux/netlink/firewall'
|
2011-05-01 12:32:22 +01:00
|
|
|
|
|
|
|
# Example of using Netlink::Firewall to capture all outbound packets
|
|
|
|
# to TCP port 7551. Use "telnet 127.0.0.1 7551" to test.
|
|
|
|
|
|
|
|
#system("modprobe ip_queue")
|
|
|
|
#system("modprobe iptable_filter")
|
|
|
|
#system("iptables -I OUTPUT -j QUEUE -p tcp --destination-port 7551")
|
2011-05-06 09:49:47 +01:00
|
|
|
nl = Linux::Netlink::Firewall::Socket.new
|
2011-05-01 12:32:22 +01:00
|
|
|
nl.set_mode(Netlink::IPQ_COPY_PACKET, 128)
|
|
|
|
nl.dequeue_packets do |pkt|
|
|
|
|
p pkt
|
2011-05-06 09:49:47 +01:00
|
|
|
Linux::NF_ACCEPT # Linux::NF_DROP
|
2011-05-01 12:32:22 +01:00
|
|
|
end
|