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.
- 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 188.8.131.52 | 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.
It should be similar to this configuration.
DEVICE="ens18" ONBOOT="yes" BOOTPROTO="none" TYPE="Ethernet" IPADDR="184.108.40.206" NETMASK="255.255.255.0" GATEWAY="220.127.116.11" DNS1="18.104.22.168" DNS2="22.214.171.124" 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::31/48" IPV6_DEFAULTGW="2a00:7b80:452::1"
Apply the changes.
sudo systemctl restart network.service
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.