---
name: "IP_MTU_DISCOVER"
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_MTU_DISCOVER"
---

# IP\_MTU\_DISCOVER(2const)

path maximum transfer unit size discovery

## NAME

IP\_MTU\_DISCOVER - path maximum transfer unit size discovery

## 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\_MTU\_DISCOVER,**                **const int \****val***, sizeof(int));** **int getsockopt(int** *sockfd***, IPPROTO\_IP, IP\_MTU\_DISCOVER,**                **int \****val***, sizeof(int));**

## DESCRIPTION

Set or receive the Path MTU Discovery setting for a socket.

When enabled, Linux will perform Path MTU Discovery as defined in RFC 1191 on **SOCK\_STREAM** sockets.

For non-**SOCK\_STREAM** sockets, **IP\_PMTUDISC\_DO** forces the don't-fragment flag to be set on all outgoing packets. It is the user's responsibility to packetize the data in MTU-sized chunks and to do the retransmits if necessary. The kernel will reject (with **EMSGSIZE**) datagrams that are bigger than the known path MTU. **IP\_PMTUDISC\_WANT** will fragment a datagram if needed according to the path MTU, or will set the don't-fragment flag otherwise.

The system-wide default can be toggled between **IP\_PMTUDISC\_WANT** and **IP\_PMTUDISC\_DONT** by writing (respectively, zero and nonzero values) to the */proc/sys/net/ipv4/ip\_no\_pmtu\_disc* file.

| | |
| --- | --- |
| Path MTU discovery value | Meaning |
| IP\_PMTUDISC\_WANT | Use per-route settings. |
| IP\_PMTUDISC\_DONT | Never do Path MTU Discovery. |
| IP\_PMTUDISC\_DO | Always do Path MTU Discovery. |
| IP\_PMTUDISC\_PROBE | Set DF but ignore Path MTU. |

When PMTU discovery is enabled, the kernel automatically keeps track of the path MTU per destination host. When it is connected to a specific peer with [**connect**(2)](/connect/2.md), the currently known path MTU can be retrieved conveniently using the [**IP\_MTU**(2const)](/IP_MTU/2const.md) socket option (e.g., after an **EMSGSIZE** error occurred). The path MTU may change over time. For connectionless sockets with many destinations, the new MTU for a given destination can also be accessed using the error queue (see [**IP\_RECVERR**(2const)](/IP_RECVERR/2const.md)). A new error will be queued for every incoming MTU update.

While MTU discovery is in progress, initial packets from datagram sockets may be dropped. Applications using UDP should be aware of this and not take it into account for their packet retransmit strategy.

To bootstrap the path MTU discovery process on unconnected sockets, it is possible to start with a big datagram size (headers up to 64 kilobytes long) and let it shrink by updates of the path MTU.

To get an initial estimate of the path MTU, connect a datagram socket to the destination address using [**connect**(2)](/connect/2.md) and retrieve the MTU by calling [**getsockopt**(2)](/getsockopt/2.md) with the [**IP\_MTU**(2const)](/IP_MTU/2const.md) option.

It is possible to implement RFC 4821 MTU probing with **SOCK\_DGRAM** or **SOCK\_RAW** sockets by setting a value of **IP\_PMTUDISC\_PROBE**. This is also particularly useful for diagnostic tools such as [**tracepath**(8)](/tracepath/8.md) that wish to deliberately send probe packets larger than the observed Path MTU.

## ERRORS

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

## STANDARDS

Linux.

## HISTORY

Linux 2.2.

- **IP\_PMTUDISC\_PROBE**

  Linux 2.6.22.

## SEE ALSO

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