Table of Contents
This step by step by guide to configure IPv6 address is validated on RHEL and CentOS 7.
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.
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.
Since addresses with long strings of zeros are common, combine one or more groups of consecutive zeros with exactly one
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
::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
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.
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.
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
|nmcli con mod||ifcfg-* file||Effect|
||IPv6 is configured statically|
||Will configure network settings using SLAAC from router advertisements.|
||Will configure network settings by using DHCPv6, but not SLAAC|
||Sets static IPv6 Address and Gateway|
||Modify /etc/resolv.conf to use this nameserver|
||Modify /etc/resolv.conf to use to use this domain in the search directive|
||Ignore DNS server information from the DHCP server|
||Automatically activates the connection at boot|
||The name of this connection|
||The connection is bound to this network interface with this name|
||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
Edit a Connection and click on
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
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.
IPv6 address/subnet and the
gateway. Make sure you select
OK to exit the utility.
Next restart the network services to activate the changes
# systemctl restart network
Now let us check the network configuration of
# 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
# 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
# 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
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
# 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
# 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
# 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
Next restart the network services to activate the changes
# systemctl restart network
I hope the steps from the article to configure IPv6 address on Linux (CentOS/RHEL 7/8) was helpful. Let me know your suggestions and feedback using the comment section.
6 thoughts on “How to configure ipv6 address in Linux (RHEL / CentOS 7/8)”
How did you get /122 when creating the new ip address and same gateway example?
This is the gateway and subnet provided by our network team.
For us noobs: the network should be restarted after the address setup:
service network restart
Thanks for your feedback, I have updated the article 🙂
I really love your website.. Very nice colors & theme. Did you make this amazing site yourself? Please reply back as I’m planning to create my very own site and want to know where you got this from or exactly what the theme is called. Kudos!
One update for Centos 8. Change
systemctl restart network
systemctl restart NetworkManager.service