This step by step by guide to configure IPv6 address is validated on RHEL and CentOS 7.

How-to-configure-ipv6-address-linux

IPv6 can act as a replacement for the IPv4 network protocol. The major problem it solves is the exhaustion of IPv4 addresses by using a much larger network address space. It also provides a number of enhancements and new features for network configuration management and support for future protocol changes.

The key reason IPv6 is not yet in wide deployment is that the core protocol does not have a simple way for systems that only have IPv6 addresses to communicate with systems that only have IPv4 addresses.

An IPv6 address is a 128-bit number, normally expressed as eight colon-separated groups of four hexadecimal nibbles (half-bytes). Each nibble represents four bits of the IPv6 address, so each group represents 16 bits of the IPv6 address.

2001:0001:0001:1443:0000:0000:0000:0400

To make it easier to write IPv6 addresses, leading zeros in a colon-separated group do not need to be written. However at least one nibble must be written in each field. Zeros which follow a non zero nibble in the group do not need to be written.

2001:1:1:1443:0:0:0:400

Since addresses with long strings of zeros are common, combine one or more groups of consecutive zeros with exactly one :: block.

2001:1:1:1443::400

Notice that under these rules 2001:1:1:1443::400 would be another less convenient way to write the example address. But it is a valid representation of the same address, and this can confuse administrators new to IPv6.

 

Some tips for writing consistently readable addresses

  • Always suppress all the leading zeros in a group
  • Use :: to shorten as much as possible. If two runs of zeros are equal in length, shorten the leftmost run of zeros by preference.
  • Although it is allowed, do not use :: to shorten one group of zeros, Use :0: instead, and save :: for runs of zeros longer than a single group.
  • Always use lowercase letters for hexadecimal numbers a through f.
IMPORTANT NOTE:
When including a TCP or UDP network after an IPv6 address, always enclose the IPv6 address in square brackets so that the port does not look like it is part of the address
[2001:1:1:1443::400]:80

 

Pre-requisite before starting to configure IPv6 address

Make sure that IPv6 is enable on your node. Look out for below entry in your sysctl configuration

# sysctl -a | grep ipv6.*disable
net.ipv6.conf.all.disable_ipv6 = 0
net.ipv6.conf.default.disable_ipv6 = 0
net.ipv6.conf.eno49.disable_ipv6 = 0

This will list the IPv6 status for the default value and per interface value.

Here “0” means IPv6 is in active on our node, if the above returns “1” then it means IPv6 is disable on your node. So if the IPv6 is disable then your IPv6 configuration will not work.

NOTE:
It is also possible that above command will not return any output which means that IPv6 is disable via GRUB so you must re-enable IPv6 from the GRUB and then reboot the node to activate the changes.

I have already written an article with steps to enable or disable IPv6

 

Comparison of nm-setting and ifcfg-* directives

The following table maps some of the key NetworkManager settings name relevant to IPv6 connections to ifcfg-* directives.

nmcli con modifcfg-* fileEffect
ipv6.method manualIPV6_AUTOCONF=noIPv6 is configured statically
ipv6.method autoIPV6_AUTOCONF=yesWill configure network settings using SLAAC from router advertisements.
ipv6.method dhcpIPV6_AUTOCONF=no
DHCPV6C=yes
Will configure network settings by using DHCPv6, but not SLAAC
ipv6 . addresses
"2001:db8::a/64 2001:db8::1"
IPV6ADDR=2001:db8::a/64
IPV6_DEFAULTGW=2001:db8::1
Sets static IPv6 Address and Gateway
ipv6.dns . . .DNS0=. . .Modify /etc/resolv.conf to use this nameserver
ipv6.dns-search example.comDOMAIN=example.comModify /etc/resolv.conf to use to use this domain in the search directive
ipv6.ignore-auto-dns trueIPV6_PEERDNS=noIgnore DNS server information from the DHCP server
connection.autoconnect yesONBOOT=YESAutomatically activates the connection at boot
connection.id eth0NAME=eth0The name of this connection
connection.interface-name eth0DEVICE=eth0The connection is bound to this network interface with this name
802-3-ethernet.mac-address . . .HWADDR=. . .The connection is bound to the network interface with this MAC Address

 

Configure IPv6 address using Network Manager.

Open Network Manager Console from your Linux node

# nmtui

Select Edit a Connection and click on Ok

How to configure ipv6 address in Linux (RHEL / CentOS 7)

Next look out for your Ethernet card on which you wish to configure IPv6 address. If your NIC card does not appear on the list then you can add a new device. Since for me my device (eno50) exists, so I will select the device and select Edit

How to configure ipv6 address in Linux (RHEL / CentOS 7)

This will bring you the main configuration page where you must give all the details to configure IPv6 address. Since I do not want to add IPv4 address to the same Ethernet device, I have disabled the IPv4 option.

Provide the IPv6 address/subnet and the gateway. Make sure you select Automatically Connect

How to configure ipv6 address in Linux (RHEL / CentOS 7)

Lastly click OK to exit the utility.

Now let us check the network configuration of eno50

# ip addr show dev eno50
3: eno50: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq portid 0200000000000000000000535634393543 state UP qlen 1000
    link/ether 00:17:a4:77:00:46 brd ff:ff:ff:ff:ff:ff
    inet6 2001:1:1:1443::432/122 scope global
       valid_lft forever preferred_lft forever
    inet6 fe80::1294:4a99:8233:8aaf/64 scope link
       valid_lft forever preferred_lft forever

So looks like I was able to successfully configure my interface with IPv6 address.

Validate the connectivity by pinging the IPv6 gateway

# ping6 2001:1:1:1443::43F
PING 2001:1:1:1443::43F(2001:1:1:1443::43f) 56 data bytes
64 bytes from 2001:1:1:1443::43f: icmp_seq=1 ttl=64 time=17.7 ms
64 bytes from 2001:1:1:1443::43f: icmp_seq=2 ttl=64 time=3.52 ms
64 bytes from 2001:1:1:1443::43f: icmp_seq=3 ttl=64 time=1.88 ms
64 bytes from 2001:1:1:1443::43f: icmp_seq=4 ttl=64 time=20.7 ms
^C
--- 2001:1:1:1443::43F ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3003ms
rtt min/avg/max/mdev = 1.880/10.954/20.707/8.339 ms

So I am able to connect to my gateway which means my IPv6 configuration was successful.

 

Configure IPv6 address using CLI

The following command will add a new connection for the interface eno49, which will auto connect at startup, getting IPv4 networking information using DHCPv4. It will also get IPv6 networking settings by listening for router advertisements on the locallink.

# nmcli con add con-name eno49 type ethernet ifname eno49
Connection 'eno49' (2ff6c44e-f016-4359-8eaf-121071bc612d) successfully added.

The below command configures the eno49 interface statically using the IPv6 address and network prefix 2001:1:1:1443::433/122 and default IPv6 gateway 2001:1:1:1443::43F, but it still auto connects at startup and saves its configuration into /etc/sysconfig/network-scripts/ifcfg-eno49.

# nmcli con add con-name eno49 type ethernet ifname eno49 ip6 2001:1:1:1443::433/122 gw6 2001:1:1:1443::43F
Connection 'eno49' (e6f51cfa-4dba-4fbb-b7fa-9c777a6edb52) successfully added.
# ip addr show dev eno49
2: eno49: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq portid 0100000000000000000000535634393543 state UP qlen 1000
    link/ether 00:17:a4:77:00:44 brd ff:ff:ff:ff:ff:ff
    inet6 2001:1:1:1443::433/122 scope global
       valid_lft forever preferred_lft forever
    inet6 fe80::9345:4602:8d7d:e1dd/64 scope link
       valid_lft forever preferred_lft forever

Let us validate our configuration by pinging the gateway using eno49 interface

# ping6 -I eno49 2001:1:1:1443::43F
ping6: Warning: source address might be selected on device other than eno49.
PING 2001:1:1:1443::43F(2001:1:1:1443::43f) from 2001:1:1:1443::432 eno49: 56 data bytes
64 bytes from 2001:1:1:1443::43f: icmp_seq=1 ttl=64 time=30.0 ms
64 bytes from 2001:1:1:1443::43f: icmp_seq=2 ttl=64 time=98.7 ms
64 bytes from 2001:1:1:1443::43f: icmp_seq=3 ttl=64 time=3.05 ms
64 bytes from 2001:1:1:1443::43f: icmp_seq=4 ttl=64 time=47.5 ms
^C
--- 2001:1:1:1443::43F ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3003ms
rtt min/avg/max/mdev = 3.051/44.847/98.766/34.933 ms

Again with the CLI looks like the steps are successful for me.

 

Modify existing IPv6 configuration

In the below command we are changing the IPv6 address of our interface eno49 from 2001:1:1:1443::433 to 2001:1:1:1443::434, while the gateway remains the same.

# nmcli con mod eno49 ipv6.addresses "2001:1:1:1443::434/122" gw6 "2001:1:1:1443::43F"
# nmcli con mod eno49 ipv6.method manual

Restart the eno49 interface

# nmcli con down eno49
Connection 'eno49' successfully deactivated (D-Bus activepath:/org/freedesktop/NetworkManager/ActiveConnection/178)

Next bring the the interface

# nmcli con up eno49
Connection successfully activated (D-Bus active path:/org/freedesktop/NetworkManager/ActiveConnection/180)

Validate the new IP address for eno49 device

# ip addr show dev eno49
2: eno49: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq portid 0100000000000000000000535634393543 state UP qlen 1000
    link/ether 00:17:a4:77:00:44 brd ff:ff:ff:ff:ff:ff
    inet6 2001:1:1:1443::434/122 scope global
       valid_lft forever preferred_lft forever
    inet6 fe80::9345:4602:8d7d:e1dd/64 scope link
       valid_lft forever preferred_lft forever

Check the connectivity from eno49 to it’s gateway

# ping6 -I eno49 2001:1:1:1443::43F
ping6: Warning: source address might be selected on device other than eno49.
PING 2001:1:1:1443::43F(2001:1:1:1443::43f) from 2001:1:1:1443::432 eno49: 56 data bytes
64 bytes from 2001:1:1:1443::43f: icmp_seq=1 ttl=64 time=16.0 ms
64 bytes from 2001:1:1:1443::43f: icmp_seq=2 ttl=64 time=4.40 ms
64 bytes from 2001:1:1:1443::43f: icmp_seq=3 ttl=64 time=8.54 ms
^C
--- 2001:1:1:1443::43F ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2002ms
rtt min/avg/max/mdev = 4.403/9.671/16.063/4.827 ms

Check the configuration file for eno49

# cat /etc/sysconfig/network-scripts/ifcfg-eno49
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=dhcp
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=no
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=eno49
UUID=2ff6c44e-f016-4359-8eaf-121071bc612d
DEVICE=eno49
ONBOOT=yes
IPV6ADDR=2001:1:1:1443::434/122
IPV6_DEFAULTGW=2001:1:1:1443::43f

 

I hope the steps from the article to configure IPv6 address on Linux was helpful. Let me know your suggestions and feedback using the comment section.

3 Comments

  1. I wanted to compose you this little bit of word in order to say thank you yet again over the fantastic techniques you’ve featured on this site. It was quite extremely generous with you to allow unhampered all that a number of people could possibly have marketed for an e-book to end up making some bucks for their own end, chiefly given that you could possibly have done it in the event you desired. The ideas likewise acted as the fantastic way to be aware that most people have a similar dreams just as my personal own to see more when considering this problem. I know there are lots of more fun moments in the future for individuals who scan your blog.

Leave a Reply

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