How to Configure IPv6 Address on AlmaLinux RockyLinux and CentOS using nmcli
An IPv6 Address is a numerical label assigned to each device participating in a computer network that uses the IPv6 protocol.
If you wish to configure Static IPv4 as well, checkout this guide How to Configure Static IPv4 Address on AlmaLinux RockyLinux and CentOS
- If you wish to configure Additional IPs, checkout this guide How to Configure Additional IPs on AlmaLinux RockyLinux and CentOS
Identify the Network Interface
Determine the name of your network interface. You can use the ip a
or ifconfig
command to list available interfaces.
Common names for interface include ens3, eth0, enp3s0 and many more,
ip a
Output:
root@vps ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 1.2.3.4 brd ff:ff:ff:ff:ff:ff
altname enp0s3
inet 192.168.0.24/24 brd 192.169.6.255 scope global noprefixroute ens3
valid_lft forever preferred_lft forever
inet6 2602:ff75::2/64 scope link noprefixroute
valid_lft forever preferred_lft forever
[root@vps ~]#
from the above output, the network interface is ens3.
also, you can find the IP address information from CrownPanel, Refer to our wiki on How to View Network Information in CrownPanel.
Modify the Connection
Configure the IPv6 address using the following command,
nmcli connection modify ens3 ipv6.addresses '2602:ff75::2/64' ipv6.method manual
Set the default gateway. Replace 2602:ff75:7::1
with the IPv6 address of your gateway,
nmcli connection modify ens3 ipv6.gateway '2602:ff75:7::1'
Note: Replace "interface" ens3 with the actual interface name that is on your server. Replace "address" 2602:ff75::2/64 with the actual IPv6 address that is assigned to your server. Replace "gateway" 2602:ff75:7::1 with the actual Gateway address assigned to the server.
Restart Network Service
Once the modification for the network interface has been updated with the additional IP information, we will go on to restart the NetworkManager for the changes to take effect.
systemctl restart NetworkManager
Alternative Method:
If the method mentioned above doesn't work, you can manually configure IPv6 using the network configuration files.
Step 1. To manually assign an IPv6 address to your network interface, navigate to the network configuration directory:
cd /etc/sysconfig/network-scripts
Step 2. List the files in the directory to find the correct network configuration file:
ls
Step 3. Edit the appropriate configuration file using nano or vi editor:
nano ifcfg-ens3
Replace
ifcfg-ens3
with the actual file name you find in the directory.
Step 4. Add or modify the following lines:
IPV6INIT=yes
IPV6ADDR=<your_ipv6_address>/64
IPV6_DEFAULTGW=<your_ipv6_gateway>
Replace
<your_ipv6_address>
with the IPv6 address you want to assign and<your_ipv6_gateway>
with the gateway address.
Step 5. After making changes, restart the network service to apply the configuration:
systemctl restart network
Step 6. Check if the IPv6 address is successfully configured:
ip -6 addr show
This will display the IPv6 addresses assigned to your network interfaces.
Step 7. Test if you have IPv6 connectivity:
ping6 google.com
Steps to Modify Default IPv6 Route
If you have configured IPv6 using any of the methods mentioned above, but the IPv6 is not functioning correctly, the issue might be related to the IPv6 route. In such cases, you can resolve this by modifying the default route using the following steps:
Step 1: Locate the Connection File usin the following command:
ls /etc/NetworkManager/system-connections/
Identify the file associated with your network interface (e.g., ens3).
Step 2: Open the file in a nano or vi text editor:
nano /etc/NetworkManager/system-connections/<connection-file>.nmconnection
replace
connection-file
with the actual file name
Step 3: Look for the [ipv6]
section. If it doesn’t exist, create it. Add or modify the gateway
and routes1
fields to set the new default gateway.
Example configuration:
[ipv6]
method=manual
address1=Your_IPv6_Address
gateway=Your_IPv6_Gateway
dns1=2001:4860:4860::8888
dns2=2001:4860:4860::8844
ignore-auto-routes=true
routes1=Enter_IPv6_default_route_here
Replace
Your_Actual_IPv6_Address
,Your_Actual_IPv6_Gateway
, andYour_Actual_IPv6_Default_Route
with the corresponding values from your network configuration.
Step 4: After editing, save the file and exit.
Step 5: Reload the NetworkManager service to apply the changes:
systemctl restart NetworkManager
Step 6: Use the ip
command to confirm that the default route has been updated:
ip -6 route
You should see the default route (::/0) pointing to the new IPv6 gateway.
This concludes our topic of configuring IPv6 Address on the AlmaLinux, Rocky Linux, and CentOS Stream 9 using NetworkManager.
CrownCloud - Get a SSD powered KVM VPS at $4.5/month!
Use the code WELCOME
for 10% off!
1 GB RAM / 25 GB SSD / 1 CPU Core / 1 TB Bandwidth per month
Available Locations: LAX | MIA | ATL | FRA | AMS