Files
netlinkrb/examples/nflog.rb

15 lines
454 B
Ruby
Raw Normal View History

2011-05-02 20:27:05 +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/nflog'
2011-05-02 20:27:05 +01:00
2011-05-06 09:49:47 +01:00
# Example of using Linux::Netlink::NFLog to capture all outbound packets
2011-05-02 20:27:05 +01:00
# to TCP port 7551. Use "telnet 127.0.0.1 7551" to test.
#system("iptables -I OUTPUT -j ULOG --ulog-nlgroup 1 -p tcp --destination-port 7551")
2011-05-06 09:49:47 +01:00
nl = Linux::Netlink::NFLog::Socket.new(:group => 1)
2011-05-02 20:27:05 +01:00
nl.dequeue_packets do |pkt|
p pkt
end