Giter Site home page Giter Site logo

go-nfnetlink's Introduction

go-nfnetlink - A native Go library for interacting with netfilter subsystems

A library for communicating with Linux netfilter subsystems over netlink sockets.

What is 'netfilter netlink'?

Linux/net/netfilter/nfnetlink.c:

Netfilter messages via netlink sockets.  Allows for user space protocol helpers and general
trouble making from userspace.

Netfilter is composed of several subsystems in the Linux kernel, some of which provide access from userland over a netlink socket interface. The protocol API for accessing these subsystems share a common set of protocol conventions called nfnetlink (netfilter netlink).

What is the nfqueue package?

A library for the netfilter queue subsystem built on top of the nfnetlink layer.

Here is a basic example of how to use it:

Set up IPTables

# iptables -A OUTPUT -p icmp -j NFQUEUE --queue-num 1 --queue-bypass

Read ICMP packets from queue number 1

q := nfqueue.NewNFQueue(1)

ps, err := q.Open()
if err != nil {
        fmt.Printf("Error opening NFQueue: %v\n", err)
        os.Exit(1)
}
defer q.Close()

for p := range ps {
        fmt.Printf("Packet: %v\n", p.Packet)
        p.Accept()
}

How can I implement support for other netfilter subsystems?

You'll probably have to read the C library code or the Linux kernel source to learn about the protocol as there is usually no documentation at all. Look at nfqueue for an example of how to implement the protocol using the nfnetlink layer.

We plan to add some basic support for conntrack in the near future. Pull requests welcome for new features and subsystems.

go-nfnetlink's People

Watchers

James Cloos avatar  avatar

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.