var img = document.createElement('img'); img.src = "https://easystat.de/piwik.php?idsite=13&rec=1&url=https://docs.vps2day.com" + location.pathname; img.style = "border:0"; img.alt = "tracker"; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(img,s);
Skip to main content

How to configure IPv6 on CentOS

When using a virtual private server (VPS) from VPS2day it's usually not necessary to manually configure IPv6, because it's automatically configured by us upon provisioning. However, if you want to learn how to configure IPv6 on a CentOS server, this is the right tutorial to follow along.

note

This tutorial requires you to know how to edit a file. If you're unfamiliar with this, please read our tutorial on how to edit a file in Linux, first.

First, open the network configuration file under /etc/sysconfig/network-scripts/ifcfg-eth0 using your favorite text editor. If you're not logged as root you might want to prefix the command with sudo to run it with elevated privileges.

sudo nano /etc/sysconfig/network-scripts/ifcfg-eth0

Add the following lines to the file, replacing IPv6_ADDRESS with the static IPv6 address you want to use, PREFIX with the prefix length of your IPv6 address, and IPv6_GATEWAY with the static IPv6 gateway address:

IPV6INIT=yes
IPV6ADDR=IPv6_ADDRESS/PREFIX
IPV6_AUTOCONF=no
IPV6_DEFAULTGW=IPv6_GATEWAY

You'll get those values from your hosting provider. You can not just enter the IPv6 details you want as it will not work correctly. Afterward, save the file and exit the text editor.

info

For VPS2day servers, no manual configuration is required. The IPv6 address and gateway are automatically configured via RA (Router Advertisement) using a SLAAC address without privacy extensions.

In order to activate the changes, restart the network service by running the following command:

sudo systemctl restart network
warning

If you are configuring the settings via SSH, it’s normal that the session may be frozen for a few seconds. Please double-check all settings before restarting the network service. If you mis-configure your network settings, you may have to use a VNC console to fix the settings because your server might lose its network connectivity. You can learn more about the VPS2day VNC console here.

To verify that the static IPv6 address and gateway have been successfully configured, run the ip addr and ip route commands and look for the IPv6 address and gateway in the output.

Here is an example of what the output of the ip addr command might look like:

2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:11:22:33:44:55 brd ff:ff:ff:ff:ff:ff
inet 192.168.0.100/24 brd 192.168.0.255 scope global dynamic noprefixroute eth0
valid_lft 85893sec preferred_lft 85893sec
inet6 2001:db8:1234:5678::/64 scope global
valid_lft forever preferred_lft forever
inet6 fe80::211:22ff:fe33:4455/64 scope link
valid_lft forever preferred_lft forever

In this example, the static IPv6 address 2001:db8:1234:5678::/64 is configured on the eth0 interface.

Here is an example of what the output of the ip route command might look like:

default via 192.168.0.1 dev eth0 proto dhcp
192.168.0.0/24 dev eth0 proto kernel scope link src 192.168.0.100
2001:db8:1234:5678::/64 dev eth0 proto kernel metric 256

In this example, the static IPv6 gateway 2001:db8:1234:5678::/64 is configured on the eth0 interface.