Fork me on GitHub

Netlink Protocol Library Suite (libnl)


The libnl suite is a collection of libraries providing APIs to netlink protocol based Linux kernel interfaces.

Netlink is a IPC mechanism primarly between the kernel and user space processes. It was designed to be a more flexible successor to ioctl to provide mainly networking related kernel configuration and monitoring interfaces.


The interfaces are split into several small libraries to not force applications to link against a single, bloated library.

Core library implementing the fundamentals required to use the netlink protocol such as socket handling, message construction and parsing, and sending and receiving of data. This library is kept small and minimalistic. Other libraries of the suite depend on this library.
API to the configuration interfaces of the NETLINK_ROUTE family including network interfaces, routes, addresses, neighbours, and traffic control.
API to the generic netlink protocol, an extended version of the netlink protocol.
API to netlink based netfilter configuration and monitoring interfaces (conntrack, log, queue)


The easiest method of installing the libnl library suite is to use the existing packages of your linux distribution. See the table below for a list of available packages per distribution. Please note that the list may be out of date at times. Refer to the manual of your distribution for more information on how to install packages.

Distribution libnl-3.x libnl-1.x
Source Package libnl-3.2.25.tar.gz libnl-1.1.4.tar.gz
CentOS Never packaged 1.1
Package names: libnl, libnl-devel
Debian 3.2.24
Package names: libnl-3, libnl-3-dev, libnl-route-3-200, ...
Package names: libnl1, libnl1-dev, libnl1-doc
Fedora 3.2.24
Package names: libnl3
Package names: libnl, libnl-devel
OpenSUSE 3.2.24
Package names: libnl3, libnl3-devel, libnl-config, libnl-tools
Package names: libnl-1, libnl-1_1-devel
Slackware 3.2.21 1.1
Package names: libnl-1.1
Ubuntu 3.2.24
Package names: libnl-3-200, libnl-3-200-dbg
Package names: libnl1, libnl-dev, libnl-doc

See the archives for specific older releases.


The latest stable release is: 3.2.25 (Released on Jul 16, 2014)

Changelog for 3.2.25-rc1 -> 3.2.25

Cong Wang (1):
      tc: add co_groups for tc qdisc and filter

Thomas Graf (1):
      ip6tnl: Use  for in6_addr and stuff

Thomas Haller (4):
      doc: state in documentation that libnl3 is supposed to work with 3.x kernels
      build: let script change into top source directory
      build: embed the git commit id of HEAD in the configure script
      libnl-3.2.25 release

Changelog for 3.2.24 -> 3.2.25-rc1

Cong Wang (20):
      remove the obsolete src/cls directory
      remove nl_cache_lookup() from cache.h
      basic: make BASIC_ATTR_TARGET optional
      fix comments for rtnl_act_add()
      remove some useless code in lib/route/cls/u32.c
      fill prio and protocol attr bits when parsing cls message
      link: document sk == NULL case for rtnl_link_alloc_cache()
      u32: add const to rtnl_u32_add_key_in*_addr()
      route: fix off-by-one in rtnl_act_parse()
      act: fix policy range check
      link: call rtnl_link_set_type() in link_msg_parser()
      veth: implement ->io_alloc
      veth: implement ->io_free
      veth: use nl_object_clone() to deep copy rtnl_link object
      add NLM_F_EXCL to rtnl_link_veth_add()
      veth: grab a reference for rtnl_link_veth_get_peer()
      act: grab a reference when adding an action to a filter
      act: fix a pointer in rtnl_act_msg_parse()
      tunnel: add a copy of include/linux/if_tunnel.h
      act: fix the logic of parsing actions

Hangbin Liu (3):
      gitignore: ignore ctags file
      doc/core: reply message should send from kernel to app
      gitignore: ignore patch files

Hiroaki KAWAI (1):
      python: fix wrongly passing argument to function in

Michał Górny (2):
      Explicitly create output directories for flex/yacc output.
      Use paths relative to srcdir in

Peter Wu (3):
      u32: prevent memcpy from NULL
      attr: prevent garbage return value for NULL param
      attr: fix compile warning in headers

Rich Fought (1):
      netfilter/ct: expand CT parameters that can be used in add/delete operations

Sruthi Yellamraju (1):
      cache: add missing declaration of nl_cache_move() in include/netlink/cache.h

Susant Sahani (8):
      introduce ipip tunnel support
      introduce gre tunnel support
      introduce sit tunnel support
      ipgre: fix attribute IPGRE_ATTR_OKEY in ipgre_put_attrs()
      ipgre: rename new public API to avoid confusion
      ipvti: introduce vti tunnel support
      vlan: add support for IFLA_VLAN_PROTOCOL
      ip6tnl: introduce ip6 tunnel support

Thomas Graf (1):
      link: Catch missing io_free() implementations

Thomas Haller (39):
      build: fix error when running `configure --disable-doc`
      route: fix return value of nl_rtgen_request()
      utils: fix nl_msec2str() which always returned '0msec' for whole second durations
      route: rtnl_route_build_msg() should not overwrite the route scope
      utils: add nl_has_capability() function
      utils: indicate capability NL_CAPABILITY_ROUTE_BUILD_MSG_SET_SCOPE
      route: don't enforce minlen in inet6_parse_protinfo() (IFLA_PROTINFO) and inet_parse_af() (IFLA_AF_S
      route: detect missing cfgid in rtnl_link_inet_get_conf()
      route: update kernel header snmp.h and fix inet6_parse_protinfo() after kernel API breakage
      route: rename internal copy of kernel header file 'inetdevice.h' to 'ip.h'
      route: update copy of kernel header 'ip.h'
      route/addr: only sent IFA_FLAGS when needed to workaround picky older kernels
      gitignore: ignore 'nf-ct-add' (netfilter/ct)
      docs: add code comment to explain the meaning of the fields in rtnl_addr_cacheinfo
      act: fix memory leak in rtnl_act_parse()
      doc: fix wrong name in documentation for rtnl_link_bridge_alloc()
      gitignore: ignore test binaries and artifacts in "tests/"
      gitignore: ignore test binaries and artifacts in "tests/"
      lib/socket: use proper typed constant UINT32_MAX for uint32_t typed port
      lib/socket: don't fail if no more local ports can be assigned in nl_socket_alloc
      lib/socket: retry generate local port in nl_connect on ADDRINUSE
      lib/socket: randomize the generated local port
      Merge branch 'socket_local_port'
      Merge branch 'mgorny-master'
      route/link: pass proper type to sizeof() for calloc() in vlan_parse()
      lib: reorder free() after printf("%p") statements
      route: remove unnecessary non-null check in pktloc and ematch
      cli: add error checking to nl-route-get about out-of-memory
      cls: fix array overrun in rtnl_ematch_opnd2txt()
      cache: fix crash in nl_cache_dump_filter() when omitting the params argument
      route/link: fix dangling pointer after rtnl_link_get_ifalias(link, NULL)
      netfilter/ct: fix calling nfnl_*_put() on uninitialized memory after nfnlmsg_*_parse()
      route/pktloc: read_pktlocs() always returned success status
      Merge branch 'coverity-fixes'
      build: fix error in include/
      doc: fix error in core documentation for nl_cache_mngr_alloc()
      Merge branch 'coverity-fixes-2'
      doc: fix by skipping invalid entries in libnl.dict
      attr: nla_get_u64() should return 0 if the attribute does not fully contain 64 bit

Tobias Klauser (5):
      obj: Fix dereference before NULL check
      msg: Remove unnecessary call of nlmsg_free on known NULL pointer
      cli: Fix typo in error message
      cache_mngr: Return proper error code if nl_socket_alloc() fails
      cache_mngr: Fix assignment of error code in nl_cache_mngr_alloc()

Changelog for 1.1.3 -> 1.1.4

Emmanuel Roullit (1):
      Perform no operation on nl_object_free(NULL).

Emmanuel Thierry (1):
      Wrong calcultation in nla_reserve

Jiri Pirko (1):
      use MSG_TRUNC flag to get recv message size at once

Thomas Graf (2):
      1.1.4 release
      nl: Increase receive buffer size to 4 pages

Коренберг Марк (дома) (1):
      Fix leak of cb if nl_socket_alloc_cb() failed to allocate socket


Documentation tarball: libnl-doc-3.2.25.tar.gz

Library Developer's Guide API Reference Tutorials
Core Library (libnl) Core Library Developer's Guide API Reference
Routing Family (libnl-route) Routing Library Developer's Guide API Reference
Generic Netlink Family (libnl-genl) API Reference
Netfilter Family (libnl-nf) API Reference

Mailing List

Please post questions and patches to the libnl mailinglist

Visit the info page for more information and to subscribe to the list or checkout the archives.

Known Bugs

Releases 3.2.18 and 3.2.19 have been shipped with an incorrect SONAME.

Important: 3.2.10 reverted an an uneeded SONAME bump that was done due to an ABI/API breakage in an unused API. After severe discussion, it was decided to undo the SONAME bump to make life easier for distribution maintainers by removing the unused APIs from the public header files and by providing compat header files that mistakenly included them.

If you linked against 3.2.18 or 3.2.19 your binary will not be compatible with >= 3.2.20. You will have to relink your binary. We are sorry for any inconvenience this may cause.

Git Trees

3.x releases


1.1.x releases

Support for 1.1.x releases is limited, backports are only done upon request. Do not develop new applications based on libnl1 and consider porting your applications to libnl3