---
name: "IP_PKTINFO"
section: "2const"
platform: "linux"
package: "man-pages"
version: "6.19-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/IP_PKTINFO"
---

# IP\_PKTINFO(2const)

information about the incoming packet

## NAME

IP\_PKTINFO - information about the incoming packet

## LIBRARY

Standard C library (*libc*, *-lc*)

## SYNOPSIS

```
#include <netinet/in.h>  /* Definition of IP* constants */
#include <sys/socket.h>
```

**int setsockopt(int** *sockfd***, IPPROTO\_IP, IP\_PKTINFO,**                **const int \****enable***, sizeof(int));**

## DESCRIPTION

Pass an **IP\_PKTINFO** ancillary message that contains a [**in\_pktinfo**(2type)](/in_pktinfo/2type.md) structure that supplies some information about the incoming packet. This works only for datagram oriented sockets.

The argument is a flag that tells the socket whether the **IP\_PKTINFO** message should be passed or not.

The message itself can be sent/retrieved only as a control message with a packet using [**recvmsg**(2)](/recvmsg/2.md) or [**sendmsg**(2)](/sendmsg/2.md).

Not supported for **SOCK\_STREAM** sockets.

## ERRORS

See [**IPPROTO\_IP**(2const)](/IPPROTO_IP/2const.md). See [**setsockopt**(2)](/setsockopt/2.md). See [**ip**(7)](/ip/7.md).

## VERSIONS

Some BSD sockets implementations provide **IP\_RCVDSTADDR** and **IP\_RECVIF** socket options to get the destination address and the interface of received datagrams. Linux has the more general **IP\_PKTINFO** for the same task.

## STANDARDS

Linux.

## HISTORY

Linux 2.2.

## SEE ALSO

**in\_pktinfo**(2const), [**IPPROTO\_IP**(2const)](/IPPROTO_IP/2const.md), [**setsockopt**(2)](/setsockopt/2.md), [**ip**(7)](/ip/7.md)
