How to Add Ipv6 Address in Linux

How to Add Ipv6 Address in Linux

To add ipv6 address in linux, you can use the ip command for a temporary change, or edit your network configuration for a persistent setup. The exact command depends on your interface name, the IPv6 address you want to use, and whether you need the change to survive a reboot.

What you need before adding an IPv6 address

What you need before adding an IPv6 address

Before you change anything, make sure you know three things: the network interface name, the IPv6 address, and the prefix length. If you skip the prefix length or use the wrong interface, the address may be added but not work correctly.

  • Interface name, such as eth0, ens33, or enp0s3
  • IPv6 address, such as 2001:db8:1234::10
  • Prefix length, such as /64
  • Optional gateway, if you also need outbound connectivity

You can identify your interface with:

ip link show

Or, to see current IP assignments:

ip addr show

Temporary vs permanent IPv6 configuration

The quickest way to add an IPv6 address is temporary, which is useful for testing. A permanent configuration is better when the address should remain after reboot or network restart.

MethodBest forSurvives rebootTypical tools
TemporaryTesting, troubleshooting, quick changesNoip
PermanentServers, stable network settingsYesNetworkManager, systemd-networkd, netplan, distro config files

How to add an IPv6 address temporarily

How to add an IPv6 address temporarily

The most direct method is the ip command. This adds the address immediately, but it will disappear after a reboot or interface restart.

Basic syntax

sudo ip -6 addr add IPV6_ADDRESS/PREFIX dev INTERFACE

Example:

sudo ip -6 addr add 2001:db8:1234::10/64 dev eth0

This assigns 2001:db8:1234::10 with a /64 prefix to the eth0 interface.

Verify the address

ip -6 addr show dev eth0

You should see the new address listed under the interface. If it does not appear, check the interface name and whether you have the correct privileges.

Add a gateway if needed

If the address is part of a routed network and you need outbound access beyond the local subnet, you may also need a default IPv6 route:

sudo ip -6 route add default via 2001:db8:1234::1 dev eth0

Replace the gateway with the correct router address for your network. Not every setup needs a manual route, especially on networks that already provide router advertisements.

How to add an IPv6 address permanently

How to add an IPv6 address permanently

Persistent configuration depends on the networking stack your Linux system uses. The safest approach is to use the tool already managing the interface, rather than mixing multiple configuration systems on the same machine.

If you use NetworkManager

On desktops and many modern servers, NetworkManager is common. You can configure IPv6 with nmcli or a graphical tool. Using the command line is often easiest for remote administration.

sudo nmcli con show

Find the active connection name, then set the IPv6 address:

sudo nmcli con mod "CONNECTION_NAME" ipv6.addresses 2001:db8:1234::10/64
sudo nmcli con mod "CONNECTION_NAME" ipv6.method manual
sudo nmcli con up "CONNECTION_NAME"

If you also need a gateway:

sudo nmcli con mod "CONNECTION_NAME" ipv6.gateway 2001:db8:1234::1

You can confirm the saved settings with:

nmcli con show "CONNECTION_NAME"

If you use systemd-networkd

On some servers and minimal installations, systemd-networkd manages networking. In that case, add the IPv6 address in the interface’s .network file.

Example configuration:

[Match]
Name=eth0

[Network]
Address=2001:db8:1234::10/64
Gateway=2001:db8:1234::1

After editing the file, restart the service:

sudo systemctl restart systemd-networkd

Then verify:

ip -6 addr show dev eth0
ip -6 route show

If you use netplan

Ubuntu Server and some related systems use netplan. Netplan files are usually stored in /etc/netplan/ and written in YAML.

Example:

network:
  version: 2
  ethernets:
    eth0:
      addresses:
        - 2001:db8:1234::10/64
      gateway6: 2001:db8:1234::1
      nameservers:
        addresses:
          - 2001:4860:4860::8888
          - 2001:4860:4860::8844

Apply the configuration with:

sudo netplan apply

Then check the result with:

ip -6 addr show dev eth0
ip -6 route show

If your distribution uses interface config files

Some older or more traditional Linux systems still use interface configuration files. The exact file and syntax vary by distribution, so use the method recommended by your distro documentation. The important part is to assign the address, prefix length, and gateway in the network configuration that your system actually reads at boot.

How to verify the IPv6 address

After you add the address, verify both the address and the route. A successful configuration should show the address on the intended interface and, if needed, a usable route to the network or default gateway.

ip -6 addr show
ip -6 route show
ping -6 2001:db8:1234::1

If you want to test external connectivity, try a known IPv6-enabled host on your network or a public destination that your environment allows.

You can also check whether the address is global, link-local, or temporary. A link-local address usually starts with fe80:: and is automatically present on IPv6-enabled interfaces. A global unicast address is the one typically used for routed network access.

How to remove or change an IPv6 address

How to remove or change an IPv6 address

If you entered the wrong address, remove it first before adding the correct one. This avoids confusion and possible duplicate address issues.

To remove a temporary address:

sudo ip -6 addr del 2001:db8:1234::10/64 dev eth0

To replace a persistent address, edit the relevant NetworkManager, netplan, or networkd configuration, then reload or reapply it.

If the old address remains active after editing a configuration file, restart the network service or bring the connection down and up again.

Common IPv6 setup problems

  • Wrong interface name, the address is added to the wrong device or not at all
  • Incorrect prefix length, especially using the wrong subnet size
  • Missing gateway, which prevents traffic from leaving the local network
  • Duplicate address, which can cause duplicate address detection to mark it unusable
  • Conflicting network managers, for example editing netplan while NetworkManager is still managing the same interface differently
  • Firewall rules, which may block IPv6 traffic even when the address is configured correctly

If the address appears but traffic still fails, check the route table and the firewall before assuming the address itself is wrong.

Quick troubleshooting checklist

  1. Confirm the interface name with ip link show
  2. Confirm the address and prefix length are correct
  3. Check whether the address appears in ip -6 addr show
  4. Check the route with ip -6 route show
  5. Test local and routed connectivity separately
  6. Review the active network manager for the system

Best practices when adding IPv6 addresses

  • Use the network tool that already manages the interface
  • Keep temporary changes separate from persistent configuration
  • Document the prefix and gateway used on the network
  • Verify both address assignment and routing
  • Avoid editing multiple network systems for the same interface

Frequently Asked Questions About how to add ipv6 address in linux

How do I add an IPv6 address in Linux temporarily?

Use the ip command, for example: sudo ip -6 addr add 2001:db8:1234::10/64 dev eth0. This is immediate but not persistent.

How do I make an IPv6 address permanent in Linux?

Edit the configuration used by your network manager, such as NetworkManager, systemd-networkd, or netplan. The exact file or command depends on your distribution.

How do I check my IPv6 address on Linux?

Run ip -6 addr show or ip addr show. These commands display IPv6 addresses assigned to each interface.

Why is my IPv6 address not working after I add it?

Common causes include the wrong interface, incorrect prefix length, missing route or gateway, duplicate address detection, or a firewall rule blocking traffic.

What is the difference between link-local and global IPv6 addresses?

Link-local addresses start with fe80:: and work only on the local network segment. Global IPv6 addresses are routable and are used for broader network or internet access.

Can I add more than one IPv6 address to the same interface?

Yes, Linux supports multiple IPv6 addresses on one interface as long as they are valid for the network and do not conflict with one another.

Conclusion

Adding an IPv6 address in Linux is straightforward once you know whether you need a temporary or permanent configuration. For quick testing, use ip -6 addr add. For a lasting setup, configure the interface through NetworkManager, systemd-networkd, netplan, or your distribution’s network files. In either case, always verify the address, prefix, and route after making the change.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *