When using the IPv6 protocol on CentOS 7, if there is a problem, it is difficult to troubleshoot and solve it. Therefore, sometimes it is necessary to turn off the IPv6 function. This tutorial will show how to turn off IPv6 on CentOS 7. Follow the steps below:
Step 1: Check IPv6 Status
Verify that IPv6 is enabled by checking the network interface information with the following command:
ifconfig
If you see inet6 fe80::20c:29ff:fed0:3514
output similar to , IPv6 is enabled.
Step 2: Edit the sysctl.conf configuration file
Open the configuration file with a text editor /etc/sysctl.conf
:
vi /etc/sysctl.conf
Add the following lines at the end of the file:
net.ipv6.conf.all.disable_ipv6=1
Save and close the file.
Step 3: Edit the network configuration file
Open the configuration file with a text editor /etc/sysconfig/network
:
vi /etc/sysconfig/network
Add the following lines:
NETWORKING_IPV6=no
Save and close the file.
Step 4: Edit the network card configuration file
Open the configuration file for your network card with an appropriate text editor, eg /etc/sysconfig/network-scripts/ifcfg-eno16777736
. Please modify it according to your actual network card information.
vi /etc/sysconfig/network-scripts/ifcfg-eno16777736
Make sure the following line exists and is set to no:
IPV6INIT=no
Save and close the file.
Step 5: Disable the IPv6 rules of the firewall
Execute the following command to prevent the IPv6 rules of the firewall from being automatically enabled when the system starts:
systemctl disable ip6tables.service
Step 6: Make the changes take effect
Execute the following command to make the modification take effect:
sysctl -p
Alternatively, you can also choose to reboot the system:
reboot
Verify that IPv6 is turned off
Verify that IPv6 has been successfully turned off by checking the network interface information again with the following command:
ifconfig
Now, you should only see IPv4 addresses, and IPv6 is gone.
By following the steps above, you can successfully disable IPv6 on CentOS 7.