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

# ipv6(7)

Linux IPv6 protocol implementation

## NAME

ipv6 - Linux IPv6 protocol implementation

## SYNOPSIS

```
#include <sys/socket.h>
#include <netinet/in.h>
```

*tcp6\_socket* **= socket(AF\_INET6, SOCK\_STREAM, 0);** *raw6\_socket* **= socket(AF\_INET6, SOCK\_RAW,** *protocol***);** *udp6\_socket* **= socket(AF\_INET6, SOCK\_DGRAM,** *protocol***);**

## DESCRIPTION

Linux 2.2 optionally implements the Internet Protocol, version 6. This man page contains a description of the IPv6 basic API as implemented by the Linux kernel and glibc 2.1. The interface is based on the BSD sockets interface; see [**socket**(7)](/socket/7.md).

The IPv6 API aims to be mostly compatible with the IPv4 API (see [**ip**(7)](/ip/7.md)). Only differences are described in this man page.

To bind an **AF\_INET6** socket to any process, the local address should be copied from the *in6addr\_any* variable which has *in6\_addr* type. In static initializations, **IN6ADDR\_ANY\_INIT** may also be used, which expands to a constant expression. Both of them are in network byte order.

The IPv6 loopback address (::1) is available in the global *in6addr\_loopback* variable. For initializations, **IN6ADDR\_LOOPBACK\_INIT** should be used.

IPv4 connections can be handled with the v6 API by using the v4-mapped-on-v6 address type; thus a program needs to support only this API type to support both protocols. This is handled transparently by the address handling functions in the C library.

IPv4 and IPv6 share the local port space. When you get an IPv4 connection or packet to an IPv6 socket, its source address will be mapped to v6.

### Address format

```
struct sockaddr_in6 {
    sa_family_t     sin6_family;   /* AF_INET6 */
    in_port_t       sin6_port;     /* port number */
    uint32_t        sin6_flowinfo; /* IPv6 flow information */
    struct in6_addr sin6_addr;     /* IPv6 address */
    uint32_t        sin6_scope_id; /* Scope ID (new in Linux 2.4) */
};
struct in6_addr {
    unsigned char   s6_addr[16];   /* IPv6 address */
};
```

*sin6\_family* is always set to **AF\_INET6**; *sin6\_port* is the protocol port (see *sin\_port* in [**ip**(7)](/ip/7.md)); *sin6\_flowinfo* is the IPv6 flow identifier; *sin6\_addr* is the 128-bit IPv6 address. *sin6\_scope\_id* is an ID depending on the scope of the address. It is new in Linux 2.4. Linux supports it only for link-local addresses, in that case *sin6\_scope\_id* contains the interface index (see [**netdevice**(7)](/netdevice/7.md))

IPv6 supports several address types: unicast to address a single host, multicast to address a group of hosts, anycast to address the nearest member of a group of hosts (not implemented in Linux), IPv4-on-IPv6 to address an IPv4 host, and other reserved address types.

The address notation for IPv6 is a group of 8 4-digit hexadecimal numbers, separated with a ':'. "::" stands for a string of 0 bits. Special addresses are ::1 for loopback and ::FFFF:\<IPv4 address\> for IPv4-mapped-on-IPv6.

The port space of IPv6 is shared with IPv4.

### Socket options

See [**IPPROTO\_IPV6**(2const)](/IPPROTO_IPV6/2const.md).

## ERRORS

- **ENODEV**

  The user tried to [**bind**(2)](/bind/2.md) to a link-local IPv6 address, but the *sin6\_scope\_id* in the supplied *sockaddr\_in6* structure is not a valid interface index.

## VERSIONS

Linux 2.4 will break binary compatibility for the *sockaddr\_in6* for 64-bit hosts by changing the alignment of *in6\_addr* and adding an additional *sin6\_scope\_id* field. The kernel interfaces stay compatible, but a program including *sockaddr\_in6* or *in6\_addr* into other structures may not be. This is not a problem for 32-bit hosts like i386.

The *sin6\_flowinfo* field is new in Linux 2.4. It is transparently passed/read by the kernel when the passed address length contains it. Some programs that pass a longer address buffer and then check the outgoing address length may break.

## NOTES

The *sockaddr\_in6* structure is bigger than the generic *sockaddr*. Programs that assume that all address types can be stored safely in a *struct sockaddr* need to be changed to use *struct sockaddr\_storage* for that instead.

**SOL\_IP**, **SOL\_IPV6**, **SOL\_ICMPV6**, and other **SOL\_\*** socket options are nonportable variants of **IPPROTO\_\***. See also [**ip**(7)](/ip/7.md).

## BUGS

The IPv6 extended API as in RFC 2292 is currently only partly implemented; although the 2.2 kernel has near complete support for receiving options, the macros for generating IPv6 options are missing in glibc 2.1.

IPSec support for EH and AH headers is missing.

Flow label management is not complete and not documented here.

This man page is not complete.

## SEE ALSO

[**IPPROTO\_IPV6**(2const)](/IPPROTO_IPV6/2const.md), [**ip**(7)](/ip/7.md)

RFC 2553: IPv6 BASIC API; Linux tries to be compliant to this. RFC 2460: IPv6 specification.
