Giter VIP home page Giter VIP logo

gopacket_nfqueue's Introduction

gopacket_nfqueue

Packet inspection with golang, gopacket and nfqueue...

# prerequisites
go get github.com/google/gopacket
apt-get install libpcap-dev
apt-get install libnetfilter-queue-dev

# how to run...
cd /[golang path]/src/github.com/tgogos/gopacket_nfqueue
go install .
sudo $GOPATH/bin/gopacket_nfqueue

Test environment

Virtualbox with three Ubuntu VMs set up like this:

 +-----------+       +-------------------+       +-----------+
 | client VM |-------| pkt inspection VM |-------| server VM |
 +-----------+       +-------------------+       +-----------+
           eth1    eth1                 eth2    eth1

client VM eth1 (host-only): 192.168.4.2
server VM eth1 (host-only): 192.168.5.2

pkt inspection VM eth1 (host-only): 192.168.4.3
pkt inspection VM eth2 (host-only): 192.168.5.3

Client VM configuration:

The client must forward traffic to the pkt inspection VM eth1 so a route must be added:

route add -net 192.168.5.0 netmask 255.255.255.0 gw 192.168.4.3 dev eth1

Server VM configuration:

The server must forward traffic to the pkt inspection VM eth2 so a route must be added:

route add -net 192.168.4.0 netmask 255.255.255.0 gw 192.168.5.3 dev eth1

Packet inspection VM configuration:

The following commands set up the packet forwarding and the routing rules in order to use NFQUEUE:

sysctl -w net.ipv4.ip_forward=1
iptables -t raw -A PREROUTING -i eth1 -j NFQUEUE --queue-num 0
iptables -t raw -A PREROUTING -i eth2 -j NFQUEUE --queue-num 0

To list or flush the above iptables rules:

sudo iptables -t raw -S # list
sudo iptables -t raw -F # flush

gopacket_nfqueue's People

Contributors

tgogos avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

i39

gopacket_nfqueue's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.