Disable IPv6 on CentOS 8

29/12/2020
In this article, I am going to show you how to disable IPv6 on CentOS 8. So, let’s get started.

Checking for IPv6 Availability:

You can check whether IPv6 is enabled on your CentOS 8 machine with the following command:

$ ip a | grep inet6

If IPv6 is enabled, there will be some inet6 lines as shown in the screenshot below.

If the command does not print anything, then IPv6 should be disabled on all your network interfaces.

Disabling IPv6 Using Kernel Boot Option:

This is a permanent method of disabling IPv6 on CentOS 8. This method requires a system reboot in order for the configuration to take effect. This is also the best method of disabling IPv6 completely.

First, open the default GRUB configuration file /etc/default/grub with vi text editor as follows:

$ sudo vi /etc/default/grub

Now, go to the end of the file and press O to create a new line and switch to the vi INSERT mode.

Now, type in the following line.

GRUB_CMDLINE_LINUX="$GRUB_CMDLINE_LINUX ipv6.disable=1"

Once you’re done, the configuration file should look as follows. Now, press <Esc> to switch to vi COMMAND mode. Then type in :wq! and press <Enter> to save the file.

Now, you have to update the GRUB CFG files.

You can find the path of the GRUB CFG files with the following command:

$ sudo ls -lh /etc/grub*.cfg

As you can see, the GRUB CFG file paths are /boot/grub2/grub.cfg and /boot/efi/EFI/centos/grub.cfg

Now, run the following command to generate a new GRUB configuration file and save it to /boot/grub2/grub.cfg file:

$ sudo grub2-mkconfig -o /boot/grub2/grub.cfg

Now, run the following command to generate a new GRUB configuration file and save it to /boot/efi/EFI/centos/grub.cfg file:

$ sudo grub2-mkconfig -o /boot/efi/EFI/centos/grub.cfg

Now, reboot your CentOS 8 machine with the following command:

$ sudo reboot

As you can see, ipv6.disable=1 is appended to the kernel boot parameters. That’s great.

Now, either press <Esc> and <Enter> or press <Ctrl> + X to boot.

Once your CentOS 8 machine boots, run the following command to verify whether IPv6 is disabled.

$ ip a | grep inet6

As you can see, the command does not print anything. It means, IPv6 is disabled.

Disabling IPv6 Using sysctl:

You can also use sysctl options to disable IPv6. This method does not require a system reboot. So, if you want to disable IPv6 on the go (maybe for testing/troubleshooting), then this method may be very helpful for you. But, this method is a little bit more complicated than the kernel boot parameter method I’ve shown you earlier.

First, create a new sysctl configuration file /etc/sysctl.d/70-ipv6.conf with the following command:

$ sudo vi /etc/sysctl.d/70-ipv6.conf

Now, type in the following lines and save the file.

Before I apply the changes, I just want to show you the default values of net.ipv6.conf.all.disable_ipv6 and net.ipv6.conf.default.disable_ipv6 when IPv6 is enabled.

As you can see, the default value of net.ipv6.conf.all.disable_ipv6 is 0 when IPv6 is enabled.

$ sudo sysctl –values net.ipv6.conf.all.disable_ipv6

As you can see, the default value of net.ipv6.conf.default.disable_ipv6 is 0 when IPv6 is enabled.

$ sudo sysctl –values net.ipv6.conf.default.disable_ipv6

Now, disable IPv6 with the following command:

$ sudo sysctl –load /etc/sysctl.d/70-ipv6.conf

IPv6 should be disabled.

As you can see, the value of net.ipv6.conf.all.disable_ipv6 is 1 after IPv6 is disabled.

$ sudo sysctl –values net.ipv6.conf.all.disable_ipv6

As you can see, the value of net.ipv6.conf.default.disable_ipv6 is 1 after IPv6 is disabled.

$ sudo sysctl –values net.ipv6.conf.default.disable_ipv6

Now, run the following command to verify whether IPv6 is disabled.

$ ip a | grep inet6

As you can see, the command does not print anything. It means, IPv6 is disabled.

Now, you can reboot and the changes should persist.

$ sudo reboot

Troubleshooting sysctl IPv6 Disabling Problems:

If you’ve disabled IPv6 using the sysctl method, then one or more of your network interface may still use IPv6 once you reboot as you can see in the screenshot below.

$ ip a | grep inet6

This happens if the network interface is managed by Network Manager. This is the case for CentOS 8. CentOS 8 uses Network Manager by default.

As you can see, IPv6 is disabled for all the network interface but only one, the network interface ens160.

$ sudo sysctl –all | grep disable_ipv6

ens160 is managed by network manager. You can verify that with the following command:

$ sudo nmcli

As you can see, Network Manager configured an IPv6 address to the network interface ens160.

To disable IPv6 on the network interface ens160 from Network Manager, run the following nmcli command:

$ sudo nmcli connection modify ens160 ipv6.method ignore

Now, reboot your CentOS 8 machine for the changes to take effect.

$ sudo reboot

Once your CentOS 8 machine boots, you can verify whether IPv6 is disabled with the following command:

$ sudo ip a | grep inet6

As you can see, the command does not print anything. Which means IPv6 is disabled. Network Manager no longer assigns any IPv6 address to the network interface ens160.

So, that’s how you disable IPv6 on CentOS 8. Thanks for reading this article.

ONET IDC thành lập vào năm 2012, là công ty chuyên nghiệp tại Việt Nam trong lĩnh vực cung cấp dịch vụ Hosting, VPS, máy chủ vật lý, dịch vụ Firewall Anti DDoS, SSL… Với 10 năm xây dựng và phát triển, ứng dụng nhiều công nghệ hiện đại, ONET IDC đã giúp hàng ngàn khách hàng tin tưởng lựa chọn, mang lại sự ổn định tuyệt đối cho website của khách hàng để thúc đẩy việc kinh doanh đạt được hiệu quả và thành công.
Bài viết liên quan

[CI/CD] Phần 3: Hướng dẫn tích hợp Jenkins và Gitlab

Chắc hẳn các bạn đã nghe tới 2 khái niệm CI và CD và muốn tự động hóa một phần hoặc hoàn...
30/12/2020

BigBlueButton + Moodle : Sự kết hợp hoàn hảo cho các đơn vị đào tạo trực tuyến.

Đào tạo trực tuyến – E Learning đang là giải pháp bắt buộc đối với các đơn vị đào...
30/12/2020

Openstack Kolla [Phần 1] Hướng dẫn cài đặt Openstack Train all-in-one bằng Kolla Ansible

Openstack Kolla là Project hay công cụ sử dụng để triển khai, vận hành Openstack. Kolla được phát hành...
30/12/2020
Bài Viết

Bài Viết Mới Cập Nhật

SỰ KHÁC BIỆT GIỮA RESIDENTIAL PROXY VÀ PROXY DATACENTER
17/02/2024

Mua Proxy v6 US Private chạy PRE, Face, Insta, Gmail
07/01/2024

Mua shadowsocks và hướng dẫn sữ dụng trên window
05/01/2024

Tại sao Proxy Socks lại được ưa chuộng hơn Proxy HTTP?
04/01/2024

Mua thuê proxy v4 nuôi zalo chất lượng cao, kinh nghiệm tránh quét tài khoản zalo
02/01/2024