Enable IPv6 on Ubuntu VPS

How to Enable IPv6 on Ubuntu?

In most cases, IPv6 is already enabled by default on Ubuntu systems. However, if it has not been enabled yet, you can enable IPv6 on Ubuntu manually by editing configuration files such as /etc/sysctl.conf file and disabling the existing “disable_ipv6” setting via changing the value to “0” with root privileges.

Changing IPv4 to IPv6 which is the latest Internet Protocol version, is a crucial step to boost online connectivity and improve security and performance.

Level up your Ubuntu server by enabling IPv6 to ensure your Linux server prepares for the evolving internet landscape and compatibility with the latest network standards.

Requirements before enabling IPv6

  • Optimized Ubuntu server with modern versions of Ubuntu (04 and later)
  • Root privileges to edit configuration files
  • Checking your system supports IPv6 and whether IPv6 is enabled (by running ” ifconfig | grep inet6 ” command)
  • Make sure that your ISP supports IPv6
  • Familiarize yourself with network configuration tools such as NetworkManager or Netplan.
  • Ensure your DNS servers support IPv6.

Step-by-step guide to enable IPv6 on Ubuntu

To enable IPv6 on Ubuntu systems manually, here are the steps:

1. Editing Configuration Files:

To set up IPv6 on Ubuntu systems, you can modify two main configuration files:

  • Editing /etc/sysctl.conf:

After logging in to the Ubuntu server as the root user, edit /etc/sysctl.conf file which has an important role in controlling kernel parameters, with a preferred text editor (for example Vim editor):

vim /etc/sysctl.conf

If already IPv6 has been enabled, you should look for the line containing the ” disable_ipv6 ” setting (if present), and if the line containing ” net.ipv6.conf.all.disable_ipv6 ” is set to “1” value, change it to “0“.

However, if these lines do not exist, add the following lines at the end of /etc/sysctl.conf file and save the changes to enable IPv6 on the Ubuntu server:

net.ipv6.conf.default.disable_ipv6 = 0
net.ipv6.conf.all.disable_ipv6 = 0
net.ipv6.conf.lo.disable_ipv6 = 0
  • Editing /etc/network/interfaces (network interfaces file):

You can edit /etc/network/interfaces (for older Ubuntu versions) or respective Netplan YAML file ( for modern versions of Ubuntu) using a preferred text editor (such as Vim):

vim /etc/network/interfaces

So, add the following line under the configuration block of your network interface:

iface eth0 inet6 static
pre-up modprobe ipv6
address IPv6-IP-Address
netmask 64
gateway IPv6-IP-Gateway-Address

Note: replace your desired IPv6 addresses and Ubuntu IPv6 details in the previous command and save the changes to the file.

Note: before making changes to the network interface configuration file, make a backup of the file.

2. Restarting Networking Service:

After editing configuration files, restart the networking service for modification to take effect:

sudo systemctl restart networking

3. Verification:

To verify if an IPv6 address is assigned, run the following command:

ifconfig | grep inet6

Or

ip a | grep inet6

If the output shows the address starting with “fe80:”, it means IPv6 has been enabled successfully on your Linux system.

Why enable IPv6?

IPv6 (Internet Protocol Version 6) which is the most recent version of Internet Protocol (IP), was developed to address the limitations of IPv4.

All smart devices with internet connectivity require multiple IP addresses to communicate with other devices.

IPv6, by providing a larger address space, improved performance, enhanced security, and compatibility with the latest technologies and internet services, creates a significant distinction with IPv4. The main benefits of IPv6 include:

  • Using a 128-bit IP address
  • Vastly Increased Address Space compared to IPv4
  • Support for IPsec (Internet Protocol Security)
  • Efficient routing and reduced latency
  • Simplifying network configurations by eliminating NAT (Network Address Translation)
  • Support auto-configuration
  • Providing flexible options and extensions
  • Built-in authentication
  • Future-Proofing
  • Better Multicasting

Instructions for disabling IPv6 on Ubuntu

You might for reasons such as network compatibility issues, troubleshooting and debugging, resource optimization, etc, decide to disable IPv6 on your Ubuntu system; however, it is generally recommended to keep it enabled for the benefits of enabling IPv6.

There are various methods to disable IPv6 on the Ubuntu system, here are step-by-step guidelines to disable IPv6 on Ubuntu:

1. Using Sysctl.conf

Through this method, you can disable IPv6 until the next reboot (temporarily), by editing Sysctl.conf file.

Therefore, open the terminal and edit the Sysctl.conf file using your preferred text editor (such as nano editor) with sudo privileges:

sudo nano /etc/sysctl.conf

Add the below lines at the end of the file:

net.ipv6.conf.all.disable_ipv6=1
net.ipv6.conf.default.disable_ipv6=1
net.ipv6.conf.lo.disable_ipv6=1

Save the file in the nano editor by pressing Ctrl+O and exit the file.

Apply changes by typing:

sudo sysctl -p

You can be sure that IPv6 is disabled on your Ubuntu system.

2. Using sysctl Command

Another way to disable IPv6 on Ubuntu is the sysctl command. Run the following commands on the Ubuntu system to disable IPv6:

sudo sysctl -w net.ipv6.conf.all.disable_ipv6=1
sudo sysctl -w net.ipv6.conf.default.disable_ipv6=1
sudo sysctl -w net.ipv6.conf.lo.disable_ipv6=1

These commands immediately disable IPv6 on your Ubuntu system. However, after reboots, these changes do not remain.

Note: To verify that IPv6 is disabled on your Ubuntu server, use the following command:

ip a

Output should not include any IPv6 entry.

Note: After disabling IPv6 on the Ubuntu server by editing the Sysctl.conf file, you can modify the setting for remaining IPv6 disabled, after rebooting. To do this, with root privileges, create /etc/rc.local file which includes the following lines to manually read the kernel parameters from your sysctl configuration file:

#!/bin/bash
# /etc/rc.local
/etc/sysctl.d
/etc/init.d/procps restart
exit 0

Then, make the file executable using chmod command:

sudo chmod 755 /etc/rc.local

3. Using GRUB

Editing the GRUB configuration file is another way to disable IPv6 on Ubuntu VPS. GRUB (Grand Unified Bootloader) manages the boot process, Through this method, you disable IPv6 on the Ubuntu server permanently by modifying the boot arguments. Here are instructions to do this:

Open the terminal and edit the GRUB configuration file (/etc/default/grub) with the preferred text editor (for example nano editor) with administrator privileges:

sudo nano /etc/default/grub

locate line starting with GRUB_CMDLINE_LINUX_DEFAULT and GRUB_CMDLINE_LINUX , edit the line by adding the parameter ‘ ipv6.disable=1 ‘ to the end of this line:

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash ipv6.disable=1"

GRUB_CMDLINE_LINUX="ipv6.disable=1"

Save the file by pressing Ctrl+O keyboards and exit the text editor.

Update GRUB configuration by running the following command:

sudo update-grub

Reboot your Ubuntu system to apply the changes:

sudo reboot

Note: It’s recommended to enable IPv6 on your Ubuntu system due to its valuable advantages. Moreover, disabling IPv6 might cause compatibility issues with some services.

How can I see my IPv6 address in Linux?

To find your IPv6 address in a Linux system, run the following command:

ip addr show

Or

ifconfig | grep inet6

look for the inet6 parameter in the output to find all IPv6 addresses assigned to your network interfaces.

Will IPv6 enhance internet speed?

IPv6 due to its simpler structure and less reliance on NAT, improves speed. However, actual speed enhancements depend on network infrastructure and conditions.

Conclusion

By enabling IPv6 on the Ubuntu server, now you can benefit from vastly larger address space, improved routing, and optimal end-to-end connectivity and take the crucial step to remain compatible with current and future internet standards.

After enabling IPv6 on Ubuntu VPS, ensure your firewall and DNS server are configured to handle IPv6 addresses.

If you face a problem related to IPv6 on your Ubuntu system, checking logs in /var/log can help you to fix issues.

Enjoy optimal connectivity and empower your Linux server by transitioning to IPv6.

Leave a Reply

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