libnet - Man Page

A C library for packet creation and injection


#include <libnet.h>


libnet is a packet assembly library that provides a portable interface for packet creation and injection.

It is a high-level API that allows an application programmer to construct and inject network packets. libnet provides a simplified interface for low-level network packet shaping, handling and injection.

libnet hides much of the tedium of packet creation from the application programmer such as multiplexing, buffer management, arcane packet header information, byte-ordering, OS-dependent issues, and much more. libnet features portable packet creation interfaces at the IP and link layer, as well as a host of supplementary and complementary functionality. Using libnet, quick and simple packet assembly applications can be whipped up with little effort.  With a bit more time, more complex programs can be written (traceroute(8) and ping(8) were easily rewritten using libnet and pcap(3).

When building applications with libnet we recommend using pkg-config(1) to detect the precense and required version of libnet.  The libnet-config(1) script is still bundled in the libnet distribution, but is considered to be deprecated in favor of pkg-config(1).  Both can be used to get compiler and linker flags of the installed libnet library, as well as provide other useful information.  For applications using GNU autotools, we recommend using the PKG_PROG_PKG_CONFIG and PKG_CHECK_MODULES m4 macros.

NOTE: If you are writing your application with libnet, include libnet.h, which will include any additional header for you, rather than including libnet/libnet-functions.h, libnet/libnet-macros.h or any of the others.

Backwards Compatibility

Your old code (circa libnet 1.0.x) WILL NOT WORK with libnet> >=1.1.x. See doc/ for easy steps on porting your old code.

See Also

pkg-config(1), libnet-config(1), libnet-functions(3), libnet-macros(3)


The original author of libnet is Mike D. Schiffman.

libnet has been maintained and extensively enhanced since 2009 by Sam Roberts. It is currently maintained by the Libnet Maintainers at GitHub:



Suggestions, bug reports/fixes, and pull requests, see:


Referenced By

firewalk(8), libnet-config(3), libnet-functions(3), libnet-macros(3), libnids(3).

Wed Jan 27 2021 libnet-1.2 libnet Programmers Guide