---
name: "IP_MULTICAST_IF"
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_MULTICAST_IF"
---

# IP\_MULTICAST\_IF(2const)

local device for a multicast socket

## NAME

IP\_MULTICAST\_IF - local device for a multicast socket

## 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\_MULTICAST\_IF,**                **const void** *val***\[***size***\], size\_t** *size***);** **int getsockopt(int** *sockfd***, IPPROTO\_IP, IP\_MULTICAST\_IF,**                **struct in\_addr \****val***, sizeof(struct in\_addr));**

## DESCRIPTION

Set the local device for a multicast socket.

The argument for [**setsockopt**(2)](/setsockopt/2.md) is an [**ip\_mreqn**(2type)](/ip_mreqn/2type.md) or (since Linux 3.5) [**ip\_mreq**(2type)](/ip_mreq/2type.md) structure, or an **in\_addr**(2type) structure. (The kernel determines which structure is being passed based on the size passed in *size*.)

## ERRORS

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

## HISTORY

Linux 1.2.

## SEE ALSO

[**IPPROTO\_IP**(2const)](/IPPROTO_IP/2const.md), **in\_addr**(2type), [**ip\_mreqn**(2type)](/ip_mreqn/2type.md), [**setsockopt**(2)](/setsockopt/2.md), [**ip**(7)](/ip/7.md)
