How to Configure Static IPv6 address on CentOS 8

Estimated reading time: 1 min

Introduction

There are multiple ways to configure your network interface. In our article, we will describe how you can change your network configuration from DHCP (dynamic) IP address to Static IPv6 address in CentOS 8.

Prerequisites

  • Cloud VPS or Dedicated Server with CentOS 8 installed.
  • You must be logged in via SSH as sudo or root user. This tutorial assumes that you are logged in as a sudo user.

Step 1: Log in using SSH

You must be logged in via SSH as sudo or root user. Please read this article for instructions if you don’t know how to connect.

Step 2: Find the active network interface

clear && echo $(ip -o -4 route get 8.8.8.8 | sed -nr 's/.*dev ([^\ ]+).*/\1/p')

Step 3: Configure the network interface

In our example, our network interface is ens18 with the following network details:

IPv6 = 2a00:7b80:452:3000::231
Netmask = /48
Gateway = 2a00:7b80:452::1

Our article will use network interface ens18 and the server details described above. Your server details will not be the same as our article and your network interface name can be different than ours. Use the network interface name from step 2.

Edit your network configuration file.

nano /etc/sysconfig/network-scripts/ifcfg-ens18

It should be similar to this configuration.

DEVICE="ens18"
ONBOOT="yes"
BOOTPROTO="none"
TYPE="Ethernet"
IPADDR="185.62.56.231"
NETMASK="255.255.255.0"
GATEWAY="185.62.56.1"
DNS1="89.207.128.252"
DNS2="89.207.130.252"
NM_CONTROLLED="NO"

Add the below lines to your current configuration file.

IPV6INIT="yes"
IPV6_AUTOCONF="no"
IPV6_DEFROUTE="yes"
IPV6_FAILURE_FATAL="no"
IPV6ADDR="2a00:7b80:452:3000::231/48"
IPV6_DEFAULTGW="2a00:7b80:452::1"

Apply the changes.

sudo systemctl restart network.service

Conclusion

Congratulations, you have now configured a static IPv6 address for your CentOS 8 Operating System. If you need to configure a static IPv4 address for your CentOS 8 please view this article.

Was this article helpful?
Dislike 7
Views: 10193

Reader Interactions

Comments

  1. RD says

    IPv6 = 2a00:7b80:452:3000::231 <================ Netmask = /48 Gateway = 2a00:7b80:452::1There is typo in yourIPV6INIT="yes" IPV6_AUTOCONF="no" IPV6_DEFROUTE="yes" IPV6_FAILURE_FATAL="no" IPV6ADDR="2a00:7b80:452:3000::31/48" <================== IPV6_DEFAULTGW="2a00:7b80:452::1"

Leave a Reply

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