How to Configure IPv6 on Linux

IPv6 configuration on Linux has evolved significantly with the introduction of modern network management tools. This guide covers the essential methods for configuring IPv6 across different Linux distributions, from checking your current status to setting up static addresses and DHCPv6 clients.

Checking IPv6 Status

Before configuring IPv6, verify whether it's currently enabled and what addresses are assigned.

The modern ip command from the iproute2 package is the standard tool for network configuration:

# Display all IPv6 addresses
ip -6 addr show

# Show only global scope IPv6 addresses (excluding [link-local](link-local-addresses-function))
ip -6 addr show scope global

# Display IPv6 routing table
ip -6 route show

Using legacy ifconfig

While deprecated, ifconfig still exists on some systems:

# Show all interfaces with IPv6 addresses (look for inet6)
ifconfig -a

Note: ifconfig is obsolete and not installed by default on modern Linux distributions.

Verify IPv6 kernel support

Check if IPv6 is enabled at the kernel level:

# Method 1: Check sysctl parameter (0=enabled, 1=disabled)
sysctl net.ipv6.conf.all.disable_ipv6

# Method 2: Check sys filesystem
cat /sys/module/ipv6/parameters/disable

# Method 3: Verify IPv6 proc entry exists
ls /proc/net/if_inet6

Configuration Methods by Distribution

Linux distributions use different network management systems. Choose the method that matches your distribution.

Method 1: NetworkManager (Fedora, RHEL, CentOS, Desktop Ubuntu)

NetworkManager is the default on most desktop Linux systems and provides both GUI and CLI configuration.

GUI Configuration

  1. Right-click the network status icon
  2. Select "Edit Connections"
  3. Choose your connection and click "Edit"
  4. Navigate to "IPv6 Settings" tab
  5. Select method: Automatic, Manual, Link-Local, or Disabled

CLI Configuration with nmcli

Configure IPv6 using NetworkManager's command-line interface:

# Add static IPv6 address
nmcli con mod eth0 ipv6.addresses "2001:db8::10/64"
nmcli con mod eth0 ipv6.gateway "2001:db8::1"
nmcli con mod eth0 ipv6.method manual

# Enable [DHCPv6](configure-dhcpv6)
nmcli con mod eth0 ipv6.method dhcp

# Enable [SLAAC](slaac-explained) (Stateless Address Autoconfiguration)
nmcli con mod eth0 ipv6.method auto

# Configure privacy extensions (RFC 4941)
nmcli con mod eth0 ipv6.ip6-privacy 2

# Configure stable privacy addressing with custom token
nmcli con mod eth0 ipv6.addr-gen-mode eui64
nmcli con mod eth0 ipv6.token "::deca:fbad:c0:ffee"

# Apply changes
nmcli con up eth0

Disable IPv6 in NetworkManager

nmcli con mod eth0 ipv6.method ignore
nmcli con up eth0

Method 2: Netplan (Ubuntu 17.10+, Ubuntu Server)

Netplan is Ubuntu's declarative network configuration tool that uses YAML syntax and can control both NetworkManager and systemd-networkd backends.

Configuration Files

Netplan configuration files are located in /etc/netplan/ with .yaml extension.

Static IPv6 Configuration

Edit /etc/netplan/01-netcfg.yaml:

network:
  version: 2
  renderer: networkd
  ethernets:
    eth0:
      dhcp4: true
      dhcp6: false
      addresses:
        - 2001:db8:1::10/64
      gateway6: 2001:db8:1::1
      nameservers:
        addresses:
          - 2001:4860:4860::8888
          - 2001:4860:4860::8844

[DHCPv6](configure-dhcpv6) Configuration

network:
  version: 2
  renderer: networkd
  ethernets:
    eth0:
      dhcp4: true
      dhcp6: true
      accept-ra: true

[SLAAC](slaac-explained) with Privacy Extensions

network:
  version: 2
  renderer: networkd
  ethernets:
    eth0:
      dhcp4: true
      dhcp6: false
      accept-ra: true
      ipv6-privacy: true

Apply Netplan Configuration

# Test configuration syntax
netplan generate

# Apply configuration
netplan apply

# Debug configuration
netplan --debug apply

Method 3: systemd-networkd (Arch, Debian Server, Minimal Systems)

systemd-networkd is the native network manager of systemd, lightweight and suitable for servers.

Configuration Files

Create or edit files in /etc/systemd/network/ with .network extension.

Static IPv6 Configuration

Create /etc/systemd/network/20-wired.network:

[Match]
Name=eth0

[Network]
Address=2001:db8:1::10/64
Gateway=2001:db8:1::1
DNS=2001:4860:4860::8888
DNS=2001:4860:4860::8844

[DHCPv6](configure-dhcpv6) Configuration

[Match]
Name=eth0

[Network]
DHCP=yes

[DHCPv6]
UseAddress=yes
UseDNS=yes

[SLAAC](slaac-explained) Configuration

[Match]
Name=eth0

[Network]
IPv6AcceptRA=yes

[IPv6AcceptRA]
DHCPv6Client=no

SLAAC with DHCPv6 for DNS

[Match]
Name=eth0

[Network]
IPv6AcceptRA=yes
DHCP=ipv6

[IPv6AcceptRA]
DHCPv6Client=yes

[DHCPv6]
UseAddress=no
UseDNS=yes

Privacy Extensions

[Match]
Name=eth0

[Network]
IPv6AcceptRA=yes
IPv6PrivacyExtensions=yes

Enable systemd-networkd

# Enable and start systemd-networkd
systemctl enable systemd-networkd
systemctl start systemd-networkd

# Restart after configuration changes
systemctl restart systemd-networkd

# Check status
systemctl status systemd-networkd
networkctl status

Method 4: Traditional /etc/network/interfaces (Debian/Ubuntu Legacy)

Older Debian-based systems use the /etc/network/interfaces file.

Static IPv6 Configuration

Edit /etc/network/interfaces:

# Static IPv6
auto eth0
iface eth0 inet6 static
    address 2001:db8:1::10
    netmask 64
    gateway 2001:db8:1::1
    dns-nameservers 2001:4860:4860::8888 2001:4860:4860::8844

SLAAC Configuration

# Enable SLAAC
auto eth0
iface eth0 inet6 auto

Apply Changes

# Restart networking service
systemctl restart networking

# Or use ifup/ifdown
ifdown eth0 && ifup eth0

System-Wide IPv6 Configuration

Sysctl Parameters

Configure IPv6 behavior at the kernel level by editing /etc/sysctl.conf or creating files in /etc/sysctl.d/.

Enable IPv6

# Enable IPv6 globally
net.ipv6.conf.all.disable_ipv6 = 0
net.ipv6.conf.default.disable_ipv6 = 0

Disable IPv6

# Disable IPv6 globally
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1

Accept Router Advertisements

# Accept RA (required for SLAAC)
net.ipv6.conf.all.accept_ra = 1
net.ipv6.conf.default.accept_ra = 1

# Accept RA even when forwarding is enabled (for routers)
net.ipv6.conf.all.accept_ra = 2

Privacy Extensions (RFC 4941)

# Enable privacy extensions
net.ipv6.conf.all.use_tempaddr = 2
net.ipv6.conf.default.use_tempaddr = 2

Values for use_tempaddr:

Disable IPv6 Autoconfiguration

# Disable SLAAC
net.ipv6.conf.all.autoconf = 0
net.ipv6.conf.default.autoconf = 0
net.ipv6.conf.all.accept_ra = 0
net.ipv6.conf.default.accept_ra = 0

Apply Sysctl Changes

# Apply immediately
sysctl -p

# Or reload from /etc/sysctl.d/
sysctl --system

# Apply single parameter
sysctl -w net.ipv6.conf.all.forwarding=1

DHCPv6 Client Setup

Most modern network managers include DHCPv6 client functionality. For standalone DHCPv6 clients:

dhclient (ISC DHCP Client)

# Request DHCPv6 lease
dhclient -6 eth0

# Release DHCPv6 lease
dhclient -6 -r eth0

# Configuration file: /etc/dhcp/dhclient6.conf

Wide DHCPv6 Client

Some distributions use the Wide DHCPv6 client:

# Install
apt install wide-dhcpv6-client   # Debian/Ubuntu
dnf install dhcpv6-client         # Fedora/RHEL

# Configuration file: /etc/wide-dhcpv6/dhcp6c.conf

Distribution-Specific Notes

Ubuntu/Debian

Fedora/RHEL/CentOS

Arch Linux

SUSE/openSUSE

Verification and Testing

After configuration, verify your IPv6 connectivity:

Local Verification

# Check assigned addresses
ip -6 addr show

# Verify routing
ip -6 route show

# Test loopback
ping6 ::1

# Test link-local (replace fe80::1 with actual gateway)
ping6 -c 4 fe80::1%eth0

# Test global connectivity
ping6 -c 4 2001:4860:4860::8888

External Connectivity Testing

Use online tools to verify your IPv6 configuration is working correctly:

# Command line tests
curl -6 https://ipv6.icanhazip.com
curl -6 https://api6.ipify.org

# DNS resolution
dig AAAA google.com
host -t AAAA google.com

Comprehensive Testing

Visit test-ipv6.run in your web browser for comprehensive IPv6 connectivity testing. This tool checks:

The testing runs entirely in your browser and provides detailed diagnostics for troubleshooting connectivity issues.

Troubleshooting

IPv6 Not Working

  1. Check if IPv6 is disabled at kernel level:

    sysctl net.ipv6.conf.all.disable_ipv6
    
  2. Verify router advertisements (for SLAAC):

    rdisc6 eth0
    
  3. Check firewall rules:

    ip6tables -L -n -v
    
  4. Examine network manager logs:

    journalctl -u NetworkManager
    journalctl -u systemd-networkd
    

No IPv6 Address Assigned

IPv6 Working but Slow

Conclusion

IPv6 configuration on Linux varies by distribution and network management tool, but the fundamental concepts remain consistent. Modern systems favor declarative configuration (Netplan, systemd-networkd) and automatic address assignment (SLAAC), while still supporting traditional static configuration when needed.

For most users, enabling DHCPv6 or SLAAC provides automatic configuration with minimal effort. System administrators requiring static addressing should choose the configuration method that matches their distribution's network manager.

Always verify your configuration with both local tools (ip, ping6) and external connectivity tests like test-ipv6.run to ensure proper dual-stack operation.