IPv6

The tldp Linux+IPv6-HOWTO article is older, and less maintained. Yet it attempts to cover many topics that are mentioned in this article, starts from the basics, and advances in a slower pace. It also has many command line examples. Beginners might want to read or skim it before reading this wiki article.

In Arch Linux, IPv6 is enabled by default.

Neighbor discovery

Pinging the multicast address ff02::1 results in all hosts in link-local scope responding. An interface has to be specified:

$ ping ff02::1%eth0

After that, you can get a list of all the neighbors in the local network with:

$ ip -6 neigh

With a ping to the multicast address ff02::2 only routers will respond.

If you add an option -I your-global-ipv6, link-local hosts will respond with their link-global scope addresses. The interface can be omitted in this case:

$ ping -I 2001:4f8:fff6::21 ff02::1

To ping everyone on all interfaces, and announce your address to everyone, use a script.

#!/usr/bin/bash
declare -a l_ifs
readarray l_ifs < <(/sbin/ip -6 -j address | jq -r '.[] | .ifname ')
for l_if in ${l_ifs[@]} ; do
 echo $l_if
 declare -a l_addrs
 readarray l_addrs < <(/sbin/ip -6 -j address show dev "$l_if" | \
                        jq -r  '.[0].addr_info[].local')
 for l_addr in ${l_addrs[@]} ; do
   echo $l_addr
   ping -c 4 -6 -I "$l_addr" ff02::1%"$l_if"
 done
done

Stateless autoconfiguration (SLAAC)

The easiest way to acquire an IPv6 address as long as your network is configured is through Stateless address autoconfiguration (SLAAC for short). The address is automatically inferred from the prefix that your router advertises and requires neither further configuration nor specialized software such as a DHCP client.

For clients

If you are using netctl you just need to add the following line to your Ethernet or wireless configuration.

IP6=stateless

If you are using NetworkManager then it automatically enables IPv6 addresses if there are advertisements for them in the network.

Please note that stateless autoconfiguration works on the condition that IPv6 icmp packets are allowed throughout the network. So for the client side the ipv6-icmp packets must be accepted. If you are using the Simple stateful firewall/iptables you only need to add:

-A INPUT -p ipv6-icmp -j ACCEPT

If you are using an other firewall frontend (ufw, shorewall, etc) consult their documentation on how to enable the ipv6-icmp packets.

If your chosen network management solution does not support configuring the DNS resolver with stateless IPv6 (e.g. netctl), then it is possible to use rdnssd(8) from the ndisc6 package for that.

For gateways

To properly hand out IPv6s to the network clients we will need to use an advertising daemon. The standard tool for this job is radvd. Configuration of radvd is fairly simple. Edit /etc/radvd.conf to include

# replace LAN with your LAN facing interface
interface LAN {
  AdvSendAdvert on;
  MinRtrAdvInterval 3;
  MaxRtrAdvInterval 10;
  prefix ::/64 {
    AdvOnLink on;
    AdvAutonomous on;
    AdvRouterAddr on;
  };
};

The above configuration will tell clients to autoconfigure themselves using addresses from the advertised /64 block. Please note that the above configuration advertises all available prefixes assigned to the LAN facing interface. If you want to limit the advertised prefixes instead of use the desired prefix, e.g. . The block can be repeated many times for more prefixes.

To advertise DNS servers to your LAN clients you can use RDNSS feature. For example, add the following lines to /etc/radvd.conf to advertise Google's DNS v6 servers:

RDNSS 2001:4860:4860::8888 2001:4860:4860::8844 {
};

The gateway must also allow the traffic of ipv6-icmp packets on all basic chains. For the Simple stateful firewall/iptables add:

-A INPUT -p ipv6-icmp -j ACCEPT
-A OUTPUT -p ipv6-icmp -j ACCEPT
-A FORWARD -p ipv6-icmp -j ACCEPT

Adjust accordingly for other firewall frontends and do not forget to enable .

Privacy extensions

When a client acquires an address through SLAAC its IPv6 address is derived from the advertised prefix and the MAC address of the network interface of the client. This may raise privacy concerns as the MAC address of the computer can be easily derived by the IPv6 address. In order to tackle this problem the IPv6 Privacy Extensions standard (RFC 4941) has been developed. With privacy extensions the kernel generates a temporary address that is mangled from the original autoconfigured address. Private addresses are preferred when connecting to a remote server so the original address is hidden. To enable Privacy Extensions reproduce the following steps:

Add these lines to /etc/sysctl.d/40-ipv6.conf:

# Enable IPv6 Privacy Extensions
net.ipv6.conf.all.use_tempaddr = 2
net.ipv6.conf.default.use_tempaddr = 2
net.ipv6.conf.nic0.use_tempaddr = 2
...
net.ipv6.conf.nicN.use_tempaddr = 2

Where nic0 to are your Network Interface Cards. You can find their names using the instructions in Network configuration#Listing network interfaces. The or parameters are not applied to nic's that already exist when the sysctl settings are executed.

After a reboot, at the latest, Privacy Extensions should be enabled.

dhcpcd

dhcpcd's default configuration includes the option , which enables "Stable Private IPv6 Addresses instead of hardware based ones", implementing RFC 7217. Therefore, it is not necessary to change anything, except if it is desired to change of IPv6 address more often than each time the system is connected to a new network. Set it to for a stable address.

NetworkManager

The use of IPv6 Privacy Extensions in NetworkManager can be controlled with the setting in or in the connection's profile. If it is not set globally nor per-connection, NetworkManager will fall back to reading /proc/sys/net/ipv6/conf/default/use_tempaddr.

To explicitly enable IPv6 Privacy Extensions by default, add these lines to :

Apply the configuration and reconnect to all active connections.

To control the use of IPv6 Privacy Extensions for individual NetworkManager-managed connections, edit the desired connection keyfile in /etc/NetworkManager/system-connections/ and append to its section the key-value pair :

Reload the connection and reconnect to it afterwards.

systemd-networkd

systemd-networkd also does not honor the settings placed in /etc/sysctl.d/40-ipv6.conf unless the option is set with the value in the .network file(s).

Other options for the IPv6 Privacy Extensions like:

net.ipv6.conf.xxx.temp_prefered_lft
net.ipv6.conf.xxx.temp_valid_lft

are honored, however.

See systemd-networkd and for details.

ConnMan

Set in a service file, i.e. /var/lib/connman/service/settings:

IPv6.privacy=preferred

See ConnMan for details.

Stable private addresses

Another option is a stable private IP address (RFC 7217). This allows for IPs that are stable within a network without exposing the MAC address of the interface.

In order to have the kernel generate a key (for wlan0, for example) we can set:

# sysctl net.ipv6.conf.wlan0.addr_gen_mode=3

Bring the interface down and up and you should see next to each IPv6 address after running . The kernel has generated a 128-bit secret for generating ip addresses for this interface, to see it run . We are going to persist this value so add the following lines to /etc/sysctl.d/40-ipv6.conf:

# Enable IPv6 stable privacy mode
net.ipv6.conf.wlan0.stable_secret = output_from_previous_command
net.ipv6.conf.wlan0.addr_gen_mode = 2

NetworkManager

The above settings are not honored by NetworkManager, but NetworkManager uses stable private addresses by default.

Static address

Sometimes, using a static address can improve security. For example, if your local router uses Neighbor Discovery or radvd (RFC 2461), your interface will automatically be assigned an address based on its MAC address (using IPv6's Stateless Autoconfiguration). This may be less than ideal for security since it allows a system to be tracked even if the network portion of the IP address changes.

To assign a static IP address using netctl, look at the example profile in . The following lines are important:

...
# For IPv6 static address configuration
IP6=static
Address6=('1234:5678:9abc:def::1/64' '1234:3456::123/96')
Routes6=('abcd::1234')
Gateway6='1234:0:123::abcd'

IPv6 and PPPoE

The standard tool for PPPoE, , provides support for IPv6 on PPPoE as long as your ISP and your modem support it. Just add the following to

+ipv6

If you are using netctl for PPPoE then just add the following to your netctl configuration instead:

PPPoEIP6=yes

Prefix delegation (DHCPv6-PD)

Prefix delegation is a common IPv6 deployment technique used by many ISPs. It is a method of assigning a network prefix to a user site (i.e. local network). A router can be configured to assign different network prefixes to various subnetworks. The ISP hands out a network prefix using DHCPv6 (usually a /56 or ) and a dhcp client assigns the prefixes to the local network. For a simple two interface gateway it practically assigns an IPv6 prefix to the interface connected to to the local network from an address acquired through the interface connected to WAN (or a pseudo-interface such as ppp).

DHCPv6 requires the client to receive incoming connections on port 546 UDP. For an nftables-based firewall, that can be configured with one line in the input chain in /etc/nftables.conf:

table inet filter {
  chain input {
    udp dport dhcpv6-client accept
    ...
  }
...
}

With dhcpcd

dhcpcd apart from IPv4 dhcp support also provides a fairly complete implementation of the DHCPv6 client standard which includes DHCPv6-PD. If you are using edit . You might already be using dhcpcd for IPv4 so just update your existing configuration.

This configuration will ask for a prefix from WAN interface () and delegate it to the internal interface (). In the event that a range is issued, you will need to use the 2nd that is commented out instead. It will also disable router solicitations on all interfaces except for the WAN interface ().

With WIDE-DHCPv6

WIDE-DHCPv6 is an open-source implementation of Dynamic Host Configuration Protocol for IPv6 (DHCPv6) originally developed by the KAME project. It can be installed with .

If you are using wide-dhcpv6, edit /etc/wide-dhcpv6/dhcp6c.conf

The wide-dhcpv6 client can be started/enabled using the systemd unit file, where interface is the interface name in the configuration file, e.g. for a interface name "WAN" use .

systemd-networkd

Configure both your upstream (wan) and downstream (lan) interface. This will enable DHCPv6-PD on the interface where the DHCPv6 client is running. The delegated prefixes are distributed by IPv6 Router Advertisement on the downstream network.

Other clients

dhclient can also request a prefix, but assigning that prefix, or parts of that prefix to interfaces must be done using a dhclient exit script. For example: https://github.com/jaymzh/v6-gw-scripts/blob/master/dhclient-ipv6.

NAT64

Wikipedia:NAT64 is the IPv6 transition mechanism where IPv6 only hosts are able to communicate with IPv4 hosts using NAT.

Linux kernel does not support NAT64 natively but there are several packages to add support for NAT64.

Disable IPv6

Disable functionality

Adding to the kernel line disables the whole IPv6 stack, which is likely what you want if you are experiencing issues. See Kernel parameters for more information.

Alternatively, adding instead will keep the IPv6 stack functional but will not assign IPv6 addresses to any of your network devices.

One can also avoid assigning IPv6 addresses to specific network interfaces by adding the following sysctl configuration to /etc/sysctl.d/40-ipv6.conf:

# Disable IPv6
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.nic0.disable_ipv6 = 1
...
net.ipv6.conf.nicN.disable_ipv6 = 1

Restart the unit to apply the configuration changes.

Note that you must list all of the targeted interfaces explicitly, as disabling all.disable_ipv6 does not apply to interfaces that are already "up" when sysctl settings are applied.

Other programs

Disabling IPv6 functionality in the kernel does not prevent other programs from trying to use IPv6. In most cases, this is completely harmless, but if you find yourself having issues with that program, you should consult the program's manual pages for a way to disable that functionality.

dhcpcd

dhcpcd will continue to harmlessly attempt to perform IPv6 router solicitation. To disable this, as stated in the man page, add the following to :

noipv6rs
noipv6

NetworkManager

To disable IPv6 in NetworkManager, right click the network status icon, and select Edit Connections > Wired > Network name > Edit > IPv6 Settings > Method > Ignore/Disabled. Then click Save.

This can also be done as:

# nmcli connection modify ConnectionName ipv6.method "disabled"

Followed by a restart of the network connection:

# nmcli connection up ConnectionName

To confirm the settings have been applied, use ip address show and check no inet6 entry is displayed. Alternatively, should have the value 1.

ntpd

Following advice in systemd#Drop-in files, edit to define how systemd starts it.

This will create a drop-in snippet that will be run instead of the default . The flag prevents IPv6 from being used by the ntp daemon. Put the following into the drop-in snippet:

[Service]
ExecStart=
ExecStart=/usr/bin/ntpd -4 -g -u ntp:ntp

which first clears the previous , and then replaces it with one that includes the flag.

GnuPG

Disable IPv6 in the dirmngr's configuration file:

Restart the user unit afterwards.

sshd

Ensure sshd is using IPv4 by adding the following to :

/etc/ssh/sshd_config
AddressFamily inet

And restart the .

systemd-timesyncd

On occasion systemd-timesyncd will attempt to query an IPv6 timeserver even when IPv6 has been disabled. This can result in the system clock not being updated and the journal showing an error similar to:

systemd-timesyncd[336]: Failed to set up connection socket: Address family not supported by protocol

The unit status of will show an attempt to connect with an IPv6 address in its Status entry, similar to:

Status: "Connecting to time server [2001:19f0:8001:afd:5400:1ff:fe9d:cba]:123 (2.pool.ntp.org)"

Per FS#59806, only the "2." ntp.org pools serve IPv6. So to prevent this remove and from the NTP and FallbackNTP entries in file.

systemd-networkd

networkd supports disabling IPv6 on a per-interface basis. When a network unit's section has either or , networkd will not try to configure IPv6 on the matching interfaces.

Note however that even when using the above option, networkd will still be expecting to receive router advertisements if IPv6 is not disabled globally. If IPv6 traffic is not being received by the interface (e.g. due to sysctl or ip6tables settings), it will remain in the configuring state and potentially cause timeouts for services waiting for the network to be fully configured. To avoid this, the option should also be set in the section.

Prefer IPv4 over IPv6

Uncomment the following line in :

#
#    For sites which prefer IPv4 connections change the last line to
#
precedence ::ffff:0:0/96  100
gollark: > If you consider the “standard of living” to be something we should make effort improve in a utilitarian philosophy senseis just assuming utilitarian philosophy is "right".
gollark: 'Tis the is-ought problem.
gollark: Somewhat more implicitly.
gollark: This is just assuming some underlying system of ethics, though.
gollark: You can argue that people's motivations might reduce to that but I don't believe that that's the day to day reasoning.

See also

This article is issued from Archlinux. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.