Configuring static IPv6 on Linux

shape
shape
shape
shape
shape
shape
shape
shape

In today’s tutorial I’m going to show you how to perform static IPv6 configuration for the Linux operating system. The IPv6 protocol has come to replace the old IPv4. Migration to IPv6 today is extremely important and inevitable given the scarcity of IPv4 addresses worldwide.

The IPv6 address is a little different from the IPv4 address. The IPv4 address is represented in decimal form and divided into 4 fields or octets as we usually call them, the octets are separated by dots and each octet has 3 digits ranging from 0 to 255, here is an example of an IPv4 address 192.168.0.1The IPv6 address uses the hexadecimal numbering system, which are numbers from 0 to 9 and letters from A to F, it has 8 fields of four digits that are called decahexateto, they are separated by the character colon, example of an IPv6 address 2001:0DB8:AD1F:25E2:CADE:CAFE:F0CA:84C1

Now that we’ve explained a bit about the IP protocol, let’s move on to its static configuration.

On Debian or Ubuntu, use your favorite text editor and open the network configuration file in the etc directory, the full path is:

nano /etc/network/interfaces

Edit the file by inserting the following lines as described below, stressing that the name of the ethernet interface must match that of your system, in my case it is ens18. What is described in the line beginning with the # symbol? is just a comment to describe the function of each subsequent line, it is not necessary for configuration, but you can also copy all the text below and paste it into your system, changing the name of the network interface to that of your system, and putting in your IPv6 address, which will work.



# Iniciar interface automaticamente.
auto ens18
#Interface de rede do meu sistema.
iface ens18 inet6 static
#Endereço que quero atribuir ao meu sistema.
address 2804:6dec:0:1::1
#Máscara de rede
netmask 64
#Gateway
gateway 2804:6dec:0:1:ffff:ffff:ffff:fffe

The configuration for Linux CentOS and Red Hat-derived systems is described below.



#O primeiro passo, é utilizar o seguinte comando para abrir o arquivo de configuração de rede do sistema:
nano -w /etc/sysconfig/network

#Então, você deverá alterar, ou se não houver nada, adicionar a seguinte linha a documentação do arquivo:
NETWORKING_IPV6=yes

#O segundo passo, é acessar esse arquivo:
nano -w /etc/sysconfig/network-scripts/ifcfg-ens18

#Insira as seguintes linhas:
IPV6INIT= yes
IPV6ADDR= 2804:6dec:0:1::1/64
IPV6_DEFAULTGW= 2804:6dec:0:1:ffff:ffff:ffff:fffe

#No terceiro passo, você abrirá o arquivo:
nano -w /etc/resolv.conf

#E por fim, adicionará
nameserver 2001:4860:4860::8888
nameserver 2001:4860:4860::8844

This way your static IPv6 will be configured. Don’t forget to restart the network service to apply the settings.

For Debian, use the command below to apply the settings.

# systemctl restart networking.service

For CentOS use the following command.

# service network restart

Leave a Reply

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

Latest news

Latest news directly from our blog.