Search Our Database

How to disable ipv6 on Centos

Last updated on |

Important Note: CentOS 7 has reached its end-of-life (EOL) as of June 30, 2024. It is recommended to upgrade to a supported version, such as CentOS Stream 9 or an alternative Linux distribution, to ensure continued security updates and support.

 

Introduction

Disabling IPv6 on your server may be necessary for various reasons, such as compatibility issues or specific network configurations. This guide will walk you through the steps to disable IPv6 and configure your SSH settings accordingly.

 

Prerequisites

  • A server running CentOS 7 (with root or sudo access).
  • Basic familiarity with SSH and command-line text editors (e.g., vim or vi).

 

Step 1: Check the ipv6 on your server

 

Step 2: Go to the file /etc/sysctl.conf

vim /etc/sysctl.conf

 

 

Step 3:  Add these lines to the file, then save and exit the file (:wq)

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

 

Step 4: Run this command to load the file settings

sysctl -p

 

Step 5: Go to /etc/ssh/sshd_config

vi /etc/ssh/sshd_config

 

Step 6: Add this line to the file, then save and exit the file (:wq)

AddressFamily inet

 

Step 7: Restart sshd for changes to get effect

systemctl restart sshd

 

Step 8: Verify if the ipv6 has been disable

 

 

Conclusion

By following these steps, you have successfully disabled IPv6 on your server and configured SSH to use IPv4 only. This can help resolve compatibility issues and ensure your network configuration is aligned with your requirements. Always ensure that changes to network settings are tested to confirm they work as expected and do not disrupt service.