IPv6(7P)IPv6(7P)NAME
IPv6, ipv6, ip6 - Internet Protocol Version 6
SYNOPSISDESCRIPTIONIPv6 is the next generation network-layer protocol designed to be the
successor to the current Internet Protocol version 4 (IPv4). It pro‐
vides the packet delivery service for TCP, UDP and ICMPv6.
IPv6 has significant advantages over IPv4 in terms of increased address
space, simplified header format, integrated QoS support and mandatory
security.
IPv6 also allows optional internet-layer information to be encoded in
separate headers called extension headers which are placed between the
IPv6 header and upper layer headers. Extension headers currently sup‐
ported are hop-by-hop option header, destination option header, frag‐
ment header and routing (type 0) header. An IPv6 packet may carry
zero, one, or more extension headers, each identified by the next
header field of the preceding header.
IPv6 has extended the address size from 32 bits to 128 bits and they
are textually represented in hex-colon notation as where the x's are
the hexadecimal values of the eight 16-bit pieces of the address. For
example
IPv6 has three types of addresses: and
· An is an identifier for a single interface. A packet sent to
an unicast address is delivered to the interface identified
by that address.
· An is an identifier for a set of interfaces. A packet sent
to an anycast address is delivered to one of the interfaces
identified by that address.
· A is an identifier for a set of interfaces. A packet sent to
a multicast address is delivered to all interfaces identified
by that address.
There are no broadcast addresses in IPv6, their function is
superseded by multicast addresses.
Every IPv6 address has a associated with it. A scope is a topological
span within which the address may be used as an unique identifier for
an interface or set of interfaces.
There are several types of unicast address.
· The loopback address is assigned to the loopback interface.
It may be used by a node to send an IPv6 packet to itself.
· Link-local address uniquely identifies interfaces within a
single link and it has a fixed prefix of For example,
· Global address uniquely identifies interfaces anywhere in the
internet.
· Unique Local IPv6 Unicast address is defined in RFC 4193 and
has a fixed prefix of These addresses have a high probability
of global uniqueness, and are intended for local communica‐
tions within a limited area such as a site.
Note: Site-local address with a fixed prefix of designed
originally to uniquely identify interfaces within a single
site only is deprecated by RFC 3879. The IPv6 Address Archi‐
tecture RFC 4291 removes the special meaning for the prefix
and makes this prefix part of the global unicast pool.
There are 2 special unicast addresses which hold an embedded IPv4
address in the low order 32-bits.
· The first type is termed as IPv4-compatible IPv6 address and
is of the form This type of address is used by dual stack
(IPv4/IPv6) nodes to perform automatic IPv6-over-IPv4 tunnel‐
ing where the IPv4 tunnel endpoint address is determined from
the IPv4 address embedded in the IPv4-compatible destination
address of the IPv6 packet being tunneled.
Note: Starting with RFC4291, the IPv4-compatible IPv6 address
has been deprecated because the current IPv6 transition mech‐
anisms no longer use them.
· The second type is termed as IPv4-mapped IPv6 address and is
of the form This address facilitates IPv6 applications to
interoperate with IPv4 applications. Applications can auto‐
matically generate this address using (see getaddrinfo(3N))
when the specified host has only IPv4 address.
IPv6 Multicast
As with IPv4, an application joins a multicast group on a network
interface in order to receive multicast datagrams sent on the network
to which that interface connects.
The application must also bind to the destination port number in order
to receive datagrams that are sent to that port number. If the appli‐
cation binds to the unspecified address (all zeroes), it may receive
all datagrams that are sent to the port number. If the application
binds to a multicast group address, it may receive only datagrams sent
to that group and port number. It is not necessary to join a multicast
group in order to send datagrams to it.
For each multicast group that an application joins on a given socket
and network interface, there is an associated filter mode and source
list. The filter mode can be "exclude" mode or "include" mode. The
source list is a set of IP addresses which will be compared to the
source addresses of received multicast datagrams.
An application uses "exclude" mode when it wants to block reception of
multicast datagrams from a specific set of sources, while allowing mul‐
ticast datagrams from all other sources.
For groups in "exclude" mode, the source list may be empty, thus allow‐
ing reception of multicast datagrams from all sources. An application
uses "include" mode when it wants to allow reception of multicast data‐
grams from a specific set of sources, while blocking multicast data‐
grams from all other sources.
For groups in "include" mode, the source list needs to contain at least
one member in order for the application to stay joined to the group;
removing the last address from an "include" mode source list will cause
the application to leave the group.
Multicast socket options are not supported on SOCK_STREAM sockets.
IPv6 Socket Options
New socket options are defined for IPv6 to send and receive extension
headers and to exchange other optional information between the kernel
and application. The options are supported at the protocol level. The
type of the variable pointed to by the optval parameter is indicated in
parenthesis.
Sets or gets the hop limit used in outgoing unicast packets.
When this option is set using (see setsockopt(2)), the new
option value specified is used as the hop limit for all subse‐
quent unicast packets sent via that socket. Valid values are in
the range 0-255 (both inclusive) and the default value is 64.
For example,
int hoplimit = 50;
setsockopt(s, IPPROTO_IPV6, IPV6_UNICAST_HOPS,
&hoplimit, sizeof(hoplimit));
This option can be used with (see getsockopt(2)) to
determine the hop limit value the system will use for
subsequent unicast packets sent via that socket.
Sets or gets the hop limit used in outgoing multicast packets.
When this option is set, the new option value specified
is used as the hop limit for all subsequent multicast
packets sent via that socket. Valid values are in the
range 0-255 (both inclusive) and the default value is 1.
Sets the interface to use for outgoing multicast
packets. The option value is the index of the selected
outgoing interface. For example,
unsigned int index;
index = if_nametoindex("lan0");
setsockopt(s, IPPROTO_IPV6, IPV6_MULTICAST_IF,
&index, sizeof(index));
Enables or disables loopback in the IP
layer for multicast datagrams sent through this socket.
The value of the variable pointed to by optval is zero
(disable) or non-zero (enable). Default: enabled.
Joins a multicast group on a specified local interface.
The group is joined in "exclude" mode, with an empty
source list. is defined in as:
struct ipv6_mreq {
struct in6_addr ipv6mr_multiaddr;
uint32_t ipv6mr_interface;
};
The field holds the interface index of a local interface,
or zero. If the interface index is specified as 0 then
the default multicast interface is used. The field holds
an IPv6 multicast address or an IPv4 multicast address in
IPv4-mapped IPv6 address format.
Joins a multicast group on a specified local interface.
The group is joined in "exclude" mode, with an empty
source list. is defined in as:
struct group_req {
uint32_t gr_interface;
struct sockaddr_storage gr_group;
};
The field holds the interface index of a local interface,
or zero. If the interface index is specified as 0 then
the default multicast interface is used. The field holds
a containing an IPv6 multicast address or an IPv4 multi‐
cast address in IPv4-mapped IPv6 address format.
Leaves a multicast group on a specified local interface.
The multicast address of the group to leave and the
interface index are specified using The interface index
should match the index used while joining the group. If
the interface index is specified as 0 then the default
multicast interface is used.
Leaves a multicast group on a specified local interface.
The multicast address of the group to leave and the
interface index are specified using The interface index
should match the index used while joining the group. If
the interface index is specified as 0 then the default
multicast interface is used.
Adds a source address to the list of blocked sources for a mul‐
ticast group.
The group must already be joined, and must be in
"exclude" mode. is defined in as:
struct group_source_req {
uint32_t gsr_interface;
struct sockaddr_storage gsr_group;
struct sockaddr_storage gsr_source;
};
The field holds the interface index of a local interface,
or zero. If the interface index is specified as 0 then
the default multicast interface is used. The field holds
a containing an IPv6 multicast address or an IPv4 multi‐
cast address in IPv4-mapped IPv6 address format. The
field holds a containing an IPv6 source address or an
IPv4 source address in IPv4-mapped IPv6 address format.
The multicast address and the source address must both be
native IPv6 addresses, or must both be IPv4-mapped IPv6
addresses.
Removes a source address from the list of blocked sources for a
multicast group.
The group must already be joined, and must be in
"exclude" mode. The multicast address, interface index,
and source address are specified using The interface
index should match the index used while joining the
group. If the interface index is specified as 0 then the
default multicast interface is used.
Adds a source address to the list of allowed sources
for a multicast group in "include" mode, joining the
group in "include" mode if not already joined. The mul‐
ticast address, interface index, and source address are
specified using If the interface index is specified as 0
then the default multicast interface is used.
Removes a source address from the list of allowed sources
for a multicast group in "include" mode, leaving the
group if the last source is being removed. The multicast
address, interface index, and source address are speci‐
fied using If the interface index is specified as 0 then
the default multicast interface is used.
When this option is set, kernel computes the
checksum for outbound packets and verifies checksum on
inbound packets. The option value is the byte offset of
the checksum location in the user data. This option is
not valid for since checksum computation is mandatory for
The default value is -1 (checksums not computed nor veri‐
fied for protocols other than
When this option is enabled,
(destination IPv6 address and the arriving interface
index) is returned as ancillary data by (See recvmsg(2).)
The information is returned in structure and it is
defined in as:
struct in6_pktinfo {
struct in6_addr ipi6_addr;
uint32_t ipi6_ifindex;
};
By default this option is disabled.
When this option is enabled, inbound packet's
hoplimit is returned as ancillary data by For example,
int on = 1;
setsockopt(s, IPPROTO_IPV6, IPV6_RECVHOPLIMIT,
&on, sizeof(on));
By default this option is disabled.
When this option is enabled, inbound packet's
traffic class is returned as ancillary data by For exam‐
ple,
int on = 1;
setsockopt(s, IPPROTO_IPV6, IPV6_RECVTCLASS,
&on, sizeof(on));
By default this option is disabled.
When this option is enabled, the inbound packet's
destination options (when present) is returned as ancil‐
lary data by By default this option is disabled.
When this option is enabled, the inbound packet's
hop-by-hop options (when present) is returned as ancil‐
lary data by By default this option is disabled.
When this option is enabled, the inbound packet's
routing options (when present) is returned as ancillary
data by By default this option is disabled.
When this option is enabled, the inbound packet's
destination options appearing before a routing header
(when present) is returned as ancillary data by By
default this option is disabled.
When this option is enabled, path MTU information
will be delivered as ancillary data in the form of to
when either the application sends packets that are too
big for the path MTU, or when those packets are sent from
a socket on which the option is enabled and the packet
size is larger than the MTU of the outgoing interface.
(See recvmsg(2).) The structure is defined in as:
struct ip6_mtuinfo {
struct sockaddr_in6 ip6m_addr;
uint32_t ip6m_mtu;
};
In this situation, will return zero but there will be a
with set to and will indicate that is bytes long. This
option is not supported on SOCK_STREAM sockets. By
default this option is disabled.
This get-only option retrieves the current path MTU
value for the destination of a connected socket. This
option cannot be used with
When this option is enabled on a socket, the socket can
be used to send and receive IPv6 packets only. By
default this option is disabled.
The next ten socket options can be used with both and as option name in
ancillary data to (See sendmsg(2).)
Used to set the source address and interface index for outgoing
packets.
Used to set the hop limit for outbound packets. This hop
limit is valid for only a single output operation. To
set hop limit for all unicast or multicast IPv6 packets
use or options respectively.
Used to set the traffic class for outbound packets. If it is
specified
via ancillary data, this traffic class is valid for only
a single output operation. To set traffic class for all
outbound IPv6 packets, should be used. Valid values
range from -1 to 255, inclusive. If the value is equal
to -1, the default value (0) is used. If the value is
between 0 and 255 inclusive, the specified value is used.
Used to set the next hop address. The node
identified by this address must be a neighbor of the
sending host. When this address is the same as the des‐
tination IPv6 address then this is equivalent to socket
option.
Used to specify the routing header for outgoing
packets. Only Type 0 routing header is currently sup‐
ported.
Used to specify one or more destination options
to be sent in subsequent IPv6 packets.
Used to specify one or more hop-by-hop options
to be sent in subsequent IPv6 packets.
Used to specify one or more destination options
preceding a routing header. This option will be silently
ignored when sending packets unless a routing header is
also specified.
Used to control the behavior of path MTU discovery.
specifies that path MTU discovery will be disabled and
packets
will be sent using the minimum MTU.
specifies that path MTU discovery will be performed.
specifies
that path MTU discovery will be performed for unicast
destinations but not for multicast destinations, and
packets to multicast destinations will be sent using
the minimum MTU.
Values other than -1, 0, and 1 are not valid.
Used to disable the automatic insertion of fragment headers.
This option is not supported on SOCK_STREAM sockets. By
default this option is disabled.
IPv6 uses the enhanced version of ICMP called ICMPv6 to report errors
encountered in processing packets and for diagnostic purposes (like
ping). ICMPv6 is an integral part of IPv6 and has a next header value
of 58.
While some of the options and the associated structures are defined in
applications are not required to include this header file explicitly,
it is automatically included by
ERRORS
One of the following errors may be returned when a socket operation
fails.
The specified multicast group has been joined
already.
The specified IPv6 address is not a local interface
address or there is no route for the
specified multicast address or the speci‐
fied multicast group has not been joined.
The address family is not supported.
The parameter 'level' is not
or optval is the NULL address, or the
specified multicast address is not valid,
or the specified source address is not
valid, or the specified interface index
is not valid, or the option is not valid
for the current filter mode, or the spec‐
ified hop limit is not in the range 0 <=
x<= 255, or the specified traffic class
is not in the range -1 <= x <= 255.
Insufficient memory is available for internal system data struc‐
tures, or
the number of source addresses exceeds
the maximum number of sources allowed, as
determined by the tunable parameters and
(for IPv4), or and (for IPv6).
The parameter optname is not a valid socket option for
the level.
The option is not supported for the socket type.
AUTHOR
The socket interfaces to IP were developed by the University of Cali‐
fornia, Berkeley.
SEE ALSOndd(1M), bind(2), getsockopt(2), recv(2), recvmsg(2), send(2), setsock‐
opt(2), socket(2), getipv4sourcefilter(3N), getsourcefilter(3N),
if_nameindex(3N), inet6_opt_init(3N), inet6_rth_space(3N),
setipv4sourcefilter(3N), setsourcefilter(3N), inet(7F), ndp(7P).
RFC 2460 Internet Protocol Version 6.
RFC 3493 Basic Socket Interface Extensions for IPv6.
RFC 3542 Advanced Sockets Application Program Interface (API) for IPv6.
RFC 3678 Socket Interface Extensions for Multicast Source Filters.
RFC 3879 Deprecating Site Local Addresses.
RFC 4193 Unique Local IPv6 Unicast Addresses.
RFC 4291 IPv6 Addressing Architecture.
IPv6(7P)